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
Linux Articles
Page 41 of 134
Filtering Files Copied When Using rsync on Linux
The Linux command-line utility rsync is a powerful and flexible tool for synchronizing files and directories across different computers and locations. It is commonly used for backups, file transfers, and data replication. One of the main features of rsync is its ability to filter files based on various criteria such as file type, size, and modification time. Rsync Overview Rsync works by comparing the source and destination directories and copying only the files that have changed or been added to the source directory. This feature makes rsync ideal for transferring large amounts of data over networks, as it ...
Read MoreHow to Kill a Detached screen Session on Linux
Screen sessions are an excellent way to run background processes on a Linux machine. However, sometimes it becomes necessary to terminate a detached screen session that is no longer needed. This article demonstrates how to kill detached screen sessions on Linux using various command-line methods. When using the GNU screen tool, we can sometimes accumulate detached sessions that require cleanup. We'll explore several approaches for terminating these disconnected screen sessions safely and efficiently. Listing Active Sessions Before terminating sessions, let's first examine how to view existing sessions. First, we'll create a couple of sample screen sessions. In ...
Read MorePass the Output of a Command as an Argument for Another on Linux
When working with the Linux command line, we often need to use the output of one command as input or arguments for another command. This tutorial explores various methods to achieve this, including command substitution, process substitution, pipes with read, and the powerful xargs utility. Preparing Sample Files Let's create test directories and sample files to demonstrate each method: mkdir dir_example target truncate -s 10 dir_example/file{1..3}.this truncate -s 4 dir_example/file{1..2}.not This creates two directories and two sets of files: three files with 10 bytes (*.this) and two files with 4 bytes (*.not). Using ...
Read MoreEnsure Only One Instance of a Bash Script Is Running on Linux
When running a bash script on Linux, it's important to ensure that only one instance of the script is running at a time. This is especially important for scripts that perform critical tasks, such as database updates or email sending. Running multiple instances of the same script simultaneously can cause conflicts, data loss, and other errors. In this article, we will discuss different methods to ensure that only one instance of a bash script runs on Linux. Using Flock One way to ensure that only one instance of a bash script runs on Linux is to use the ...
Read MoreUsing Vim Registers on Linux
Vim is a powerful text editor widely used on Linux systems. One of the features that makes Vim so powerful is its support for registers. Registers are essentially storage locations that allow you to quickly and easily store and retrieve text. In this article, we will discuss the basics of using registers in Vim in detail, including how to copy and paste text using registers, how to display register contents, and how to manipulate register contents. Understanding Registers Before we dive into using registers, it's important to understand what they are and how they work. In Vim, there ...
Read MoreUsing the find -exec Command Option on Linux
The find command in Linux is a versatile and powerful tool for searching files and directories on a file system. The -exec option enhances find's capabilities by allowing you to execute commands on each discovered file or directory. This feature is invaluable for automating tasks like processing, modifying, or managing files that match specific criteria. Syntax and Usage The basic syntax of the find command with the -exec option is as follows − find [path] [options] -exec [command] {} \; path − The starting location for the search (can be a directory path ...
Read MoreThe Meaning of IFS in Bash Scripting on Linux
In Bash scripts on Linux, the "IFS" (Internal Field Separator) variable plays an important role in controlling how fields in a string are separated. IFS defaults to a space, tab, and newline character, which means that, by default, fields in a string are separated by any combination of these characters. However, the IFS value can be changed to meet the specific needs of a script. In this article, we will explore the meaning of IFS in Bash scripting and how it can be used in various scenarios. What is IFS? IFS is a special variable in Bash which ...
Read MoreCheck if a String Contains a Substring in Linux
Working with strings in Linux can be a bit tricky, but with the right tools it can be a piece of cake. A common task many Linux users have to perform is to check if a string contains a specific substring. This can be done using a variety of methods, including regular expressions, string manipulation commands, and programming languages like Python or Perl. However, in this article, we will explore one of the most popular and efficient methods to check if a string contains a substring in Linux, that is by using the special shell variable IFS (Internal Field Separator). ...
Read MoreLinux last Command
The last command is a powerful Linux utility used to display a list of users who have previously logged in to the system. This command is especially useful for system administrators who need to track user activity and monitor login sessions on servers. The last command can display various information including login dates, session duration, and the terminal or device used to access the system. Syntax and Options The basic syntax of the last command is as follows − last [options] [username] Common options available with the last command include − ...
Read MoreWhat is a .pid File in Linux?
On Linux, a .pid file is a process identification (PID) file that stores the process ID of a running process. The PID is a unique number assigned to each process when it starts and serves as the process identifier within the operating system. These files are typically located in /var/run or /var/run/ directories and are named after the process they represent. What is a PID File? A PID file is a simple text file containing the process ID of a running process. It gets created when the process starts and is deleted when the process terminates. System administrators, ...
Read More