Top Linux Commands: Basic, Useful, and Common Commands Explained

Essential Linux Commands: A Comprehensive Guide for Beginners

Linux commands are the best ways to navigate on a Linux system. Linux experts usually control Linux clients and servers using commands instead of a graphical user interface for faster usage and automation purposes. Not to mention, commands free you from mouse usage and make you more productive.

Let me introduce you to the basic Linux commands to advanced ones and everything in between so you can also aspire to master Linux systems.

Introduction to Linux Commands

Command line interface is the preferred mode for all kinds of interactions with Linux systems, like client-side devices, locally hosted Linux servers, or Linux Virtual Dedicated Servers

As a beginner, you can start with the basic ones, like ls and cd. However, as you gain experience navigating a Linux server using commands, you’ll leverage powerful tools like awk, and sed, as well as shell scripting for automation.

The Basic Linux Command Structure

A Linux command has the following parts and appears as a structured syntax.

command [options] [arguments]

  • Command: This is the main instruction (e.g., ls to list files).
  • Options (Flags): They modify the behavior of the command (e.g., ls -l shows detailed file information).
  • Arguments: These specify targets for the command (e.g., ls /home lists files in the /home directory).

Essential Requirements

You must have access to the command-line interface of the Linux virtual private server (VPS) or the client desktop. Whether you’re using a Ubuntu user account with root access or not also matters. Most basic commands (e.g., ls, cd, mkdir, touch, find, etc.) do not require root access. Only system-level commands (e.g., apt install, systemctl restart) need sudo/root. If you’re not sure, you can learn to create a user in Linux with sufficient access to use all the commands explained in this guide.

Now that you’re all set to begin, let me introduce you to these popular and essential 21 Linux terminal commands to administer Linux clients and servers.

Basic Linux Commands for Beginners

1. ls lists files and directories in the current directory.

Syntax

ls [OPTION] [FILE]

Explanation of Syntax

ls → The command itself.

[OPTION] → Optional flags to modify the output (e.g., -l for detailed list, -a for hidden files).

[FILE] → Optional file or directory names to list specific items. If omitted, it lists the current directory.

Example Usage

ls -l /home/user/Documents

2. pwd displays the current working directory.

Syntax

pwd

Example Usage

Shows the full path of the current working directory.

pwd

3. cd changes the current directory.

Syntax

cd [DIRECTORY]

Explanation of Syntax

cd → The command itself; is used to navigate directories.

[DIRECTORY] → The target directory to move into. If omitted, it defaults to the home directory.

Example Usage

Changes the current directory to /home/user/Documents.

4. mkdir creates a new directory.

Syntax

mkdir [OPTION] DIRECTORY

Explanation of Syntax

mkdir → The command itself; is used to create directories.

[OPTION] → Optional flags (e.g., -p to create parent directories if they don’t exist).

DIRECTORY → The name(s) of the directory to create.

Example Usage

Creates a directory named NewFolder inside /home/user/Documents.

mkdir /home/user/Documents/NewFolder

5. rm removes files or directories.

Syntax

rm [OPTION] FILE

Explanation of Syntax

rm → This is the command used to delete files or directories.

[OPTION] → Optional flags (e.g., -r for recursive deletion, -f for force deletion).

FILE → The file(s) or directory(ies) to remove.

Example Usage

Deletes a file named sample.txt inside /home/user/Documents.

rm /home/user/Documents/sample.txt

Commonly Used Linux Terminal Commands

6. cp copies files and directories.

Syntax

cp [OPTION] SOURCE DESTINATION

Explanation of Syntax

cp → This part is the actual command which copies files or directories.

[OPTION] → Optional flags (e.g., -r to copy directories recursively, -i for interactive mode).

SOURCE → The file(s) or directory(ies) to copy.

DESTINATION → The target location where the copied file(s) or directory(ies) will be placed.

Example Usage

Copies file.txt from /home/user/Documents to /home/user/Backup.

cp /home/user/Documents/file.txt /home/user/Backup

7. mv moves or renames files and directories.

Syntax

