KnowledgebaseBasic Linux Command List (Cheat Sheet)

A practical basic Linux command list: navigation, files, permissions, processes, networking, disk, and SSH. Includes examples and safe flags for VPS and server use.

DocumentationUpdated Jan 28, 2026

Basic Linux command list (cheat sheet)

This is a basic Linux command list you can keep as a quick reference. It covers the commands you will use most on Ubuntu, Debian, CentOS, AlmaLinux, Rocky Linux, and Fedora. Each section includes short examples you can copy and run. If you are working on a VPS, use the safety notes to avoid the common mistakes.

Before you start (quick safety rules)

  • Know where you are: run pwd before deleting or moving files.
  • Start read-only: check with ls -lah, then act.
  • Use help pages: command --help or man command.
  • Avoid risky defaults on servers: do not use chmod 777 unless you understand why it is needed, and be extra careful with rm -rf.

Basic Linux command list (quick cheat sheet)

Use this table when you just need the command fast. Detailed examples are below.

TaskCommandExample
Show current folderpwdpwd
List files (human)lsls -lah
Change foldercdcd /var/www
Copy / movecp, mvcp -a src/ backup/
Search in filesgrepgrep -R "error" /var/log
Check disk spacedfdf -h
Check inodesdfdf -i
See CPU and RAM usagetoptop
Manage servicessystemctlsystemctl status nginx
Find open portsssss -tulpn
SSH into a serversshssh root@203.0.113.10

Navigation commands (folders and paths)

  • pwd: print the current working directory.
    pwd
  • ls: list files and folders. Useful flags: -l (details), -a (hidden), -h (human sizes).
    ls -lah
  • cd: change directory.
    cd /etc
    cd ..
    cd ~
  • which: show the path of a command (helps when multiple versions exist).
    which php

Terminal basics and help commands

  • clear: clear the terminal screen.
    clear
  • history: show your previous commands (great for repeating work).
    history | tail -n 20
  • man: open the manual page for a command.
    man rsync
  • exit: close your shell session (or SSH session).
    exit

File and directory commands

  • touch: create an empty file or update timestamp.
    touch notes.txt
  • mkdir: create a directory. Use -p for nested folders.
    mkdir -p projects/app/logs
  • cp: copy files and folders. Use -r for directories, -a to preserve permissions and timestamps.
    cp -a /var/www/html /var/www/html-backup
  • mv: move or rename.
    mv old-name.txt new-name.txt
  • rm: remove files. Use -r for directories. On servers, consider interactive delete to be safe.
    rm -i file.txt
    rm -r folder/
  • ln: create links. Use -s for symlinks.
    ln -s /var/www/site/current public

View files and logs

  • cat: print file content (best for small files).
    cat /etc/os-release
  • less: view a file page by page (great for configs and logs).
    less /var/log/syslog
  • head: show first lines.
    head -n 50 access.log
  • tail: show last lines. Use -f to follow logs live.
    tail -n 200 error.log
    tail -f /var/log/nginx/error.log

Search and filter text

These are the basics you will use for troubleshooting and log searching.

  • grep: search for text in a file or directory. Useful flags: -R (recursive), -n (line numbers), -i (ignore case).
    grep -Rni "permission denied" /var/log
  • find: search for files by name, type, size, and more (very useful on servers).
    find /var/www -type f -name "*.log"
  • wc: count lines, words, bytes.
    wc -l access.log
  • sort and uniq: sort lines and deduplicate (often used together).
    sort file.txt | uniq -c
  • cut: extract columns by delimiter.
    cut -d: -f1 /etc/passwd

Permissions and ownership (very important on VPS)

Linux permissions control who can read, write, and execute files. Most “site is broken” issues on servers come from wrong ownership or permissions.

  • chmod: change permissions.
    chmod 644 file.txt
    chmod 755 folder/
  • chown: change owner and group.
    chown -R www-data:www-data /var/www/site
  • stat: show permissions and metadata.
    stat wp-config.php
Common modeTypical useMeaning (owner/group/others)
644Regular files (configs, text)rw- / r-- / r--
600Sensitive files (keys, secrets)rw- / --- / ---
755Directories and executablesrwx / r-x / r-x

Tip: If you are tempted to use 777, stop and fix ownership first. It is usually safer to set the correct user and group with chown than to open permissions for everyone.

