Every Linux journey starts at the same place: a blinking cursor in a terminal window. Whether you're setting up your first Ubuntu virtual machine, managing a cloud server, or preparing for a cybersecurity career, the command line is where the real power lives. Graphical interfaces come and go, but these commands have remained stable for decades -- learn them once and they'll serve you on any distribution, any server, any environment.

This guide walks through 20 essential commands, organized by what you'll actually need to do: figure out where you are, move around, work with files, and understand your system. Each command includes practical examples you can run right now in your own terminal.

Before you can do anything useful in Linux, you need to know where you are and how to move around. The Linux filesystem is a tree structure with the root directory / at the top, and everything else branching out from there. Unlike Windows, there are no drive letters -- everything is a path.

1. pwd -- Print Working Directory

The pwd command answers the simplest and most important question: where am I right now? When you first open a terminal, you're typically dropped into your home directory, but it's easy to lose track of your location as you move around. Running pwd prints the full absolute path of your current directory.

terminal
$ pwd
/home/kandi

This might seem too simple to bother mentioning, but when you're deep inside nested directories or working across multiple terminal sessions, pwd is the command that keeps you grounded. Many experienced administrators still use it constantly.

2. ls -- List Directory Contents

Once you know where you are, you need to see what's around you. The ls command lists files and directories in your current location. On its own, ls gives you a basic list of names. But the real power comes from its flags.

terminal
# Basic listing
$ ls
Documents  Downloads  Music  Pictures  scripts

# Long format with hidden files
$ ls -la
total 36
drwxr-xr-x  6 kandi kandi 4096 Feb 26 10:15 .
drwxr-xr-x  3 root  root  4096 Feb 20 08:00 ..
-rw-------  1 kandi kandi  220 Feb 20 08:00 .bash_history
-rw-r--r--  1 kandi kandi  807 Feb 20 08:00 .bashrc
drwxr-xr-x  2 kandi kandi 4096 Feb 26 10:15 Documents
drwxr-xr-x  2 kandi kandi 4096 Feb 25 14:30 Downloads
drwxr-xr-x  2 kandi kandi 4096 Feb 22 09:12 scripts

The -l flag switches to the long format, which shows permissions, ownership, file size, and modification date. The -a flag includes hidden files -- those whose names start with a dot. You'll use ls -la so often it might become muscle memory.

3. cd -- Change Directory

The cd command moves you from one directory to another. You can use absolute paths that start from root, or relative paths that start from your current location. There are also several useful shortcuts worth memorizing.

terminal
# Move into a subdirectory
$ cd Documents

# Go up one level
$ cd ..

# Jump straight to your home directory
$ cd ~

# Return to the previous directory you were in
$ cd -

# Navigate using an absolute path
$ cd /var/log
Pro Tip

Use the Tab key to autocomplete directory and file names as you type. If you start typing cd Doc and press Tab, the shell will complete it to cd Documents/ for you. This saves typing and prevents typos -- especially with long or complex names.

Working with Files and Directories

Now that you can navigate, it's time to actually do things with files. These commands cover the core operations: creating, copying, moving, renaming, and deleting. They're the verbs of the Linux command line.

4. touch -- Create Empty Files

The touch command creates a new, empty file. Its original purpose is actually to update a file's timestamp, but creating blank files is its most common beginner use. It's handy for quickly creating placeholder files, empty config templates, or test files.

$ touch notes.txt

You can create multiple files at once by listing them separated by spaces: touch file1.txt file2.txt file3.txt.

5. mkdir -- Make Directories

The mkdir command creates new directories. Like touch, it's straightforward on its own, but the -p flag is what makes it truly useful. The -p flag creates the entire path of nested directories in a single command, and it won't throw an error if the directory already exists.

terminal
# Create a single directory
$ mkdir projects

# Create nested directories in one command
$ mkdir -p projects/webapp/src

6. cp -- Copy Files and Directories