mv [OPTION] SOURCE DESTINATION

Explanation of Syntax

mv → The command itself; is used to move or rename files and directories.

[OPTION] → Optional flags (e.g., -i for interactive mode, -v for verbose output).

SOURCE → The file(s) or directory(ies) to move or rename.

DESTINATION → The target location or new name for the file(s) or directory(ies).

Example Usage

Renames oldname.txt to newname.txt in /home/user/Documents.

mv /home/user/Documents/oldname.txt /home/user/Documents/newname.txt

8. cat displays the contents of a file.

Syntax

cat [OPTION] [FILE]

Explanation of Syntax

cat → This is the command itself. It’s used to read and display file contents.

[OPTION] → Optional flags (e.g., -n to show line numbers, -E to show line endings).

[FILE] → The file(s) whose contents will be displayed.

Example Usage

Displays the contents of notes.txt in /home/user/Documents.

cat /home/user/Documents/notes.txt

Working With Files and Directories in Linux

9. touch creates an empty file or updates the timestamp of an existing file.

Syntax

touch [OPTION] FILE

Explanation of Syntax

touch → The command itself; is used to create new empty files or update the timestamp of existing files.

[OPTION] → Optional flags (e.g., -c to avoid creating a file if it doesn’t exist, -t to specify a timestamp).

FILE → The file(s) to create or update.

Example Usage

Creates a new empty file named newfile.txt inside /home/user/Documents.

touch /home/user/Documents/newfile.txt

10. find it searches for files and directories based on name, type, size, or other attributes.

Syntax

find [DIRECTORY] [OPTION] [EXPRESSION]

Explanation of Syntax

find → The command itself; used to search for files and directories.

[DIRECTORY] → The starting directory for the search (default is the current directory).

[OPTION] → Optional flags (e.g., -name to search by filename, -type to filter by file type).

[EXPRESSION] → The search criteria (e.g., the file name or size).

Example Usage

Searches for a file named example.txt inside /home/user/Documents.

find /home/user/Documents -name “example.txt”

11. du displays the disk usage of files and directories.

Syntax

du [OPTION]  [FILE]

Explanation of Syntax

du → The command itself; is used to check disk usage.

[OPTION] → Optional flags (e.g., -h for the human-readable format, -s for a summary of total size).

[FILE] → The file(s) or directory(ies) to analyze.

Example Usage

Shows the disk usage of the /home/user/Documents directory in a human-readable format.

du -h /home/user/Documents

Linux Commands for Networking

12. ping sends ICMP echo requests to a host to check network connectivity.

Syntax

ping [OPTION] DESTINATION

Explanation of Syntax

ping → The command itself; used to test network connectivity to a host.

[OPTION] → Optional flags (e.g., -c to specify the number of packets, -i to set the interval between requests).

DESTINATION → The target hostname or IP address to check connectivity.

Example Usage

Sends 4 ping requests to google.com to test connectivity.

ping -c 4 google.com

13. netstat displays network connections, routing tables, and interface statistics.

Syntax

netstat [OPTION]

Explanation of Syntax

netstat → The command itself; used to monitor network connections and statistics.

[OPTION] → Optional flags (e.g., -t to show TCP connections, -u to show UDP connections, -a to show all connections).

Example Usage

Displays all active TCP connections

netstat -t

14. curl transfers data from or to a server using various protocols (HTTP, FTP, etc.).

Syntax

curl [OPTION] URL

Explanation of Syntax

curl → The command itself; used to retrieve or send data over a network.

[OPTION] → Optional flags (e.g., -o to save output to a file, -I to fetch only the headers).

URL → The web address of the resource to be accessed.

Example Usage

Fetches the HTML content of example.com and displays it in the terminal.

curl https://example.com

Linux Commands for System Information

15. uname displays systems information such as kernel name, version, and architecture.

Syntax

uname [OPTION]

Explanation of Syntax

uname → The command itself; used to print system details.

[OPTION] → Optional flags (e.g., -a for all details, -r for kernel version, -m for machine hardware name).

Example Usage

Displays the system’s kernel version.

uname -r

