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
Articles by Satish Kumar
Page 59 of 94
Specify an Editor for Crontab on Linux
The default editor for crontab on Linux is the vi editor. However, this can be changed by setting the VISUAL or EDITOR environment variable to the desired editor before running the crontab command. For example, to use nano as the editor for crontab, the command would be − export VISUAL=nano; crontab -e or export EDITOR=nano; crontab -e This will open the crontab file in nano for editing. Methods to Change Crontab Editor Temporary Change To temporarily change the editor for a single crontab session, set the environment variable inline ...
Read MoreHow to Find Broken Symlinks in Linux
Symbolic links (symlinks) are shortcuts in Linux that point to files or directories, allowing users to access them without specifying full paths. However, when the target file or directory is deleted or moved, the symlink becomes broken. This article explains how to identify and fix broken symlinks in Linux systems. What is a Broken Symlink? A broken symlink is a symbolic link that points to a non-existent file or directory. When you try to access it, the system returns a "file not found" error. Broken symlinks occur when: The target file or directory is deleted The ...
Read MoreBash Continue How to Resume a Loop
Bash is a popular command-line interface shell used extensively in Linux and Unix operating systems. One of its most useful features is the ability to execute loops, which automate repetitive tasks. Sometimes you may need to skip certain iterations within a loop or control its flow. This is where the Bash continue statement becomes essential. What is a Bash Loop? A loop is a programming construct that executes a block of code repeatedly. Bash supports several types of loops including for loops (which iterate over a set of values) and while loops (which execute as long as a ...
Read MoreStoring a Command in a Variable in a Shell Script
In shell scripting, you can store a command in a variable to improve code organization and reusability. This technique allows you to define commands once and execute them multiple times throughout your script. Basic Command Storage The basic syntax for storing a command in a variable is − variable_name="command" For example − current_date="date" list_files="ls -la" To execute the stored command, you need to use command substitution or eval − # Using eval (less secure) eval $current_date # Using command substitution (preferred) $($current_date) Storing Commands in ...
Read MoreSplitting Files in Unix Systems
Unix systems are widely recognized for their efficiency and versatility in handling file operations. One of the most common operations is splitting large files into smaller, more manageable chunks. The split command in Unix is specifically designed to achieve this task, allowing users to divide files based on size, line count, or specific delimiters. Split Command Syntax The basic syntax of the split command is as follows: split [OPTION]... [INPUT [PREFIX]] Where [INPUT] specifies the file to be split, [PREFIX] defines the naming pattern for output files (default is 'x'), and [OPTION] provides various ...
Read MoreRun a Script on Startup in Linux
There are several ways to run a script on startup in Linux, depending on your specific distribution and the type of script you are trying to run. Each method has its own advantages and is suitable for different use cases. Methods Overview Method Best For Linux Systems User Level systemd System services, daemons Modern distributions System-wide cron (@reboot) Simple scripts, scheduled tasks All distributions User or system rc.local Quick system scripts Traditional systems System-wide init.d Legacy system services Older distributions System-wide .bashrc/.bash_profile User-specific ...
Read MoreCommon Linux Text Search
Linux provides powerful command-line tools for searching text within files and directories. Text search is an essential skill for system administrators, developers, and users who need to locate specific content across their filesystem. This article explores the most commonly used Linux text search tools and their practical applications. grep − Pattern Matching The grep command is the most fundamental text search tool in Linux. It searches for patterns within files and displays matching lines. Basic Syntax grep [options] pattern [file...] Common Examples Search for "error" in a log file: grep ...
Read MoreBash declare Statement Syntax and Examples
The declare statement is a built-in Bash command that allows you to set attributes for variables and control their behavior. When you declare a variable using declare, you can specify how Bash should treat that variable − whether it's an array, integer, read-only, or has other special properties. Syntax of Declare Statement The basic syntax of the declare statement is straightforward − declare [options] variable=value Where declare is the keyword, [options] are flags that set specific attributes, and variable=value assigns a value to the variable. Common Declare Options Option ...
Read MoreLinux Commands Comparison curl vs wget
Curl and wget are two essential command-line utilities in Linux for downloading files from the internet. While both serve similar purposes, they have distinct features, capabilities, and use cases. Understanding their differences helps you choose the right tool for your specific needs. Overview of curl and wget Both curl and wget are command-line tools designed to retrieve data from the internet, but they differ in their approach and capabilities. Curl is a versatile data transfer tool that supports numerous protocols including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, and many others. It's designed to handle various data formats ...
Read MoreRunning Script or Command as Another User in Linux
There are several ways to run a script or command as another user in Linux. The most common methods are using the su command (switch user), the sudo command (superuser do), and the runuser command. Each approach has different use cases, security implications, and requirements. These commands are essential for system administration tasks where you need to execute operations with different user privileges without logging out and back in as another user. Using su Command The su command allows you to switch to another user's account. The basic syntax is: su [options] [username] ...
Read More