The cp command copies files from one location to another. The basic syntax is cp source destination. To copy entire directories and their contents, you need the -r (recursive) flag.

terminal
# Copy a file
$ cp report.txt report-backup.txt

# Copy a directory and everything inside it
$ cp -r projects/ projects-backup/

# Copy and preserve all attributes (permissions, ownership, timestamps, symlinks)
$ cp -a /var/www/ /var/www-backup/

7. mv -- Move and Rename

The mv command serves double duty. It moves files from one location to another, and it also renames files. The logic is the same either way -- you're changing the path associated with a file. If the destination is in the same directory, it's a rename. If it's somewhere else, it's a move.

terminal
# Rename a file
$ mv old-name.txt new-name.txt

# Move a file into a directory
$ mv report.txt Documents/

# Move and rename simultaneously
$ mv ~/Downloads/data.csv ~/projects/dataset.csv

8. rm -- Remove Files and Directories

The rm command deletes files. Unlike graphical file managers, there is no trash can or undo. When you rm a file, it's gone. This is one of the first commands where you need to exercise real caution.

terminal
# Delete a single file
$ rm oldfile.txt

# Delete a directory and its contents
$ rm -r old-project/

# Interactive mode -- prompts before each deletion
$ rm -ri old-project/
Caution

Never run rm -rf / or rm -rf * without being absolutely certain of your current directory. The -r flag means recursive (delete everything inside), and -f means force (don't ask for confirmation). Combined carelessly, these flags can wipe out your entire system. Always double-check with pwd before running destructive commands.

Viewing and Searching File Content

Files are only useful if you can read what's inside them. Linux provides several tools for viewing content, each suited to different situations. Knowing which one to reach for saves time and avoids frustration -- especially when dealing with large files.

9. cat -- Display File Contents

The cat command (short for "concatenate") dumps the entire contents of a file to the terminal. It's perfect for small files like configuration snippets or short scripts. For anything longer than a screenful, you'll want to use a pager instead.

$ cat /etc/hostname

You can also use cat to combine multiple files: cat part1.txt part2.txt > combined.txt. This concatenation ability is where the command gets its name.

10. less -- Page Through Files

When a file is too large to read all at once, less lets you scroll through it page by page. You navigate with the arrow keys, Page Up and Page Down, or the spacebar. Press q to quit. You can also search within the file by pressing / followed by your search term, then use n to jump to the next match or N to go back to the previous match.

$ less /var/log/syslog

The less command is far more practical than cat for reading logs, documentation, or any file longer than a few dozen lines. There's also head and tail for viewing just the beginning or end of a file, respectively. The command tail -f is especially useful -- it continuously follows a file as new lines are appended, making it ideal for watching live log output.

11. grep -- Search Text with Patterns

The grep command searches for text patterns inside files. It's one of the commands that separates a casual Linux user from a productive one. You can search a single file, multiple files, or even pipe the output of other commands into grep to filter results.

terminal
# Search for a word in a file
$ grep "error" /var/log/syslog

# Case-insensitive search
$ grep -i "warning" logfile.txt

# Recursively search all files in a directory
$ grep -r "TODO" ~/projects/

# Show line numbers alongside matches
$ grep -n "def main" script.py
Note

grep supports regular expressions, which allow you to match complex patterns beyond simple text. For example, grep -E "^[0-9]{3}[^0-9]" data.txt finds lines that start with exactly three digits followed by a non-digit character. Regular expressions are a deep topic on their own, but even basic grep usage with plain text searches will cover many of your daily needs.

12. find -- Locate Files on the System

While grep searches inside files, find searches for the files themselves. You can search by name, type, size, modification date, permissions, and more. It's the go-to tool when you know a file exists somewhere but can't remember exactly where.

terminal
# Find a file by name
$ find /home -name "report.pdf"

# Find all Python files
$ find ~/projects -name "*.py"

# Find files modified in the last 24 hours
$ find /var/log -mtime -1

# Find and delete all .tmp files
$ find /tmp -name "*.tmp" -delete

Understanding Permissions and Ownership

Linux is a multi-user operating system, and permissions determine who can read, write, or execute any given file. Understanding this system is fundamental -- it's the foundation of Linux security, and it's something you'll encounter every single day.

13. chmod -- Change File Permissions

The chmod command modifies the access permissions on files and directories. Permissions are divided into three categories: the file owner, the group, and everyone else. Each category can have read (r), write (w), and execute (x) permissions. You can set permissions using either symbolic notation or numeric (octal) notation.

terminal
# Make a script executable
$ chmod +x deploy.sh

# Set specific permissions using octal notation
# 7=rwx, 5=r-x, 5=r-x (owner full, group/others read+execute)
$ chmod 755 deploy.sh

# Remove write permission for group and others
$ chmod go-w config.yml

14. chown -- Change File Ownership

The chown command changes who owns a file or directory. This is especially important when setting up services or web servers, where files need to be owned by a specific system user. You'll typically need sudo to change ownership since it's a privileged operation.

terminal
# Change owner of a file
$ sudo chown www-data index.html

# Change owner and group simultaneously
$ sudo chown www-data:www-data /var/www/html/

# Recursively change ownership of a directory
$ sudo chown -R appuser:appuser /opt/myapp/

System Information and Process Management

Beyond working with files, you need to understand what your system is doing. These commands let you check resource usage, manage running programs, and gather information about the machine itself.

15. sudo -- Execute as Superuser

The sudo command lets you run a single command with elevated (root) privileges. Instead of logging in as root -- which is risky because every command has unrestricted power -- you prefix specific commands with sudo when they require administrative access. The system will prompt for your password the first time, then cache it for 15 minutes by default, so you won't be prompted again during that window.

$ sudo apt update

Think of sudo as a safety mechanism. It forces you to consciously decide when you need elevated privileges, rather than accidentally running everything as root. On Ubuntu and similar distributions, the root account is locked by default and sudo is the intended way to perform administrative tasks.

16. ps -- View Running Processes

The ps command shows a snapshot of currently running processes. By default, it only shows processes in your current terminal session, but with the right flags it can show everything running on the system.

terminal
# Show all processes with full details
$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY  STAT START   TIME COMMAND
root         1  0.0  0.1 169344 13200 ?    Ss   Feb20   0:12 /sbin/init
kandi     1423  0.2  1.4 456780 58320 ?    Sl   10:15   0:04 /usr/bin/python3
www-data  1567  0.0  0.3 124560 12840 ?    S    10:15   0:01 nginx: worker

# Find a specific process
$ ps aux | grep nginx

Notice that last example uses the pipe operator | to send the output of ps into grep. Piping commands together is one of the fundamental concepts in Linux -- small tools that each do one thing well, chained together to accomplish complex tasks.

17. top -- Monitor System Activity in Real Time

While ps gives you a static snapshot, top provides a live, continuously updating view of system activity. It shows CPU usage, memory consumption, running processes, and system load -- all refreshing every few seconds. Press q to exit.

$ top

For a more user-friendly alternative, try htop if it's installed on your system. It provides the same information with color coding, mouse support, and easier process management. You can install it with sudo apt install htop on Debian-based systems.

18. kill -- Terminate Processes

When a process becomes unresponsive or you need to stop a running program, kill sends a signal to that process. You need the process ID (PID), which you can find using ps or top. The default signal is SIGTERM (signal 15), which asks the process to shut down gracefully. If that doesn't work, SIGKILL (signal 9) forces an immediate termination.

terminal
# Graceful termination
$ kill 1423

# Force kill -- use only when graceful fails
$ kill -9 1423

# Kill a process by name
$ killall firefox
Warning

Always try a graceful kill before resorting to kill -9. A graceful termination allows the process to clean up temporary files, close database connections, and save state. Force-killing skips all of that, which can lead to data corruption or orphaned resources.

Networking and Connectivity

Even as a beginner, you'll encounter situations where you need to check whether a server is reachable, look up your own IP address, or download a file. These two commands cover the essentials.

19. ping -- Test Network Connectivity

The ping command sends small packets to a target host and measures the response time. It's the first tool you reach for when something "isn't working" on the network. If ping gets a reply, the network path is functioning. If it times out, you know where to start troubleshooting.

terminal
# Ping a domain
$ ping google.com
PING google.com (142.250.80.46) 56(84) bytes of data.
64 bytes from lax17s65-in-f14.1e100.net: icmp_seq=1 ttl=117 time=5.42 ms
64 bytes from lax17s65-in-f14.1e100.net: icmp_seq=2 ttl=117 time=5.38 ms

# Send only 4 pings and stop
$ ping -c 4 192.168.1.1

On Linux, ping runs continuously until you stop it with Ctrl+C. The -c flag lets you specify how many pings to send before stopping automatically. Pay attention to the response time and whether any packets are lost -- both are key indicators of network health.

20. curl -- Transfer Data from URLs

The curl command transfers data to or from a server using various protocols, though HTTP and HTTPS are by far the most common. It's useful for downloading files, testing APIs, checking whether a web server is responding, and much more.

terminal
# Fetch a webpage and display it in the terminal
$ curl https://example.com

# Download a file and save it
$ curl -O https://example.com/data.tar.gz

# Check HTTP response headers only
$ curl -I https://example.com

# Follow redirects automatically
$ curl -L https://short.url/redirect

You might also encounter wget, which is another download tool that's often preinstalled on Linux systems. The main difference is that wget is designed specifically for downloading files (and can mirror entire websites), while curl supports a wider range of protocols and is more versatile for interacting with APIs and web services.

Putting It All Together

Individually, each of these 20 commands is a simple tool with a specific purpose. The real power of the Linux command line emerges when you start combining them. Pipes (|) let you chain commands together, sending the output of one into the input of the next. Redirects let you save output to files -- use > to write to a new file (or overwrite an existing one) and >> to append to the end of a file without erasing what's already there. Together, these mechanisms let you build workflows that would take many clicks and windows in a graphical environment.

combining commands
# Find all error messages in syslog from today
$ grep "error" /var/log/syslog | tail -20

# Count how many Python files are in a project
$ find ~/projects -name "*.py" | wc -l

# List the 10 largest files in a directory
$ ls -lS /var/log/ | head -10

# Save a process listing to a file (overwrites if file exists)
$ ps aux > running-processes.txt

# Append today's errors to a log (preserves existing content)
$ grep "error" /var/log/syslog >> error-log.txt
Warning

Be careful with the > redirect. If the target file already exists, > will silently overwrite its contents with no way to undo it. When in doubt, use >> to append instead, or check whether the file exists first with ls.

The Linux philosophy is about building complex solutions from simple, composable parts. Each command does one thing well. Your job is to learn how to connect them.

Where to Go from Here

These 20 commands form a solid foundation, but they're just the beginning. Once you're comfortable with the basics, there are a few natural next steps worth exploring. The man command (short for "manual") is your built-in reference -- running man ls or man grep will show you the full documentation for any command, including every flag and option. It opens in less, so the same navigation keys apply: arrow keys to scroll, / to search, q to quit. If a full manual page feels overwhelming, try --help instead (for example, grep --help) for a shorter summary. You don't need to memorize everything upfront; you just need to know where to look.

Beyond individual commands, start learning about shell scripting. A shell script is simply a text file containing a series of commands that run in sequence. Once you can write even a basic script, you can automate repetitive tasks, schedule backups, deploy applications, and build the kind of workflows that make system administration efficient.

Finally, practice in a safe environment. Spin up a virtual machine or use a cloud instance where mistakes don't cost anything. The commands in this article are safe when used thoughtfully, but building comfort with the terminal takes repetition. The more you use these tools, the more natural they become -- and the more you'll appreciate why the command line has been the backbone of Linux administration for decades.