16. uptime shows how long the system has been running, along with the number of logged-in users and load average.

Syntax

uptime

Explanation of Syntax

uptime → The command itself; it provides system uptime and load statistics.

Example Usage

Displays how long the system has been running.

uptime

17. df displays disk space usage for file systems.

Syntax

df [OPTION] [FILE]

Explanation of Syntax

df → The command itself; is used to check available and used disk space.

[OPTION] → Optional flags (e.g., -h for human-readable output, -T to show file system type).

[FILE] → The specific file system or directory to check (optional).

Example Usage

Displays disk space usage in a human-readable format.

df -h

Advanced Linux Shell Commands

18. awk processes and analyzes text files, typically for pattern scanning and data extraction.

Syntax

awk [OPTION] ‘PROGRAM’ FILE

Explanation of Syntax

awk → The command itself; is used for text processing.

[OPTION] → Optional flags (e.g., -F to specify a field separator).

‘PROGRAM’ → The script or pattern to apply to each line of input.

FILE → The file(s) to process.

Example Usage

Extracts and prints the first column of data.txt, assuming columns are space-separated.

awk ‘{print $1}’ data.txt

19. sed edits text in a stream or file using search, replace, and pattern-matching techniques.

Syntax

sed [OPTION] ‘SCRIPT’ FILE

Explanation of Syntax

sed → The command itself; is used for stream editing.

[OPTION] → Optional flags (e.g., -i for in-place editing, -e to specify multiple scripts).

‘SCRIPT’ → The instructions for modifying the text (e.g., search and replace).

FILE → The file(s) to edit.

Example Usage

It replaces all occurrences of “apple” with “orange” in fruits.txt without modifying the original file.

sed ‘s/apple/orange/g’ fruits.txt

Cool and Useful Linux Commands to Know

Syntax

20. htop displays an interactive and real-time view of system processes and resource usage.

htop [OPTION]

Explanation of Syntax

htop → The command itself; is used to monitor system performance interactively.

[OPTION] → Optional flags (e.g., -u to filter processes by the user, -p to show specific process IDs).

Example Usage

Launches htop to view system processes interactively.

htop

21. ncdu analyzes and displays disk usage in a user-friendly, interactive interface.

Syntax

ncdu [OPTION] [DIRECTORY]

Explanation of Syntax

ncdu → The command itself; provides a visual breakdown of disk usage.

[OPTION] → Optional flags (e.g., -x to stay within one file system, -r for read-only mode).

[DIRECTORY] → The directory to analyze (default is the current directory).

Example Usage

Analyzes disk usage of the /home directory interactively.

ncdu /home

Expert Command Patterns: Combining Tools Like a Pro

Linux commands become exponentially more powerful when composed, not just executed individually. For example:

  • grep -R "TODO" /etc
    Searches recursively through /etc for lines containing “TODO” — essential for auditing configs.
  • find /var/log -type f -mtime -7 -exec gzip {} \;
    Finds logs modified in the last 7 days and compresses them — useful in log rotation scripts.
  • ps aux | grep httpd | awk '{print $2}' | xargs kill -9
    Extracts process IDs of a service and kills them — a composition of ps, grep, awk, and xargs.

This pattern – combine lightweight tools instead of installing heavy utilities , reflects the Unix philosophy and is fundamental for real production scripting and automation.

Understanding Exit Codes and Scripting Reliability

Every Linux command returns an exit code: 0 for success, anything else for failure. In scripts, checking $? (the exit status) is crucial:

mkdir /secure/backup
if [[ $? -ne 0 ]]; then
  echo "Backup folder creation failed" >&2
  exit 1
fi

Understanding exit codes prevents silent failures in automation and alerts you immediately when expected conditions aren’t met, a core practice in professional shell scripting and automation workflows.

Real-World Scenarios: Monitoring and Health Checks

For real servers, particularly VPS or cloud instances, these commands become part of health check workflows:

  • top and htop — real-time CPU/memory usage (interactive)
  • vmstat 5 — outputs system stats every 5 seconds
  • iostat -xz 2 — extended I/O stats for storage performance (needs sysstat package)

