Found 1436 Articles for Linux

Run a Script on Startup in Linux

Satish Kumar
Updated on 31-Oct-2023 20:53:41

57K+ Views

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. Using systemd − On systems that use systemd, you can create a systemd service file for your script and configure it to run on startup. Using cron − You can use the cron daemon to schedule your script to run at startup. You can add a line to the cron table (crontab) to run your script at a specific time on startup. Using init.d − On systems that use the older init.d ... Read More

Storing a Command in a Variable in a Shell Script

Satish Kumar
Updated on 24-Jan-2023 19:36:54

510 Views

In a shell script, you can store a command in a variable by using the syntax − variable_name="command" For example − current_date="date" You can then execute the command stored in the variable by prefixing it with $ − $current_date This will execute the command date. Storing the Command in an Array In a shell script, you can store a command in an array by using the syntax minus; array_name=( "command1" "command2" "command3" ) For example − commands=( "ls -l" "pwd" "date" ) You can then execute the commands stored in the array by using a ... Read More

Specify an Editor for Crontab on Linux

Satish Kumar
Updated on 24-Jan-2023 19:35:31

1K+ Views

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. Editor in Linux An editor in Linux is a program that allows users to create, view, and modify text files. There are many different text editors available for Linux, each with ... Read More

Monitoring Network Usage in Linux

Satish Kumar
Updated on 24-Jan-2023 19:33:59

13K+ Views

Linux monitoring refers to the process of tracking and analyzing various aspects of a Linux system's performance, such as CPU usage, memory usage, disk usage, network traffic, and system uptime. The goal of Linux monitoring is to detect and diagnose any issues that may be impacting the performance or stability of the system, and to identify and correct problems before they become critical. Network Monitoring Tools Some common network monitoring tools for Linux include − nload − is a command-line tool for monitoring network traffic on a Linux system. Speedometer − is a simple tool but with a different ... Read More

Delete the History of the Last n Commands on Linux

Satish Kumar
Updated on 24-Jan-2023 19:32:40

7K+ Views

In Linux, the command history is a record of previously executed commands. The command history is stored in a file called . bash_history, which is located in the home directory of each user. The history command can be used to view the command history, and the history command can also be used with other commands, such as grep, to search for specific commands in the history. The commands in the history are assigned a number, which can be used to quickly execute a previous command by prefixing it with an exclamation mark (!). For example, typing "!123" will execute the ... Read More

Run a Java Application as a Service on Linux

Satish Kumar
Updated on 24-Jan-2023 19:29:20

5K+ Views

A simple service in Linux is a program that runs in the background and performs a specific function or set of functions. These programs can be started automatically at boot time, and can be controlled using the command line or through a system service manager such as systemd or Upstart. To create a simple service in Linux, you would first write the program that performs the desired function. This program should be designed to run in the background and to continue running even after the terminal window or SSH session is closed. Next, you would create a script that can ... Read More

Showing a GUI Notification From a Shell Script in Linux

Satish Kumar
Updated on 24-Jan-2023 19:28:07

806 Views

There are several ways to display a GUI notification from a shell script in Linux, but one common method is to use the notify-send command. This command is part of the libnotify library and is typically pre-installed on most Linux distributions. An example of how to use notify-send to display a notification with a title of "Hello" and a message of "World" is − notify-send "Hello" "World" You can use the command in your shell script by simply adding the command to it, or assign the notification text to a variable and use it message="This is your reminder" ... Read More

How to Calculate Optimal Blocksize to Use With dd in Linux

Satish Kumar
Updated on 24-Jan-2023 19:26:05

3K+ Views

The optimal block size to use with the dd command in Linux depends on the specific use case and the hardware that you are working with. However, as a general rule of thumb, it is best to use a block size that is a multiple of the disk's physical block size, as this can lead to better performance. To determine the physical block size of a disk, you can use the fdisk command with the -l option. This will list all the partitions on the disk, along with the start and end cylinders, and the block size. For example, to ... Read More

How to Check Logs Using journalctl in Linux

Satish Kumar
Updated on 24-Jan-2023 19:24:40

2K+ Views

Logs are a crucial component of any Linux system, as they provide a record of system activity, including system events, user actions, and system processes. Log checking, or log monitoring, is the process of regularly reviewing log files to identify any unusual or suspicious activity, such as failed login attempts, system crashes, or security breaches. Log checking is important for maintaining the security and stability of a Linux system, as it allows administrators to quickly identify and troubleshoot problems, and detect and respond to potential security threats. Basic journalctl Commands journalctl is a command line utility for viewing and managing ... Read More

Exclude grep From ps Results on Linux

Satish Kumar
Updated on 24-Jan-2023 19:23:03

2K+ Views

The ps command in Linux is used to display information about the running processes on a system. It provides a snapshot of the current processes, including the process ID (PID), the user that owns the process, the percentage of CPU and memory usage, and the command that started the process. By default, ps only shows information about processes that are running in the same terminal session as the ps command. However, using various options and command line arguments, you can customize the output to show information about all processes running on the system, or even remotely. Listing All Processes To ... Read More

Advertisements