Linux Articles

Page 59 of 134

Find the Current Working Directory of a Running Process in Linux

Pradeep Jhuriya
Pradeep Jhuriya
Updated on 17-Mar-2026 9K+ Views

One of the basic tasks when working with processes on a Linux system is determining the current working directory of a process. The current working directory, also known as the "current directory" or "current working folder, " is the directory in which a process runs and interacts with files. Knowing the current working directory of a process can be useful for debugging, understanding the environment in which a process is running, or monitoring process activity. In this article, we will discuss how to find the current working directory of a running process on Linux. We will cover several methods ...

Read More

Run Cron Job Only If It Isn't Already Running in Linux

Pradeep Jhuriya
Pradeep Jhuriya
Updated on 17-Mar-2026 2K+ Views

Cron is a utility in Linux that allows users to schedule commands or scripts to run automatically at a specific date and time. However, sometimes it may be necessary to ensure that a cron job does not run more than once at a time, preventing resource conflicts or data corruption. In this article, we will discuss two effective methods to prevent overlapping cron tasks: using process tracking and using a .pid file. Method 1: Process Detection with pgrep One way to avoid overlapping cron task execution is to check for the presence of the task's process before running ...

Read More

Move All Files Including Hidden Files Into Parent Directory in Linux

Pradeep Jhuriya
Pradeep Jhuriya
Updated on 17-Mar-2026 10K+ Views

In Linux, hidden files (also called dotfiles) are files whose names begin with a dot (.) character. These files typically store configuration data or system settings that should be handled carefully. When you need to move all files from a subdirectory to its parent directory, including these hidden files, Linux provides several effective methods. Using the mv Command The mv command is the standard tool for moving files and directories from one location to another. It can also be used to rename files and directories. Moving Visible Files Only To move all visible files from a ...

Read More

Search Within Specific File Types Using grep on Linux

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

The grep command in Linux is a powerful text search utility that allows you to search for specific patterns within files. When working with large directory structures containing various file types, you can combine grep with specific options to search only within files of particular types, making your searches more targeted and efficient. Basic File Type Search with grep To search for a specific pattern within a specific file type, use the --include option with the -r (recursive) flag. This combination allows you to search through directories while filtering by file extension. grep -r 'example' --include='*.txt' ...

Read More

Read the Source Code of Shell Commands on Linux

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

Reading the source code of shell commands on Linux helps developers understand how commands work internally and learn system programming techniques. Most Linux commands are compiled binaries, so you cannot simply view their source code with text editors like you would with script files. Understanding Command Types Before searching for source code, it's important to identify the type of command using the type command − type ls type cd type echo This will show whether a command is a binary executable, shell builtin, alias, or function. Only binary executables and scripts have readable source ...

Read More

What Does cd do on Linux

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

The cd command stands for "change directory" and is used to navigate the file system on a Linux computer. When used with a specific directory path as an argument, cd will change the current working directory to that location. For example, the command cd /home/user/documents will change the current working directory to the "documents" folder located within the "user" folder in the root directory. If you use cd command without any argument it will take you to your home directory. Basic cd Command Usage Here are the most common ways to use the cd command − ...

Read More

Check if Directory is Mounted in Bash on Linux

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

Checking if a directory is mounted is a common system administration task in Linux. There are several reliable methods to determine whether a specific directory serves as a mount point, each with different advantages and use cases. Using the mount Command The mount command is the most traditional method to check mounted filesystems. To check if a specific directory is mounted, combine it with grep − mount | grep "/mnt/data" If the directory is mounted, this returns information about the mount point, filesystem type, and source device. If not mounted, no output is displayed. ...

Read More

Mapping Hostnames with Ports in /etc/hosts

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

The /etc/hosts file is a simple text file used to map hostnames to IP addresses locally on a system. It provides hostname resolution by bypassing DNS servers, allowing administrators to define custom IP-to-hostname mappings. Each line represents a single mapping with the IP address followed by one or more hostnames separated by spaces. Understanding the Hosts File Structure The hosts file is located at /etc/hosts on Unix-like systems and C:\Windows\System32\drivers\etc\hosts on Windows. It follows a simple format where each line contains an IP address followed by hostnames: 192.168.1.100 myserver.local 127.0.0.1 localhost ::1 localhost When ...

Read More

Negate an if Condition in a Bash Script in Linux

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

To negate an if condition in a Bash script in Linux, you can use the ! operator (logical NOT). This operator reverses the truth value of a condition — if the condition would normally be true, negation makes it false, and vice versa. For example, instead of checking if [ $x -eq 5 ], you can use if [ ! $x -eq 5 ] to execute commands when the variable is not equal to 5. Basic Negation Syntax The ! operator is placed inside the test brackets, immediately after the opening bracket: if [ ! condition ...

Read More

Encrypting and Decrypting Directory in Linux

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

Directory encryption in Linux provides essential security for protecting sensitive data from unauthorized access. There are several methods available, each with different strengths and use cases. This guide covers the most popular utilities for encrypting and decrypting directories. GPGtar for Archive Encryption GPGtar is a utility that combines tar archiving with GPG encryption, allowing you to encrypt entire directories as compressed archives. It uses GNU Privacy Guard (GPG) to encrypt files within a tar archive, making it ideal for securing large numbers of files at once. Creating an Encrypted Archive To create an encrypted tar archive ...

Read More
Showing 581–590 of 1,338 articles
« Prev 1 57 58 59 60 61 134 Next »
Advertisements