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
Operating System Articles
Page 101 of 171
What Does cd do on Linux
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 MoreCheck if Directory is Mounted in Bash on Linux
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 MoreMapping Hostnames with Ports in /etc/hosts
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 MoreNegate an if Condition in a Bash Script in Linux
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 MoreEncrypting and Decrypting Directory in Linux
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 MoreWhen to Use an Alias vs Script vs a New Function in Bash
When working with Bash, it's important to understand the differences between using an alias, a script, and a function. Each has its own unique use case and can be used to accomplish different tasks efficiently. Aliases An alias is a way to create a shortcut for a command or series of commands. They are defined using the alias keyword followed by the desired shortcut and the command it should reference. For example, the following creates an alias for the ls -la command − alias ll='ls -la' This allows the user to type ll instead ...
Read MoreUsing sed With a Literal String Instead of an Input File
The sed (Stream Editor) command is a powerful text processing tool that typically operates on files. However, it can also process literal strings directly without requiring input files. This capability is particularly useful for quick text transformations, scripting, and pipeline operations where you need to manipulate text data on-the-fly. Using the Echo Command with Pipes The most common method to use sed with a literal string is by piping the output of the echo command to sed. This approach allows you to process text directly from the command line. echo "This is an old string" | ...
Read MoreChecking Host's Network Availability in Linux
When working with Linux systems, it is essential to verify network connectivity to specific hosts. This capability is crucial for troubleshooting connectivity issues, monitoring network performance, and checking the status of servers or devices. Linux provides several powerful command-line tools for network diagnostics. Ping Command The ping command is the most fundamental tool for checking network availability. It sends Internet Control Message Protocol (ICMP) echo request packets to a target host and waits for echo reply packets. Basic Ping Usage ping [hostname or IP address] Examples: ping www.example.com ping 192.168.1.1 ...
Read MoreHow to Create a crontab Through a Script on Linux
Creating a crontab through a script on Linux is a simple and efficient way to automate repetitive tasks and schedule them to run at specific intervals. This article explores how to create and manage crontab entries through scripts, including practical examples and troubleshooting tips. What is a Crontab? A crontab (cron table) is a configuration file that specifies shell commands to run periodically on a given schedule. The cron daemon reads these files and executes commands at the specified times. Each user can have their own crontab file, making it useful for tasks such as running backups, sending ...
Read MoreWhy Should We Disable Root-login over SSH on Linux
Root-login over SSH is a common method for gaining access to a Linux server, but it poses significant security risks. In this article, we will explore the reasons why disabling root-login over SSH is a critical security practice, and provide step-by-step examples of how to implement this safeguard. What is Root-Login Over SSH? When a Linux server is set up, the root user is created by default. The root user is the most powerful user on the system, with unrestricted privileges to perform any task, including making changes to system configuration, installing software, creating users, and accessing all ...
Read More