chattr — Change Linux File Attributes
Practical chattr examples for setting and removing Linux file attributes such as immutable files.
Linux command-line notes and practical examples for everyday administration, troubleshooting, and shell work.
Practical chattr examples for setting and removing Linux file attributes such as immutable files.
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 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
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 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.
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
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
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 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 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