Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Mukul Latiyan
Page 5 of 37
How to know what the 'errno' means in Linux?
Errno is a global variable in Linux and Unix systems that indicates the type of error that occurred during system calls and library function execution. When a system call or library function encounters an error, it sets the errno variable to a specific integer value that corresponds to the type of error. This mechanism allows developers to identify and handle different types of errors programmatically. The errno variable is defined in the header file and is thread-local in modern implementations. Each error code has both a numeric value and a symbolic constant name written in uppercase letters. ...
Read MoreHow to limit the number of results returned from grep in Linux?
The grep command in Linux is a powerful text search utility used to filter and search for specific patterns in files. When working with large files or datasets, you may want to limit the number of results returned to make the output more manageable and focused. The grep command searches for lines containing a specified pattern (regular expression) and displays matching results. By default, it returns all matching lines, but Linux provides several options to limit and control the output. Syntax grep [options] pattern [files] Common Grep Options Option Description ...
Read MoreHow to list all users in a Linux group?
In order to understand the commands to list all users in a Linux group, you first need to know how to list all users on the system. There are several ways to accomplish this, and one effective method is using the compgen command. The compgen command is a Linux utility that lists all commands executable in the terminal. When used with the -u flag, it displays all users present on the Linux system. compgen -u Output root daemon bin sys sync games man lp mail news uucp proxy www-data backup ... ...
Read MoreHow to list down all the available commands and aliases on Linux?
Linux provides a vast collection of commands and aliases that users can utilize in the terminal. These commands serve different purposes and can be executed from anywhere in the command line interface. Understanding how to list available commands and aliases is essential for efficient Linux system administration and usage. There are several approaches to discover all available commands in Linux. You can write custom shell scripts or use built-in shell functions designed for this purpose. The most effective method involves using the compgen command, which is a bash builtin specifically designed to list various shell components. Using the ...
Read MoreHow to list running screen sessions on Linux?
Screen (also known as GNU Screen) is a terminal multiplexer that allows you to start a screen session and open multiple windows within that session. A key advantage is that processes running in Screen continue to execute even when their window is not visible or when you disconnect from the session. Installing Linux Screen If the screen package is not already installed on your Linux distribution, you can install it using the appropriate command for your system. For Ubuntu and Debian sudo apt update sudo apt install screen For CentOS and Fedora ...
Read MoreHow to match two strings that are present in one line with grep in Linux?
The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display lines that contain the pattern we are searching for. When we need to find lines containing multiple strings, we can combine grep commands or use pattern matching techniques. The pattern we search for is referred to as a regular expression, and grep provides several methods to match multiple strings on the same line. Basic Grep Syntax grep [options] pattern [files] Common Grep Options ...
Read MoreHow to perform grep operation on all files in a directory?
The grep command in Linux is used to search for patterns within files. It displays lines that match a specified pattern (regular expression) and is one of the most essential utilities for text processing and file searching in Linux systems. Basic Syntax grep [options] pattern [files] Common Options Option Description -c Lists only a count of matching lines -h Displays matched lines without filenames -i Ignores case for matching -l Prints filenames only (not the matching lines) -n Displays ...
Read MoreHow to preserve colouring after piping grep to grep in Linux?
In order to preserve colouring after using pipes between grep commands, we must first understand what the grep command is and how it handles output coloring in Linux. The grep command in Linux is used to filter searches in files for a particular pattern of characters. It is one of the most used Linux utility commands to display lines that contain the pattern we are searching for. The pattern we search for is typically called a regular expression. By default, grep displays colored output when writing directly to a terminal, but this coloring is lost when output is ...
Read MoreHow to prevent a background process from being stopped after closing SSH client in Linux?
A background process in Linux is a process that runs independently of the shell session. When you start a background process and then close your SSH client, the process typically gets terminated due to the SIGHUP signal (hangup signal) sent to all child processes. This article explains several methods to prevent background processes from being stopped after SSH disconnection. Starting Background Processes In Linux, you can start a process in the background by appending the & symbol after the command: sleep 10000 & This command runs the sleep process in the background for 10, ...
Read MoreHow to quickly sum all the numbers in a file on Linux?
Consider that we have a file named bar that contains different numbers inside it. The bar file looks something like this − immukul@192 linux-questions-code % cat bar 11 12 13 We need to get the sum of all the numbers present in the above file. There are several approaches and solutions that we can consider using different commands and techniques. Let's explore these possible solutions one by one. Bash Script Approach The most basic approach is to open the file and read the contents, then calculate the sum of all the numbers using a ...
Read More