User and identity commands

  • whoami: show the current user.
    whoami
  • id: show user ID, group ID, and groups.
    id
  • groups: list your groups.
    groups
  • sudo: run a command as root (or another user).
    sudo systemctl restart nginx
  • passwd: change a user password (requires permissions).
    passwd

Processes and services

On a VPS, these commands help you spot high CPU or RAM usage and manage services safely.

  • ps: list running processes.
    ps aux | head
  • top: live view of CPU and RAM usage (press q to quit).
    top
  • kill and pkill: stop a process by PID or name.
    kill 1234
    pkill -f "php-fpm"
  • systemctl: manage services on systemd distros.
    systemctl status nginx
    systemctl restart mysql
  • journalctl: view systemd logs.
    journalctl -u nginx --since "1 hour ago"

Networking commands (IP, ports, DNS)

  • ip a: show IP addresses and interfaces.
    ip a
  • ip r: show routing table (helps diagnose “no internet”).
    ip r
  • ss: show listening ports and connections (modern replacement for netstat).
    ss -tulpn
  • ping: test basic connectivity.
    ping -c 4 1.1.1.1
  • curl: test HTTP and APIs from the terminal.
    curl -I https://example.com
  • dig (or nslookup): check DNS resolution.
    dig +short middlehost.com

Disk space, inodes, and memory

Disk space and inodes are different. A server can have free GBs but still fail uploads if it runs out of inodes (too many files).

  • df: disk usage by filesystem.
    df -h
  • df -i: inode usage by filesystem.
    df -i
  • du: folder sizes (useful for finding big directories).
    du -sh /var/log/* | sort -h
  • free: memory usage (RAM and swap).
    free -h
  • lsblk: list disks and partitions.
    lsblk

Archives and compression

  • tar: create or extract tar archives.
    tar -czf backup.tar.gz folder/
    tar -xzf backup.tar.gz
  • zip and unzip: zip archives (if installed).
    zip -r site.zip public/
    unzip site.zip

Package management (install software)

Your package manager depends on your distro. Run cat /etc/os-release if you are unsure.

Distro familyUpdateInstall package
Ubuntu / Debiansudo apt updatesudo apt install nginx
Fedora / Rocky / Alma / RHELsudo dnf updatesudo dnf install nginx

SSH and file transfer (remote server basics)

  • ssh: connect to a remote server.
    ssh user@server-ip
  • scp: copy files over SSH.
    scp file.txt user@server-ip:/root/
  • rsync: fast sync (best for large folders, keeps progress and can resume).
    rsync -avz ./site/ user@server-ip:/var/www/site/

If you are doing this on a VPS (Middlehost quick pointers)

A cheat sheet is great, but performance issues on websites are usually CPU, RAM, disk I/O, or misconfigured services. If you need a clean Linux environment to practice these commands, a Virtual Private Server (VPS) for Linux gives you full root access. For heavier workloads and isolation, consider dedicated servers for high traffic sites.

FAQs

What are the most important Linux commands for beginners?

Start with navigation and safety basics: pwd, ls -lah, cd, plus file commands like cp, mv, and rm -i. For troubleshooting, learn grep, tail -f, df -h, and top. These cover 80% of day-to-day server tasks.

How do I check disk space and inodes on Linux?

Use df -h to see disk space in GB and MB, and use df -i to see inode usage. Inodes are the “file count” capacity of a filesystem. If you run out of inodes, you can have free disk space but still cannot create new files, uploads, or cache files.

What is the difference between sudo and su?

sudo runs a single command with elevated permissions, based on your user’s sudo rules. su switches to another user, often root, for a full session. On servers, sudo is usually safer because it keeps actions scoped to one command and leaves a clearer audit trail in logs.

How do I find which process is using a port?

Run ss -tulpn to list listening ports and the process names. If you suspect a specific port, filter it like ss -tulpn | grep :80 or grep :443. This is useful when a web server fails to start because “address already in use” usually means another service is bound to that port.

What is the safest way to delete files on a Linux server?

First confirm your path with pwd and list targets with ls -lah. For single files, use rm -i so you get a confirmation prompt. For directories, consider deleting in smaller steps and avoid running rm -rf unless you are completely sure. When in doubt, move to a backup folder first.

Supercharge Your Website with Blazing-Fast Hosting

Join thousands of businesses and creators who trust us to deliver unmatched speed, reliability, and support. Let’s chat and find the perfect plan for you!

Chat with Us
99.9% Uptime
24/7 Support