Parsing Command-Line Arguments in Bash

Bash scripts often need to read command-line arguments. For simple scripts, you can use positional parameters such as $1, $2 and $@. Simple positional arguments Loop through all arguments Basic option handling getopts is useful for small scripts that need flags such as -v or options with values such as -f file.txt.

aspell — Spell Check Text from the Command Line

aspell is a command-line spell checker. It is useful when editing plain text files, notes, documentation or scripts where you want a quick spelling pass without opening a full word processor. Check a text file This opens an interactive spelling session for the file. List possible misspellings This prints words that aspell thinks may be … Read more

Linux Redirection Operators: >, >> and |

Shell redirection operators control where command input and output go. They are useful for saving command output, appending logs, and passing one command’s output into another command. Write output to a file > writes output to a file. It replaces the existing file contents. Append output to a file >> appends output to the end … Read more

mpstat — Check CPU Usage by Processor

mpstat reports CPU usage statistics. It is useful when you want to see whether load is spread across processors or concentrated on one CPU. Show CPU statistics Refresh every few seconds Show each processor separately On many systems, mpstat is provided by the sysstat package.

script — Record a Terminal Session

The script command records everything shown in a terminal session. It is useful when you want to capture troubleshooting steps, command output, or a repeatable install log. Start recording Run your commands as usual. When finished, exit the recording session. View the log Avoid recording passwords, tokens or private data. The output is saved as … Read more

halt — Stop or Power Off a Linux System

The halt command is used to stop a Linux system. On modern Linux systems, systemctl poweroff or shutdown is usually preferred because it is clearer and works through systemd. Check the command first Modern equivalent Only run shutdown or power-off commands on a machine you are allowed to stop. Be especially careful on remote servers, … Read more

host — DNS Lookup Utility

The host command is a simple DNS lookup tool. It is useful for checking whether a hostname resolves, which IP address it points to, or which mail servers are configured for a domain. Basic lookup Check mail servers Check name servers For deeper DNS troubleshooting, compare the result with dig and check whether the issue … Read more

hdparm — View Disk Parameters in Linux

hdparm can display disk parameters and run simple read-performance checks. Some write options can be risky, so use read-only commands unless you are sure of the device and impact. Show disk information Run a basic read test Replace /dev/sda with the correct device name for your system. Check devices first with lsblk.

lsof — List Open Files

lsof lists open files on a Linux or Unix system. It is useful because sockets, devices, directories and regular files can all appear as open files. Find which process is using a port List open files for a process List files opened by a user This command is helpful when troubleshooting ports, locked files, deleted … Read more