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 60 of 134
When 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 MoreRedirecting the Output of an Already Running Process on Linux
Redirecting the output of an already running process on Linux is a powerful technique that allows you to capture or reroute the stdout and stderr streams of processes that are currently executing. This capability is essential for system administrators and developers who need to monitor, debug, or analyze process output without interrupting the running application. Using /proc File System for Direct Redirection The most direct method involves manipulating file descriptors through the /proc filesystem. Every running process has file descriptors accessible via /proc/PID/fd/. Redirecting stdout to a File # Find the process ID ps aux ...
Read MoreRemove the First Line of a Text File in Linux
There are several ways to remove the first line of a text file in Linux. In this article, we will explore four different methods that can be used to accomplish this task, each with its own advantages and syntax. Method 1: Using the head Command The head command displays the first few lines of a text file. To remove the first line, we use the -n option with a negative value. The -n -1 option tells head to display all lines except the last one, which effectively removes the first line when we want all but the first. ...
Read MoreThe netcat Command in Linux
The netcat command in Linux is a powerful network utility for communication and troubleshooting. It allows users to read and write data to network connections using TCP or UDP protocols. Often called the nc command, netcat serves as a versatile tool for establishing connections, transferring files, port scanning, and network debugging. What is the netcat command? The netcat command, also known as nc, is a command-line utility that enables reading and writing data over network connections. It can establish connections to servers and clients, send and receive data, and perform various network-related tasks. Network administrators commonly use it ...
Read MoreFind and tar Files on Linux
One of the most powerful features of the Linux operating system is the ability to find and manipulate files quickly and easily from the command line. This can be especially useful when working with large numbers of files or when you need to automate certain tasks. In this article, we will explore two essential command-line tools for finding and compressing files on Linux: the find command and the tar command. Finding Files with the find Command The find command is a powerful tool that allows you to search for files on your Linux system based on various criteria ...
Read MorePreserve Bash History in Multiple Terminal Windows on Linux
Bash history is a powerful tool that can help you keep track of all the commands you've executed in your terminal. It can be especially useful when you're working with multiple terminal windows, as it allows you to easily switch between them and pick up where you left off. In this article, we'll show you how to preserve bash history in multiple terminal windows on Linux, and explain why it's so important. Why Preserve Bash History? Preserving bash history is important because it allows users to easily recall commands they have previously executed in the terminal. This can ...
Read More