basic linux commands
2026-04-01
Here is a curated list of the most basic Linux commands, categorized by function.
1. Navigation (Getting Around)
# Print Working Directory - shows where you are
pwd
# Change Directory
cd ~ # go home
cd .. # go up 1 level
cd /home/bob/music/ # go to that folder
# List
ls # shows contents of a directory
2. File Management (Creating, Moving, Deleting)
# Make Directory
mkdir folder-name
# Create file
touch file.txt
# Copy
cp [src] [dest]
cp file.txt file-backup.txt
# Move
mv file.txt ~/backups/
# Remove
rm file.txt
rm -r folder/ # recursively remove (remove folders and folders inside folders)
3. Viewing File Content
# Concatenate (you can pass in multiple files)
cat file.txt # prints the contents of file.txt to the screen
cat file.txt otherfile.txt # prints contents of both files
# View scrollable
less file.txt
# View first 5 lines
head -n 5 file.txt
# View last lines (follow)
tail -f file.txt
# ^ this is useful to watch a file get populated, like a log file
4. Permissions & Ownership
# Change Mode
# - changes permissions - read/write/execute for owner/group/other
chmod 755 file.txt
# Change Owner
chown user:group file.txt
5. Search & Filter
# Global Regular Expression Print
# - basically find certain text in a file
grep "error" log.txt
# Find all files (-r recursively) in /home/billy that contain the word "binger"
grep -r "binger" /home/billy/
# Find
# - find all files in THIS directory that end in .log
# - ("." means HERE, as in pwd)
find . -name "*.log"
# - find all files in /etc/systemd/ that end in .conf, case insensitive
find /etc/systemd -iname "*.conf"
6. System Information & Processes
# Who Am I? - shows your username
whoami
# Process Status
# - lists all running processes
ps aux
# Kill
kill [PID] # kill a process using its ID
pkill [name] # kill a process by name
# Process Monitor
# Real-time system resource usage
top
htop
btop
nvtop # GPU
7. Networking
# Ping - connectivity test.
ping [host]
ping 1.1.1.1 # ping cloudflare
# Secure Shell - connect to another computer
ssh user@host
# IP
ip addr
ip -c a # colored bit more nicely
8. Extra Tips
# History
# - forgot what command you ran? type history
history
# Tab
# - press TAB on your keyboard to autocomplete commands
# Manual
# - You can type man before any command to read its manual
man ls
man cd
man ssh
# TLDR
# - Manuals are...long. Just give me the bits
tldr ls
tldr cd
tldr ssh
# You may have to install this first - sudo apt install tldr
# Pipe
# - 'Piping' is using the output of 1 command as the input to another.
# - You put a | character between the commands.
# - e.g. Sort process list by CPU (3rd column) in reverse numerical order (highest first) and get the top 5 CPU hogs
ps aux | sort -k 3 -nr | head -n 5
# - e.g. Watch a log file for lines that contain 'error'
tail -f /var/log/logfile.txt | grep "error"
Safety
Always double-check your commands before pressing Enter, especially with:
rm(Remove)sudo(Run as root)chmod 777(Open permissions)dd(Disk write - extremely dangerous)