Found 1090 Articles for Operating System

Read Random Line From a File in Linux

Satish Kumar
Updated on 24-Mar-2023 15:20:44
In Linux, reading a random line from a file can be a useful task in various scenarios. For example, when you want to select a random word from a dictionary or randomly select a line from a log file for analysis purposes. There are several ways to read a random line from a file in Linux. In this article, we will explore different methods to achieve this task along with their pros and cons. Method 1: Using shuf Command The shuf command is a simple and efficient way to read a random line from a file in Linux. shuf command ... Read More

How to Call an External Program Using awk

Satish Kumar
Updated on 24-Mar-2023 15:20:03
Introduction Awk is a powerful text processing tool that can be used to automate various tasks such as data manipulation, filtering, and reporting. One of interesting features of awk is its ability to call external programs from within script. In this article, we will explore how to call an external program using awk. Understanding System() Function The system() function is used to execute external commands from within awk. syntax of system() function is as follows − system(command) The command argument is external command that we want to execute. When system() function is executed, awk passes command argument to ... Read More

The “Oldconfig” Target In The Linux Kernel Makefile

Kunal Verma
Updated on 23-Mar-2023 18:27:12
Abstract The Linux kernel is the core component of the Linux operating system, and it is responsible for managing system resources and providing various services to user space applications. Building the Linux kernel from source is a common task for developers and system administrators, and the Makefile is the primary tool used for this purpose. One of the targets provided by the Makefile is the "oldconfig" target, which is used to update the kernel configuration file based on the current system configuration. In this tutorial, we will explain the "oldconfig" target and how to use it. Note − Linux commands ... Read More

Testing Bash Scripts With Bats in Linux

Kunal Verma
Updated on 23-Mar-2023 18:26:13
Abstract There are countless applications for the widely used and beneficial scripting language bash. Despite the fact that the language itself is widely used, testing it is not as common. This may result in expensive mistakes and reduced trust in the code. In this article, we are going to understand how to test bash scripts with the Bats in the Linux. Note − Linux commands are case-sensitive. What is BATS? Bash Automated Testing System, sometimes known as BATS, is a testing framework. Before a bash program is released, it may be verified using this automated testing procedure that it is ... Read More

Skip Hidden Files and Directories During Recursive Copy

Kunal Verma
Updated on 23-Mar-2023 18:24:41
Abstract On the Linux command line, cp -r can be the first command that appears when we want to copy directories recursively. Dotfiles are understood to function under Linux as hidden files. We occasionally exclude hidden files and directories from directories while copying them recursively. We'll learn how to do it in this tutorial. Note − Linux commands are case-sensitive. SCP command Using the command-line tool SCP (secure copy), you can safely move files and directories between two places. We can copy a file or directory with scp from a local system to a remote system, from a remote ... Read More

Parse Command Line Arguments in Bash on Linux

Kunal Verma
Updated on 23-Mar-2023 18:23:59
Abstract Command-line arguments can be entered sequentially or processed into options by bash programs. These arguments are used by command-line utilities to selectively select between execution environments or conditionally trigger functions in a Bash script. They can be set up in various ways in Bash. Note − Linux commands are case-sensitive. getopt Syntax The Syntax for getopts is − $ getopts optstring opt [arg ...] The following applies to the aforementioned function − The options are represented by an optstring. If there is a colon (:) following the option, it expects a response. In the optstring, option c, ... Read More

How to Show the wget Progress Bar Only in Linux?

Kunal Verma
Updated on 23-Mar-2023 18:23:18
Abstract Remote management of UNIX/Linux/BSD servers via an ssh session is a common practice. For installation, you might need to download the software or other files. For Linux operating systems, a few strong graphical download managers are available. However, the non-interactive downloader is preferred when using the wget command at the command line or shell prompt. The wget command supports a wide range of settings and Internet protocols, including HTTP, FTP, HTTPS, and others. One of the simplest uses of the wget command is to download a single file and place it in the directory where you are currently working. ... Read More

How to Set Wget Connection Timeout in Linux?

Kunal Verma
Updated on 23-Mar-2023 18:22:38
Abstract When working in a Linux environment, you have the freedom to decide how you want to download your files from a transparent URL. The majority of users are accustomed to Linux's interactive method of downloading such files. This interactive method involves using a web browser, where a user clicks on a download button that is available and waits until the file download has begun and is successfully finished. An alternate method for obtaining network-based files through a non-interactive or command-line environment is the free GNU software Wget. The Wget utility's non-interactive property suggests that your file downloads can proceed ... Read More

Fixing the "Too many open files" Error in Linux

Kunal Verma
Updated on 23-Mar-2023 18:21:55
Abstract On Linux servers under heavy load, "too many open files" problems occur frequently. It denotes that a process is unable to open new files (file descriptors) because it has opened too many already. The "max open file limit" is predetermined by default for each process or user on Linux, and the settings are modest. The number of concurrent files descriptor users and processes is constrained. The "Too many open files error" appears when the limit is reached when the user or process tries to open more file descriptors. Therefore, increasing the maximum number of file descriptors a user or ... Read More

Find the Process That is Using a File in Linux

Kunal Verma
Updated on 23-Mar-2023 18:20:05
Abstract There may be a situation where, despite the fact that no one is attempting to access the share to your knowledge, you are unable to unmount it. This is typically seen while mounting a share. The potential error that you could experience is "the file is busy", or we may occasionally see the notice "the file is busy" when attempting to access a file. This indicates that a process is active on the system that is using the file and keeping it open for reading or writing. Sometimes, when this occurs, we'll want to figure out which process is ... Read More