Example automation snippet to log CPU spikes:

while sleep 60; do
  date >> /var/log/cpu_usage.log
  top -bn1 | head -n5 >> /var/log/cpu_usage.log
done

These patterns are used widely in server monitoring and incident response.

Security-Oriented Commands Every Admin Must Memorize

Beyond basic navigation, advanced users should know these with exact options:

  • chmod u=rwx,g=rx,o=rx file — sets secure permissions explicitly
  • chattr +i important.conf — sets immutable bit, preventing accidental writes
  • sudo journalctl -u sshd — inspects SSH daemon logs for authentication analysis
  • ss -tulwn — shows listening TCP/UDP ports without name resolution — essential for firewall debugging

Security commands like chattr or ss are not often in beginners’ lists but are fundamental in secure server admin practices.

Filesystem and Storage Commands: Beyond the Basics

Experienced users depend on these:

  • lsblk -f — lists block devices with filesystem info
  • blkid — shows UUIDs and labels of devices
  • mount | column -t — clearer overview of mounted filesystems
  • df -hT — shows filesystem types along with space details

Understanding how to interpret storage information programmatically is necessary for automated deployments and troubleshooting disk issues.

Customizing Your Shell Environment for Productivity

One of the most powerful ways to work with Linux is not commands per se, but how you customize them:

  • Aliases
alias ll='ls -alF'
alias g='grep --color=auto'

Shell functions

mkcd () { mkdir -p "$1"; cd "$1"; }

History management

  • export HISTTIMEFORMAT="%F %T "

Pro users rely on shell customizations to speed up workflows and reduce errors, this is beyond knowing commands; it’s about shaping your environment.

Automating with Script Tips and Best Practices

Linux mastery often involves scripting:

  • Always start scripts with shebang:
#!/usr/bin/env bash

Use set -euo pipefail for safer scripts:

  • set -euo pipefail

These options:

  • -e: exit on error
  • -u: error on undefined variable
  • -o pipefail: catches errors in pipelines

Using these patterns prevents silent failures, a hallmark of reliable automation.

FAQs About Linux Commands

Find below common questions on basic Linux commands to advanced ones so you don’t need to invest more time in searching for answers instead, you can practice the commands listed above:

What are the basic Linux commands every beginner should know?

You must master the following Linux codes as a beginner user of Linux machines:

ls [options] [directory]

cd [directory]

cp [options] source destination

mv [options] source destination

rm [options] target

How do I use the terminal in Linux?

Find below the effortless steps to use the terminal in your Linux client, servers, VPS, etc.:

  1. You can open the terminal by pressing Ctrl + Alt + T or searching for “Terminal” in the applications menu.
  2. Check the current directory using pwd to see where you are in the file system.
  3. Navigate between folders by using cd [directory] to move to a different location.
  4. Use ls at the end of a command to list files and folders in the current directory.
  5. Run a command by typing it (e.g., mkdir newfolder) and pressing Enter.
  6. Close the terminal using exit or by pressing Ctrl + D.

What is the most common Linux command?

The most common Linux command in a hosting environment like a Linux VPS is ssh. It allows secure remote access to the server. Administrators use it to connect to a remote machine. Running ssh user@server-ip enables server management from anywhere.

How do I list all commands available in Linux?

You can list all available commands in Linux by using the compgen -c command. Here are the basic steps to try:

  1. Press Ctrl + Alt + T to open the Terminal app.
  2. Run the command using compgen -c and press Enter to execute it.
  3. Scroll through the output by using Shift + Page Up and Shift + Page Down.
  4. Filter specific commands with compgen -c | grep keyword by searching for a keyword.
  5. Save the list by running the command compgen -c > commands.txt to store it in a file.

What are the most useful Linux commands for system management?

Here are the top 3 most useful Linux system management commands:

1. Top: It helps monitor system performance by displaying real-time CPU, memory, and process usage.

2. Systemctl: This command manages system services by starting, stopping, restarting, and checking their status. 

Syntax: systemctl [command] [service]

