Read News/Blog
Back to News/Blog List
Common Linux Commands
Here’s a list of Linux commands, with their options (if any) that you can run within the terminal for the most common tasks. Give them a try and make the best use of your Linux OS!
1. System Navigation & File Management
- pwd — Prints the current working directory path.
- ls — Lists files and directories in the current directory.
Options:- -l — Use long listing format (detailed view).
- -a — Show all files, including hidden ones (starting with .).
- -h — Display file sizes in human-readable format (e.g., KB, MB).
- -R — List contents of subdirectories recursively.
- --color=auto — Enable colored output to distinguish file types.
- cd — Changes the current directory.
Common usages:- cd .. — Move up one directory level.
- cd / — Move to the root directory.
- cd ~ — Move to the home directory.
- tree — Displays the directory structure in a tree-like format.
Options:- -L N — Limit display to N directory levels.
- -a — Include hidden files.
- find — Searches for files and directories in a hierarchy.
Options:- -name pattern — Search by file name.
- -type f — Search only for files.
- -type d — Search only for directories.
- -size +100M — Find files larger than 100 MB.
- -mtime N — Find files modified N days ago.
- -exec command {} \; — Execute a command on each found item.
- locate — Quickly searches for files by name using a prebuilt database.
- file — Determines the type of a given file.
- stat — Displays detailed file or directory information (size, permissions, timestamps).
- touch — Creates an empty file or updates its access and modification timestamps.
- cp — Copies files or directories.
Options:- -r — Copy directories recursively.
- -v — Show progress for each copied file.
- -u — Copy only when the source file is newer.
- -i — Prompt before overwriting existing files.
- mv — Moves or renames files and directories.
Options:- -i — Prompt before overwrite.
- -v — Show progress.
- rm — Removes files or directories.
Options:- -r — Delete directories recursively.
- -f — Force delete without prompting.
- -i — Ask for confirmation before each removal.
- mkdir — Creates directories.
Options:- -p — Create parent directories if needed.
- -v — Show directories as they’re created.
- rmdir — Removes empty directories.
- cat — Displays file contents, concatenates, or creates files.
Options:- -n — Number all output lines.
- less — Views file contents one screen at a time (scrollable).
- head — Displays the first lines of a file.
Options:- -n N — Show the first N lines.
- tail — Displays the last lines of a file.
Options:- -n N — Show the last N lines.
- -f — Follow a file as it grows (e.g., log files).
2. File Permissions & Ownership
- chmod — Changes file or directory permissions.
Common usages:- chmod 755 file — Owner: read/write/execute; others: read/execute.
- chmod +x file — Add execute permission.
- chmod -R directory — Apply permissions recursively.
- chown — Changes ownership of a file or directory.
- chgrp — Changes the group ownership of a file or directory.
- umask — Sets default permissions for new files and directories.
3. Compression & Archiving
- tar — Archives multiple files into one.
Options:- -c — Create a new archive.
- -x — Extract from an archive.
- -v — Verbose output (list processed files).
- -f — Specify archive file name.
- -z — Compress with gzip.
- -j — Compress with bzip2.
- -t — List archive contents.
- gzip — Compresses files.
Options:- -r — Compress files recursively.
- -v — Show compression details.
- gunzip — Decompresses .gz files.
- zip — Creates zip archives.
Options:- -r — Recursively include directories.
- -v — Verbose output.
- unzip — Extracts zip archives.
Options:- -l — List archive contents.
- -v — Verbose mode.
4. System Information
- uname — Displays system and kernel information.
Options:- -a — Show all system information.
- -r — Show kernel release.
- -n — Show network hostname.
- hostname — Shows or sets the system’s hostname.
Options:- -I — Display system’s IP addresses.
- uptime — Displays system uptime and load average.
- date — Displays or sets the system date and time.
Options:- +%Y-%m-%d — Show date in year-month-day format.
- cal — Displays a calendar for the current month or year.
- free — Displays memory usage.
Options:- -h — Human-readable units (e.g., MB, GB).
- top — Displays dynamic, real-time view of running processes.
- lscpu — Shows information about CPU architecture.
- lsblk — Lists block devices (drives and partitions).
- dmesg — Displays kernel messages, including boot and hardware logs.
5. Process Management
- ps — Displays running processes.
Options:- aux — Show all processes in detail.
- -ef — Full-format listing with parent-child relationships.
- kill — Terminates a process by PID.
Options:- -9 — Force kill immediately.
- -15 — Graceful termination (default).
- pkill — Kills processes by name.
- nice — Starts a process with a specified priority.
- renice — Changes the priority of a running process.
- jobs — Lists current background jobs.
- bg — Resumes a job in the background.
- fg — Brings a background job to the foreground.
6. Networking
- ping — Tests connectivity to a host.
Options:- -c N — Send N packets.
- -i N — Wait N seconds between packets.
- ip — Displays or configures network interfaces.
Examples:- ip addr — Show IP addresses.
- ip route — Show routing table.
- netstat — Displays network connections and routing tables.
Options:- -t — TCP connections.
- -u — UDP connections.
- -l — Listening sockets.
- -n — Show numeric addresses.
- -p — Show process IDs and names.
- ss — A faster alternative to netstat.
Options:- -tuln — Show listening TCP and UDP ports.
- curl — Transfers data from or to a URL.
Options:- -I — Fetch only HTTP headers.
- -O — Save file with its original name.
- -L — Follow redirects.
- wget — Downloads files via HTTP/HTTPS/FTP.
Options:- -c — Continue interrupted downloads.
- -b — Run in background.
- -r — Recursive download.
- scp — Securely copies files between hosts.
Options:- -r — Copy directories recursively.
- -P — Specify remote port number.
- ssh — Connects securely to a remote host.
Options:- -p — Specify port.
- -i — Use an identity (private key) file.
7. User & Group Management
- whoami — Displays the current username.
- id — Displays user and group IDs.
- adduser — Creates a new user account.
- passwd — Changes a user password.
- usermod — Modifies an existing user account.
Options:- -aG group — Add user to a group.
- -s shell — Change user shell.
- -d dir — Change home directory.
- sudo — Runs commands as the root user or another user.
8. Text Processing
- grep — Searches for text patterns in files.
Options:- -i — Case-insensitive search.
- -r — Recursive search.
- -n — Show line numbers.
- --color — Highlight matches.
- awk — Scans and processes text using patterns and actions.
- sed — Stream editor for modifying text.
Options:- -i — Edit files in place.
- s/pattern/replacement/ — Substitute text.
- sort — Sorts lines of text files.
Options:- -r — Reverse order.
- -n — Numeric sort.
- -u — Remove duplicates.
- uniq — Filters or counts duplicate lines.
Options:- -c — Prefix lines with counts.
- -d — Show only duplicates.
- wc — Counts words, lines, or characters.
Options:- -l — Count lines.
- -w — Count words.
- -c — Count bytes.
9. System Administration
- systemctl — Controls and manages systemd services.
Options:- start service — Start a service.
- stop service — Stop a service.
- status service — View status.
- enable service — Auto-start at boot.
- disable service — Disable autostart.
- journalctl — Displays system logs.
Options:- -xe — Show recent errors and logs.
- -u service — Show logs for a specific service.
- shutdown — Shuts down or restarts the system.
Options:- -h now — Halt immediately.
- -r now — Reboot immediately.
- reboot — Reboots the system immediately.
- history — Displays command history.
Options:- !N — Re-execute command number N.
- grep text — Filter history results.
10. Disk & Storage Management
- fdisk — Command-line utility to manage disk partitions.
Options:- -l — List all available disks and their partition tables.
- fdisk /dev/sdX — Open a specific disk for partitioning (replace sdX with actual disk ID).
- lsblk — Lists all block devices (disks, partitions, USBs) in a tree format.
Options:- -f — Show filesystem type and UUID.
- -o — Customize displayed columns (e.g., lsblk -o NAME,SIZE,MOUNTPOINT).
- blkid — Displays attributes (UUID, filesystem type) of block devices.
- mount — Mounts a filesystem or device to a directory.
Examples / options:- mount /dev/sdX1 /mnt — Mounts a partition to /mnt.
- -t type — Specify filesystem type (e.g., ext4, ntfs).
- -o option — Use mount options (e.g., ro, rw, noexec).
- umount — Unmounts a mounted filesystem or device.
Examples / options:- umount /mnt — Unmounts /mnt.
- umount /dev/sdX1 — Unmounts the device directly.
- -f — Force unmount (use cautiously).
- df — Displays disk space usage for mounted filesystems.
Options:- -h — Human-readable sizes (KB, MB, GB).
- -T — Show filesystem type.
- -a — Include pseudo and temporary filesystems.
- du — Displays disk usage of files and directories.
Options:- -h — Human-readable sizes.
- -s — Show only total size per directory.
- --max-depth=N — Limit recursion to N levels.
- mkfs — Creates a new filesystem on a partition.
Examples / options:- mkfs.ext4 /dev/sdX1 — Create an EXT4 filesystem on partition sdX1.
- -t type — Specify filesystem type.
- -L label — Set a volume label.
- fsck — Checks and repairs filesystem errors.
Examples / options:- fsck /dev/sdX1 — Check and repair a partition.
- -y — Automatically fix detected errors.
- -n — Perform a dry run (no changes made).
- dd — Low-level utility for copying and converting raw data (e.g., cloning disks).
Options:- if=file — Specify input file (or device).
- of=file — Specify output file (or device).
- bs=size — Set block size (e.g., bs=4M).
- status=progress — Show copy progress.
- parted — Disk partition manipulation tool (similar to fdisk, supports GPT).
Options:- -l — List partitions.
- mklabel gpt — Create a new GPT partition table.
- mkpart — Create a new partition.
11. Package Management
🟩 Debian / Ubuntu (apt & dpkg)
- apt update — Updates the package list from repositories.
- apt upgrade — Upgrades all upgradable packages to newer versions.
- apt install package — Installs a package from repositories.
Options:- -y — Automatically answer “yes” to prompts.
- --reinstall — Reinstall an existing package.
- apt remove package — Removes a package but keeps configuration files.
Options:- -y — Auto confirm removal.
- apt purge package — Removes a package and its configuration files.
- apt autoremove — Removes automatically installed dependencies no longer needed.
- apt search keyword — Searches for a package by keyword.
- apt show package — Displays detailed information about a package.
- dpkg -l — Lists installed packages.
- dpkg -i package.deb — Installs a .deb package manually.
- dpkg -r package — Removes a manually installed package.
🟥 RHEL / CentOS / Fedora (yum & dnf)
- yum install package — Installs a package.
- yum remove package — Removes a package.
- yum update — Updates all packages to the latest version.
- yum list installed — Lists all installed packages.
- yum search keyword — Searches for a package by name or keyword.
- dnf — Modern replacement for yum with same syntax and improved performance.
🟦 Arch Linux (pacman)
- pacman -S package — Installs a package.
- pacman -R package — Removes a package.
- pacman -Syu — Updates package database and all installed packages.
- pacman -Qs keyword — Searches for packages by keyword.
- pacman -Qi package — Shows detailed information about a package.
12. Scripting & Automation
- bash — Runs Bash shell or executes a shell script file.
Example:- bash script.sh — Executes script.sh.
- sh — Executes shell scripts (POSIX compliant, simpler than Bash).
- echo — Prints text or variables to the terminal.
Options:- -n — Do not print a newline.
- -e — Enable interpretation of backslash escapes (e.g., \n, \t).
- Example: echo -e "Line 1\nLine 2" — Prints two lines.
- read — Reads user input into a variable in scripts.
- Example: read name — Waits for input and stores it in name.
- export — Sets or exports environment variables.
- Example: export PATH=$PATH:/usr/local/bin — Adds a directory to PATH.
- alias — Creates shortcuts for commands.
- Example: alias ll='ls -lah' — Defines ll as a shortcut for listing files in long format.
- cron — Time-based job scheduler for repetitive tasks.
- crontab — Installs, edits, or lists scheduled jobs for the current user.
Options:- -e — Edit the current user’s cron jobs.
- -l — List all cron jobs.
- -r — Remove all cron jobs.
- Example: crontab -e then add: 0 2 * * * /path/to/script.sh — Run script daily at 2 AM.
- at — Schedules a one-time command execution at a specific time.
- Example: at 10:30 → then type your command → Ctrl+D to save.
- which — Shows the full path of a command or executable.
- type — Displays how a command name is interpreted (alias, builtin, or external).
- sleep — Delays execution for a given number of seconds.
- Example: sleep 5 — Wait for 5 seconds.
- seq — Prints a sequence of numbers.
- Example: seq 1 5 → prints 1 2 3 4 5.
- printf — Prints formatted text (more powerful than echo).
- Example: printf "Name: %s\nAge: %d\n" "Alice" 18
- exit — Exits the current shell or script with a return code.
Example:- exit 0 — Exit successfully.
- exit 1 — Exit with an error.
- trap — Catches and handles signals in scripts.
- Example: trap "echo Interrupted!" SIGINT — Print message when user presses Ctrl+C.
- source — Executes commands from a file in the current shell environment.
- Example: source ~/.bashrc — Reloads shell configuration.
Go open source!

AuthorNaim Zulkipli
Date17 October 2025