The first time I accidentally ran rm -rf * in my home directory, I lost documents, SSH keys, and saved scripts in seconds. No warning. No confirmation. Just gone. I didn’t have a proper backup, so recovery was messy and incomplete.
That mistake taught me more about Linux than any tutorial did.
If you’re new to Linux, the terminal can feel intimidating. Whether you’re a student, a freelancer, or just someone who set up Ubuntu out of curiosity, that feeling is normal. However, once you learn these 50 Linux commands for beginners, you’ll be able to navigate the file system, manage files, monitor your system, and troubleshoot basic issues on your own.
This is not a dry reference list. Each command comes with context, real examples, and warnings where it matters. Specifically, you’ll find real stories of what happens when these commands go wrong. Bookmark this page. You’ll come back to it. For more guides like this, check out our WisePH tech tutorials.
How to use this list
If you’re a complete beginner, start at the top and work through each section. If you already know the basics, jump to the section you need. Commands shown like this are typed exactly as written in your terminal. Square brackets like [file] simply mean you replace that part with your actual file name.
Navigation commands: ls, pwd, cd
What are the most important Linux navigation commands?
ls, pwd, and cd are the three commands you will use every single terminal session. They show where you are, what’s in a folder, and how to move around. Learn these first, before anything else.
| Command | What it does |
|---|---|
ls | List contents of the current directory |
pwd | Show the full path of where you are right now |
cd [folder] | Move into a folder |
cd .. | Go up one level |
cd ~ | Go back to your home directory |
ls: list directory contents
ls shows what’s inside a folder. Add -la to see hidden files and permissions too.
ls
ls -lapwd: print working directory
Run pwd before any destructive command like rm. Knowing exactly where you are prevents a lot of disasters. This habit alone has saved me more than once.
pwdcd: change directory
cd Documents
cd ..
cd ~File and directory management: mkdir, mv, cp, rm, touch, rmdir
How do I create, move, copy, and delete files in Linux?
Six commands handle most of your file work. mkdir creates folders, mv moves or renames, and cp copies. Additionally, rm deletes files, touch creates empty files, and rmdir removes empty folders. The dangerous one is rm. More on that in a moment.
| Command | What it does |
|---|---|
mkdir [name] | Create a new directory |
mv [source] [dest] | Move or rename a file |
cp [source] [dest] | Copy a file |
rm [file] | Delete a file permanently |
rm -rf [dir] | Delete a directory and all its contents |
touch [file] | Create a blank new file |
rmdir [dir] | Delete an empty directory |
mkdir: make directory
A common beginner mistake: running mkdir with a path that doesn’t exist yet. Add -p to create parent folders automatically.
mkdir projects
mkdir -p projects/2026/aprilmv: move or rename files
mv report.txt Documents/
mv oldname.txt newname.txtcp: copy files
Use -r to copy entire directories.
cp file.txt backup.txt
cp -r myfolder/ backup_folder/rm and rmdir: the ones that bite
rm does not send files to trash. Deleted files are gone.
I once ran rm -rf * thinking I was inside a temp folder. I had actually cd‘d into my home directory earlier and forgotten. As a result, it wiped out documents, SSH keys, and saved scripts. Recovery was messy and incomplete. Since then, I always run pwd first and use rm -i for anything risky.
Similarly, a coworker tried to clean up log files on a production server using rm -rf /var/log/*. He accidentally typed an extra space in the wrong place. Services started failing hours later. It took a full day to trace it back to that one command.
Before running rm, do three things:
- Run
pwdto confirm where you are - Use
rm -ito get a confirmation prompt for each file - Never run
rm -rf /, ever
rm file.txt
rm -i file.txt # asks before deleting each file
rmdir empty_folder/Viewing files: cat, less, head, tail, diff
How do I read a file in Linux without opening a text editor?
cat dumps the whole file to your terminal. less lets you scroll page by page. head and tail show the first or last lines. diff compares two files side by side.
| Command | What it does |
|---|---|
cat [file] | Print entire file to terminal |
less [file] | Read file one screen at a time (press Q to quit) |
head [file] | View first 10 lines |
tail [file] | View last 10 lines |
diff [file1] [file2] | Compare two files line by line |
cat notes.txt
less longfile.txt
head -20 report.txt # first 20 lines
tail -f /var/log/syslog # follow live log updates
diff file1.txt file2.txttail -f is especially useful when monitoring live server logs. It updates in real time as new lines get written.
Writing and terminal utilities: echo, clear, history, alias
What does the echo command do in Linux?
echo prints text to the terminal or writes it to a file. It sounds simple, but the > vs >> distinction trips up almost every beginner at some point.
A junior dev tried to add an environment variable to a .env file:
echo "API_KEY=abc123" > .envThat single > wiped out every existing variable: API keys, database config, everything. The app went down. They had to restore from backup. In short, always use >> unless you specifically want to replace the file’s contents.
echo "Hello" >> notes.txt
clear # clears the terminal screen
history # shows your recent commands
alias ll='ls -la' # create a shortcut commandalias is one of the most time-saving commands on this list. Add your most-used aliases to ~/.bashrc. That way, they load automatically every session.
System information: top, df, du, free, uptime, uname
How do I check system performance in Linux?
These six commands give you a real-time picture of what your system is doing: CPU usage, disk space, memory, and uptime. Think of them as your terminal’s built-in dashboard.
| Command | What it shows |
|---|---|
top | Live CPU and memory usage (like Task Manager) |
df -h | Disk space for all mounted drives |
du -sh [dir] | How much space a specific folder uses |
free -h | RAM and swap usage |
uptime | How long the system has been running |
uname -a | Full system and kernel info |
top
df -h
du -sh ~/Downloads
free -h
uptime
uname -aPress Q to exit top. It stays open until you close it.
User and permissions: sudo, chmod, chown, useradd, passwd, whoami, w, finger
How do permissions work in Linux?
Linux assigns every file an owner. It also assigns a set of read, write, and execute permissions for three groups: the owner (u), the group (g), and everyone else (o). chmod changes those permissions. chown, on the other hand, changes who owns the file. Both require care.
| Command | What it does |
|---|---|
sudo [command] | Run a command as root (admin) |
chmod [permissions] [file] | Change file permissions |
chown [user] [file] | Change file ownership |
useradd [name] | Create a new user account |
passwd | Change your password |
whoami | Print the current logged-in user |
w | Show who is logged in and what they’re running |
finger [user] | Show a short info dump about a user |
chmod: where beginners go wrong
Two mistakes come up constantly.
First: someone hits a permission error and immediately runs chmod 777 on everything. It fixes the error. However, 777 means anyone can read, write, and execute the file, including attackers. One developer made the entire upload folder of a PHP app 777. As a result, the site got injected with malware within a week.
Second: setting chmod 644 on a directory. Files don’t usually need execute permission. Directories, however, do. Without it, nothing can enter the folder. Consequently, the app breaks, not because permissions are too open, but because they’re too restrictive in the wrong place.
The right approach: give the minimum permissions needed, not the maximum that works.
chmod 644 file.txt # owner reads/writes, others read only
chmod 755 myfolder/ # owner full access, others read and enter
chmod -R 755 /var/www/ # apply recursively to a web folder
chown username file.txtpasswd: the underrated one most tutorials skip
Almost every Linux guide covers ls, cd, and sudo. Very few, however, mention passwd. If you’re logging into a machine for the first time, especially a server or shared system, changing your password immediately is basic practice.
passwdIt prompts for your current password, then your new one twice. That’s it. No flags, no manual digging.
sudo, whoami, w, finger
sudo gives you root-level power for a single command. That’s enough to break things. Use it only when a command specifically requires it, not out of habit.
sudo apt update
whoami
w
finger usernameSearch and locate: grep, find, locate, whereis, whatis
What is the best command to search for files in Linux?
find searches in real time and always returns current results. locate, by contrast, uses a cached index and is faster but may miss recently created files. grep searches inside files for specific text. whereis tells you where a program is installed. Finally, whatis gives a one-line description of any command.
| Command | Best for |
|---|---|
grep "text" file | Search inside a file for matching text |
find / -name "file" | Search by file name in real time |
locate file | Fast search from a cached index |
whereis [command] | Find where a program is installed |
whatis [command] | One-line description of any command |
grep "error" /var/log/syslog
find /home -name "*.txt"
locate report.pdf
whereis python3
whatis chmodIf locate doesn’t find a file you just created, run sudo updatedb first to refresh the index.
Network commands: ping, ssh, ifconfig, ip a
How do I check my IP address and network status in Linux?
ifconfig and ip a both show your network interfaces and IP addresses. ping tests if a host is reachable. ssh, meanwhile, opens a secure encrypted connection to another machine over any network.
| Command | What it does |
|---|---|
ping [address] | Test connection to a server or website |
ssh user@host | Connect to a remote server securely |
ifconfig | Show IP and network interface info |
ip a | Modern, shorter alternative to ifconfig |
ping google.com
ssh username@192.168.1.10
ifconfig
ip aip a is the current standard. Some minimal Linux installs don’t include ifconfig by default. So it’s worth knowing both.
Archiving: tar, zip, unzip
How do I compress and extract files in Linux?
tar bundles multiple files into one archive. It can also compress them. zip creates a zip file compatible with Windows and Mac. unzip extracts those archives.
tar -cvf archive.tar myfolder/ # create a tar archive
tar -xvf archive.tar # extract a tar archive
tar -czvf archive.tar.gz myfolder/ # create compressed tar.gz
zip -r backup.zip myfolder/
unzip backup.zipProcess management: kill, jobs
How do I stop a frozen program in Linux?
kill sends a signal to a process to stop it. jobs lists background tasks in your current session. To find the process ID, combine ps with grep.
jobs
ps aux | grep firefox
kill [PID]
kill -9 [PID] # force kill (use when the regular kill does not work)kill -9 is the hard stop. Use it when a process refuses to close normally.
Package and miscellaneous: apt, sort, cal
apt manages software packages on Debian-based distros like Ubuntu. It’s how you install, update, and remove programs from the command line.
sudo apt update # refresh the package list
sudo apt install [name] # install a program
sudo apt remove [name] # uninstall a programsort arranges lines of text alphabetically or numerically.
sort names.txt
sort -r names.txt # reverse ordercal shows a calendar in your terminal. Simple, but genuinely useful when you need a quick date check without leaving the terminal.
cal
cal 2026Commands to treat with caution
Some commands on this list cause real, hard-to-reverse damage when misused. These four deserve extra attention.
| Command | Why it’s risky |
|---|---|
rm -rf | Permanently deletes everything in a path with no confirmation |
rmdir | Deletes directories; confirm the path before running |
sudo | Any mistake runs with full root-level power |
chmod -R 777 | Opens every file to every user, a security hole on any server |
One habit prevents most accidents: run pwd before any destructive command. Know where you are before you act.
The one command most beginners skip: passwd
Every Linux tutorial covers ls, cd, and sudo. Almost none spend time on passwd. However, if you’re logging into a machine for the first time (a server, a shared system, or even a fresh Ubuntu install), changing your password right away is smart practice. Most people skip this step and forget about it entirely.
passwdIt asks for your current password, then your new one twice. No extra steps. In my opinion, it’s one of the most practical commands a regular user can know. Specifically, it’s useful precisely because it’s so easy to overlook.
Frequently asked questions
What is the safest way to delete files in Linux?
Use rm -i so the terminal asks for confirmation before deleting each file. For directories, always run pwd first to confirm your location. Avoid rm -rf unless you are completely certain of the target path.
What does sudo mean in Linux?
sudo stands for “superuser do.” It lets you run a single command with root-level admin permissions. Use it only when a command specifically requires it. A mistake with sudo can affect the whole system.
How do I check my IP address in Linux?
Run ip a or ifconfig in the terminal. Look for the inet line under your active network interface. On Ubuntu, the interface is usually called eth0 for wired connections or wlan0 for Wi-Fi.
What is the difference between find and locate in Linux?
find searches your file system in real time and always returns current results. locate uses a pre-built index and is faster, but may miss recently created files. Run sudo updatedb to refresh the locate index.
How do I change my password in Linux terminal?
Run passwd and follow the prompts. It asks for your current password, then your new one twice. No other flags or options needed for a basic password change.
Start with five, build from there
You don’t need to memorize all 50 commands today. Instead, start with navigation: ls, pwd, cd. Then move into file management. Add one group at a time until the terminal feels like home.
The biggest lesson from losing my home directory: always know where you are before you act. pwd takes one second. Recovery, however, can take days.
Keep exploring. The terminal rewards curiosity. For more tech guides written for regular users, browse the WisePH tech tutorials.









