Basic Linux Commands for Beginners

New to Linux? Start here. These fundamental commands are the foundation of everything else you will learn, and mastering them opens the door to the entire Linux ecosystem.

1. ls (List)

Most Used

Shows you what is in the current folder. It is like double-clicking a folder in Windows Explorer or Finder on Mac, but faster and more informative.

# Standard list
$ ls
Documents Downloads Music Pictures
# List with details (size, date, permissions)
$ ls -l
drwxr-xr-x 2 user user 4096 Jan 01 12:00 Documents

2. cd (Change Directory)

Navigation

Moves you into another folder. This is how you walk around your computer through the terminal.

$ cd Documents
$ cd .. (Go back one level)
$ cd ~ (Go to Home folder)
$ cd / (Go to root of filesystem)

3. mkdir (Make Directory)

Creation

Creates a new folder to organize your files. The name comes from "make directory".

$ mkdir NewProject
$ mkdir -p Project/Src/Assets (Create nested folders)

4. touch

Creation

Creates an empty file instantly. You can create multiple files at once by listing them.

$ touch index.html style.css script.js

5. sudo (SuperUser Do)

Admin

Runs a command as Administrator (root). Essential for installing apps and changing system settings. "With great power comes great responsibility."

$ sudo apt update
[sudo] password for user:

Your Journey into the Linux Command Line

Learning Linux commands might seem intimidating at first, especially if you have spent years using graphical interfaces where you point and click. But the command line is not an obstacle to overcome—it is a superpower to unlock. Once you become comfortable with these basic commands, you will find yourself reaching for the terminal even when a GUI option exists, because it is simply faster and more precise.

The commands in this guide represent the absolute foundation of Linux usage. They are the building blocks upon which everything else is constructed. A seasoned system administrator uses these exact same commands hundreds of times per day—they never become obsolete or replaced by "advanced" alternatives. Master them, and you have laid the groundwork for everything from web development to DevOps to cybersecurity.

Why the Terminal Still Matters in 2024

You might wonder why developers still use the terminal when modern operating systems have such polished graphical interfaces. The answer is efficiency and power. While clicking through folders works fine for occasional use, it becomes tedious when you need to work with many files, perform repetitive tasks, or manage remote servers.

Consider this scenario: you need to rename 100 image files from "IMG_001.jpg" through "IMG_100.jpg" to "vacation_001.jpg" through "vacation_100.jpg". In a graphical file manager, this would require clicking each file, selecting rename, typing the new name, and repeating 100 times. In the terminal, it is a single command that takes seconds to type and executes instantly.

More importantly, most servers do not have graphical interfaces at all. When you deploy a web application, manage a database, or configure cloud infrastructure, you will be working through SSH in a terminal. There is no alternative. The skills you learn now will serve you throughout your entire career.

Understanding the File System Structure

Linux organizes files in a hierarchical tree structure, starting from the root directory represented by a single forward slash /. Unlike Windows, which uses different letters for different drives (C:, D:), everything in Linux lives under this single root.

Key directories you will encounter include /home, which contains personal directories for each user; /etc, which holds system configuration files; /var, which stores variable data like logs and databases; /tmp, which is for temporary files that are cleared on reboot; and /usr, which contains user programs and utilities.

Your home directory has a special shortcut: the tilde character ~. When you type cd ~, you are taken to your home directory regardless of where you currently are in the file system. Many configuration files (like .bashrc) live in your home directory and start with a dot, making them "hidden" files that do not appear in normal ls listings (use ls -a to see them).

Tab Completion: Your Best Friend

The single most important productivity feature in the terminal is tab completion. When typing a command or file path, press the Tab key and the shell will automatically complete the name if there is only one match, or show you all possible matches if there are several.

For example, if you have a folder called "Documents" and you type cd Doc then press Tab, the shell will complete it to cd Documents/. This works for commands, file names, directory names, and even some command arguments. You should be pressing Tab constantly—it is faster and prevents typos.

If Tab does not complete anything, that means either nothing matches what you have typed so far, or there are multiple matches. Press Tab twice to see all possibilities. This is incredibly useful when you cannot remember the exact name of a file.

Navigating with Confidence

The pwd command (print working directory) tells you exactly where you are in the file system. This is invaluable when you get lost navigating around. The cd command changes your location, and you can use either absolute paths (starting from /) or relative paths (starting from your current location).

Two special directory references are essential: a single dot . refers to the current directory, and double dots .. refers to the parent directory (one level up). So cd .. moves you up one level, cd ../.. moves you up two levels, and cd ../sibling moves to a sibling directory.

The dash character has a special meaning too: cd - takes you back to the previous directory you were in. This is extremely handy when you are bouncing between two locations—just type cd - to toggle between them.

Creating and Organizing Files

The touch command creates empty files, but its original purpose was actually to update the timestamp of existing files (hence the name "touch"). If the file does not exist, it creates it. This makes it safe to use even if you are not sure whether the file already exists.

mkdir creates directories, and the -p flag is extremely useful. Without -p, if you try to create a/b/c and a does not exist, the command fails. With -p, it creates all the parent directories as needed. Get in the habit of always using mkdir -p.

For removing files and directories, rm removes files and rmdir removes empty directories. To remove a directory with files in it, use rm -r (recursive). Be extremely careful with rm—there is no trash can in the terminal. Deleted files are gone immediately.

Understanding Sudo and Permissions

Linux is fundamentally a multi-user operating system with a sophisticated permissions model. The root user (also called the superuser) has unlimited power to do anything on the system. Regular users have restricted permissions for security reasons—they can only modify their own files and cannot change system configuration or install software globally.

The sudo command allows authorized users to temporarily execute commands with root privileges. When you type sudo apt install package, you are saying "run this installation command as root." You will be prompted for your password, and the system logs that you ran this command—providing accountability.

Not everyone can use sudo—your username must be in the sudoers file. On personal computers, your user is typically granted sudo access during installation. On servers, access is carefully controlled by system administrators.

Building Good Habits

Use the up arrow key to recall previous commands. Your shell maintains a history of everything you have typed, and scrolling through it is much faster than retyping. You can also use history to see a numbered list and ! followed by a number to re-run that command.

When running potentially dangerous commands like rm, add the -i flag for interactive mode, which prompts you before each deletion. Some people even alias rm to rm -i in their shell configuration so they always get prompted.

Finally, read error messages carefully. Linux error messages are usually very specific about what went wrong. "Permission denied" means you need sudo or to check file permissions. "No such file or directory" means you made a typo or are in the wrong location. "Command not found" means the program is not installed or not in your PATH.