Example: systemctl status apache2

3. df -h: It shows disk space usage by displaying available and used storage in a human-readable format.

Syntax: df -h [directory]

Example: df -h /

Are there any cool or advanced Linux commands worth learning?

You can try the fortune Linux command to do fun things when taking a break from your work. It displays a random quote, joke, or witty saying for fun and inspiration.

How can I create a custom command in Linux?

You can create a custom command using an alias for shortcuts. Alternatively, you can also use a shell script for more complex tasks. Aliases are temporary unless added to a configuration file. Contrarily, scripts can be made executable and placed in the system path. Here’s an example with steps:

  1. Define an alias by running alias customcmd=’actual_command options’ in the Terminal.
  2. Make the alias permanent by adding alias customcmd=’actual_command options’ to ~/.bashrc or ~/.bash_aliases.
  3. Create a shell script using nano myscript.sh and write the desired command inside.
  4. Add executable permission by running chmod +x myscript.sh to allow execution.
  5. Copy the script to /usr/local/bin/ using sudo mv myscript.sh /usr/local/bin/customcmd.
  6. Run the custom command by typing customcmd in the terminal.

What’s the difference between grep, awk, and sed?

  • grep: Fast pattern search in text.
  • awk: Field-aware text processing and reporting language.
  • sed: Stream editor for in-place text manipulation.
    Together they form a powerful toolkit for parsing and transforming text data on the fly.

How can I safely delete a directory with its contents?


Use rm -rf /path/to/dir, but only after verifying the path, because this command is irreversible. Combining it with --preserve-root prevents accidental full system deletion. How do I find commands I’ve used recently?
Use history | grep <term> for pattern search in your shell history. You can also press Ctrl+R in many shells to search interactively.

What’s the safest way to combine commands?


Use && to ensure only running the next command if the previous succeeds, e.g.,:

make && sudo make install

This prevents accidental execution when earlier steps fail.

References

  1. DigitalOcean – Comprehensive guide to essential Linux commands, including file, process, network, and system operations.
    https://www.digitalocean.com/community/tutorials/linux-commands
  2. It’s FOSS – List of 50 Linux commands with explanations for power users and administrators.
    https://itsfoss.gitlab.io/post/50-linux-commands-you-must-know/
  3. DreamHost – Beginner to advanced Linux command overview with examples and usage.
    https://www.dreamhost.com/blog/linux-commands/
  4. WebAsha – Top 100 Linux commands with examples, usage, and output for beginners and advanced users.
    https://www.webasha.com/blog/top-100-most-useful-linux-commands-with-examples-usage-and-output-for-beginners-and-advanced-users
  5. Vmhoster Blog – Powerful Linux commands with practical examples (grep, find, awk, sed, rsync, etc.).
    https://blog.vmhoster.com/powerful-linux-commands/
  6. Hostinger – Essential Linux commands to know with real usage examples.
    https://www.hostinger.com/tutorials/linux-commands
  7. LinuxConfig.org – Top 20 most important Linux commands (navigation, system management, etc.).
    https://linuxconfig.org/linux-commands-top-20-most-important-commands-you-need-to-know
  8. GoLinuxCloud – Linux commands cheat sheet with 100+ categorized commands for engineers.
    https://www.golinuxcloud.com/linux-commands-cheat-sheet/
  9. Zentyal – 100 Example Linux command cheat sheet with structured categories.
    https://www.zentyal.com/news/linux-commands/
  10. Dev.to – 100+ commands guide for beginners and professionals.
    https://dev.to/10000coders/100-linux-commands-a-complete-guide-for-beginners-and-professionals
About The Author
A man with short, light brown hair and a trimmed beard, wearing a beige sweater, looks directly at the camera against a dark background.
Liutauras is the Head of Customer Support Team with five years of experience in the fast-paced cloud hosting industry. With a strong passion for software engineering and cloud computing, he continuously strives to expand his technical expertise while prioritizing client satisfaction. Liutauras is committed to proactive support and providing valuable insights to help clients maximize their cloud environments.
Subscribe to our newsletter