LinhGo Labs
LinhGo Labs
Essential Linux Commands Cheat Sheet for Beginners and Developers

Essential Linux Commands Cheat Sheet for Beginners and Developers

The basic Linux commands for beginners, including file management, system information, and process control.

If you’re new to Linux or just need a quick refresher, you’re in the right place. I’ve put together this cheat sheet of the most commonly used Linux commands - the ones I actually use day-to-day, not just theoretical stuff.

Whether you’re SSH’d into a server at 2 AM trying to figure out why something broke, or just getting started with Linux, having these commands at your fingertips is a lifesaver. I’ve organized them by category so you can quickly find what you need.

Linux Commands Sheet

These are your bread and butter - you’ll use them constantly.

  • ls โ€“ directory listing
  • ls -l โ€“ formatted listing
  • ls -la โ€“ formatted listing including hidden files
  • cd dir โ€“ change directory to dir
  • cd .. โ€“ change to parent directory
  • cd ./dir โ€“ change to dir in parent directory
  • cd ~ โ€“ change to home directory
  • pwd โ€“ show current directory (“where am I?”)
  • mkdir dir โ€“ create a directory
  • rm file โ€“ delete file
  • rm -f dir โ€“ force remove file
  • rm -rf dir โ€“ delete directory dir
  • rm -r dir โ€“ remove directory dir
  • rm -rf / โ€“ DON’T DO THIS. Seriously. This nukes your entire system
  • cp file1 file2 โ€“ copy file1 to file2
  • mv file1 file2 โ€“ rename file1 to file2
  • mv file1 dir/file2 โ€“ move file1 to dir as file2
  • touch file โ€“ create or update file
  • cat file โ€“ output contents of file
  • cat > file โ€“ write standard input into file
  • cat >> file โ€“ append standard input into file
  • tail -f file โ€“ output contents of file as it grows (great for watching logs)

When you need to know what’s actually running and how it’s performing:

  • date โ€“ show current date/time
  • uptime โ€“ show uptime (how long has this server been running?)
  • whoami โ€“ who you’re logged in as
  • w โ€“ display who is online
  • cat /proc/cpuinfo โ€“ display CPU info
  • cat /proc/meminfo โ€“ memory info
  • free โ€“ show memory and swap usage
  • du โ€“ show directory space usage
  • du -sh โ€“ displays readable sizes in GB (much more human-friendly)
  • df โ€“ show disk usage
  • uname -a โ€“ show kernel config

For when you need to download stuff or debug connection issues:

  • ping host โ€“ ping host (is it alive?)
  • whois domain โ€“ get whois info for domain
  • dig domain โ€“ get DNS info for domain
  • dig -x host โ€“ reverse lookup host
  • wget file โ€“ download file
  • wget -c file โ€“ continue stopped download (lifesaver for large files)
  • wget -r url โ€“ recursively download files from URL
  • curl url โ€“ outputs the webpage from URL
  • curl -o meh1.html url โ€“ writes the page to meh1.html
  • ssh user@host โ€“ connect to host as user
  • ssh -p port user@host โ€“ connect to host on specific port
  • ssh -D user@host โ€“ connect & use bind port

  • tar cf file.tar files โ€“ tar files into file.tar
  • tar xf file.tar โ€“ untar into current directory
  • tar tf file.tar โ€“ show contents of archive
  • c โ€“ create archive
  • t โ€“ table of contents
  • x โ€“ extract
  • z โ€“ use zip/gzip
  • f โ€“ specify filename
  • j โ€“ bzip2 compression
  • w โ€“ ask for confirmation
  • k โ€“ do not overwrite
  • T โ€“ files from file
  • v โ€“ verbose

This trips up a lot of people, but it’s actually pretty simple once you get it:

  • chmod octal file โ€“ change permissions of file
  • 4 โ€“ read (r)
  • 2 โ€“ write (w)
  • 1 โ€“ execute (x)

Add them up for combinations. So read + write = 6, read + execute = 5, all three = 7.

  • owner/group/world
  • chmod 777 โ€“ rwx for everyone (use sparingly - it’s a security risk)
  • chmod 755 โ€“ rwx for owner, rx for group/world (good for scripts)
  • chmod 644 โ€“ rw for owner, r for everyone else (good for files)

For managing what’s running on your system:

  • ps โ€“ display currently active processes
  • ps aux โ€“ detailed outputs (shows everything)
  • kill pid โ€“ kill process with process id (pid)
  • killall proc โ€“ kill all processes named proc (be careful with this one)

Because we all spend half our time looking for files:

  • grep pattern files โ€“ search in files for pattern
  • grep -r pattern dir โ€“ search for pattern recursively in dir (searches subdirectories too)
  • locate file โ€“ find all instances of file (fast, uses a database)
  • whereis app โ€“ show possible locations of app
  • man command โ€“ show manual page for command (RTFM in action)

Pro tip: When in doubt, man is your friend. Almost every command has a manual page. Just type man [command] and you’ll get detailed info about what it does and all its options.

Bookmark this page or keep it handy - even experienced Linux users look up syntax all the time. No shame in that!