20 Basic Linux Commands

Essential commands every beginner needs to learn

Command Syntax

A typical Linux command follows this pattern: command -options argument

Think of the Linux terminal as a powerful way to talk directly to your computer. These commands are the essential vocabulary you need to navigate and control your system effectively.

1

pwd

Print Working Directory - Shows you the full path of the directory you are currently in. It's your compass in the file system.

$ pwd
/home/username
2

ls

List - Lists the files and directories in your current location.

Common options: -l (detailed list), -a (show hidden files)

$ ls -la
total 24
drwxr-xr-x 2 user user 4096 Mar 1 10:00 .
3

cd

Change Directory - Moves you to a different directory.

Common usage: cd Documents, cd .., cd ~, cd -

$ cd Documents
$ pwd
/home/username/Documents
4

mkdir

Make Directory - Creates a new directory.

$ mkdir my_new_folder
5

touch

Creates a new, empty file. Also used to update the timestamp of an existing file.

$ touch new_file.txt
6

cp

Copy - Copies files or directories.

Common options: -r (copy directories recursively)

$ cp important_document.txt important_document_backup.txt
$ cp -r my_project my_project_backup
7

mv

Move - Moves or renames files and directories.

$ mv old_filename.txt new_filename.txt # Renaming
$ mv file.txt /path/to/destination/ # Moving
8

rm

Remove - Deletes files or directories. Use with extreme caution!

Common options: -r (remove directories), -i (prompt before deletion)

$ rm -i temporary_file.txt
rm: remove regular file 'temporary_file.txt'? y
9

cat

Concatenate - Displays the entire content of a file on the screen. Best for short files.

$ cat config.txt
username=john_doe
email=john@example.com
10

less

Displays file content one screen at a time. Much better for viewing long files.

$ less long_log_file.log
# Press spacebar to go down, 'b' to go up, 'q' to quit
11

head

Shows the first 10 lines of a file.

$ head /var/log/syslog
12

tail

Shows the last 10 lines of a file. Extremely useful with -f to follow a file in real-time.

$ tail -f /var/log/auth.log # Watch live login attempts
13

find

Searches for files and directories in a directory hierarchy.

$ find /home -name "*.jpg" # Find all .jpg files in /home
14

grep

Global Regular Expression Print - A powerful search tool for finding text patterns within files.

$ grep "error" system.log
$ ls -la | grep "Mar 1" # Using pipe to filter output
15

man

Manual - The most important command! Shows the documentation for other commands.

$ man ls # Get detailed info on all options for the `ls` command
16

chmod

Change Mode - Changes the permissions (read, write, execute) of a file or directory.

$ chmod +x my_script.sh # Make a script executable
17

sudo

SuperUser Do - Runs a command with administrative (root) privileges.

$ sudo apt update # Update package lists (on Ubuntu/Debian)
18

Package Managers

Installs, updates, and removes software packages.

$ sudo apt update # Refresh package lists (Ubuntu/Debian)
$ sudo apt install vim # Install Vim
$ sudo apt remove package_name # Remove a package
19

ps

Process Status - Shows a snapshot of the currently running processes.

$ ps aux # Show all running processes
20

kill

Terminates a running process. You need the Process ID (PID) from the ps command.

$ kill 1234 # Politely ask process ID 1234 to stop
$ kill -9 1234 # Forcefully kill process ID 1234

Pro Tip: The Pipe (|)

This isn't a command by itself, but a fundamental concept. The pipe takes the output of the command on the left and uses it as the input for the command on the right.

$ ps aux | grep firefox # Show only processes related to "firefox"

← Back to Fundamentals Index ↑ Back to EXPANDED