Linux Articles

Page 36 of 134

How to list all users in a Linux group?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 1K+ Views

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 More

How to Clear Linux terminal screen?

Satish Kumar
Satish Kumar
Updated on 17-Mar-2026 2K+ Views

The Linux terminal is an essential tool for system administration and daily tasks. During extended terminal sessions, the screen can become cluttered with output from various commands, making it difficult to focus on current work. Clearing the terminal screen helps maintain a clean workspace and improves productivity. Linux provides several methods to clear the terminal screen, each with different behaviors and use cases. Let's explore the most effective approaches. Using the clear Command The clear command is the most common method to clear the terminal screen. It removes all visible text and positions the cursor at the ...

Read More

How to list running screen sessions on Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 3K+ Views

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 More

How to solve "Unary operator expected" errors?

Satish Kumar
Satish Kumar
Updated on 17-Mar-2026 9K+ Views

The "unary operator expected" error is a common syntax error in Bash scripting that occurs when a conditional expression lacks the required operands. This typically happens when variables are empty or undefined, causing the shell to receive fewer arguments than expected for comparison operations. What Causes the Error? The error occurs when Bash encounters a comparison operator with missing or empty operands. Let's examine a script that demonstrates this issue − #!/bin/bash read -p "Enter the input: " num1 if [ $num1 -eq 1 ] then echo "Number entered is 1" else ...

Read More

How to quickly sum all the numbers in a file on Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 6K+ Views

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

What happens to Open File Handle if file is Moved or Deleted?

Satish Kumar
Satish Kumar
Updated on 17-Mar-2026 419 Views

When working with files that have open handles, understanding how operating systems behave during file operations like deletion, moving, or replacement is crucial. This behavior depends on how filesystems manage inodes and file references internally. Understanding Files and Inodes In Linux filesystems, files are tracked using inode numbers rather than filenames. A filename is essentially a hard link that points to an inode containing the actual file data and metadata. $ touch inode_example $ stat inode_example File: inode_example Size: 0 ...

Read More

Build complete path in Linux by concatenate two strings?

Satish Kumar
Satish Kumar
Updated on 17-Mar-2026 907 Views

In Linux systems, path concatenation is a common task when building complete file paths from separate directory and filename components. This process involves joining two or more path segments while handling special cases like trailing slashes, empty strings, and relative paths. Basic String Concatenation for Paths The simplest approach to combine paths is using variable substitution. Let's examine a practical example: $ my_home_dir="/home/shubh/baeldung/" $ repo_path="tutorials/linux-bash/command-line-arguments/src/main/bash" $ file_path="$my_home_dir$repo_path" $ echo $file_path /home/shubh/baeldung/tutorials/linux-bash/command-line-arguments/src/main/bash However, this basic approach can create issues with multiple consecutive slashes: $ file_path="$my_home_dir/$repo_path" $ echo $file_path /home/shubh/baeldung//tutorials/linux-bash/command-line-arguments/src/main/bash While Linux ...

Read More

What is the maximum number of threads per process in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 2K+ Views

Linux manages thread allocation through several system parameters and limits. The maximum number of threads per process is determined by multiple factors including system-wide thread limits, virtual memory availability, and stack size configurations. System-Wide Thread Limit The first approach to check the maximum number of threads is to examine the system-wide limit: cat /proc/sys/kernel/threads-max 61741 This value represents the total number of threads that can exist on the entire system. You can modify this limit using: echo 123456789 > /proc/sys/kernel/threads-max where 123456789 is your desired maximum thread ...

Read More

Copy a directory to an existing directory Linux?

Satish Kumar
Satish Kumar
Updated on 17-Mar-2026 1K+ Views

Copying directories is one of the most common operations in Linux system administration. The cp command is typically used for this purpose, but copying a directory into an existing directory requires specific techniques to handle content merging properly. This article explores different methods to recursively copy directory contents into an existing target directory, both with and without overwriting existing files. Understanding the Problem When copying a directory to an existing directory, we need to distinguish between two scenarios: Copying directory contents − Merge files from source into target Copying the entire directory − Create a ...

Read More

Use ./ (Dot Slash) to execute script file?

Satish Kumar
Satish Kumar
Updated on 17-Mar-2026 2K+ Views

In Linux, ./ (dot slash) is used to execute script files located in the current directory. The dot (.) represents the current working directory, and the forward slash (/) is the path separator, so ./script.sh tells the shell to run the script from the current location. What Does Dot Slash Mean? The dot (.) in Linux represents the current working directory. When combined with the forward slash (/), it creates a relative path that points to files in your current location. For example: $ ls -l -rwxr-xr-x 1 user1 user1 156 Jun 12 19:09 script.sh -rw-r--r-- ...

Read More
Showing 351–360 of 1,338 articles
« Prev 1 34 35 36 37 38 134 Next »
Advertisements