Home Linux Commands 50 Linux Commands Cheat Sheet for Beginners

50 Linux Commands Cheat Sheet for Beginners

Dive into the world of Linux with this essential guide, featuring 50 must-know commands for beginners. From navigating directories to managing processes, this article equips you with the foundational skills needed to confidently use Linux and take control of your computing environment.

by Arun Kumar
linux commands cheat sheet for beginners

Navigating the Linux terminal can seem like traversing a labyrinth for beginners. But, fear not! As an experienced Linux user and a Raspberry Pi enthusiast, I’ve spent countless hours tinkering with commands, some of which have become my steadfast allies in the digital realm.

Today, I’ll share 50 Linux commands that will transform you from a novice to a proficient user, especially on the delightful little powerhouse known as the Raspberry Pi.

50 Essential Linux Commands for Beginners

Navigating the file system

  1. pwd (Print Working Directory): Shows your current directory. Simple yet indispensable.bash
    $ pwd
    /home/pi
  2. ls (List): Displays files and directories in your current directory. Spice it up with -l for detailed listings, -a to include hidden files, and -h for human-readable sizes.bash
    $ ls -lah
    total 28K
    drwxr-xr-x  2 pi pi 4.0K Jan  1 10:00 .
    drwxr-xr-x  3 pi pi 4.0K Dec 31 09:30 ..
    -rw-r--r--  1 pi pi  220 Feb 25  2020 .bash_logout
    -rw-r--r--  1 pi pi 3.7K Feb 25  2020 .bashrc
  3. cd (Change Directory): Move around the file system like a pro. cd .. takes you one level up, while cd brings you back home.bash
    $ cd /var/log
    $ pwd
    /var/log
  4. mkdir (Make Directory): Create new directories to keep your projects organized.bash
    $ mkdir projects
  5. rmdir (Remove Directory): Deletes empty directories. I rarely use this as rm -r is my go-to for stubborn non-empty ones.bash
    $ rmdir unused_folder
  6. touch: Create a new file or update the timestamp of an existing one. My lazy self loves it for quickly creating files.bash
    $ touch newfile.txt
  7. rm (Remove): Deletes files or directories. Use with caution; rm -rf is powerful but can be your worst nightmare if misused.bash
    $ rm oldfile.txt
  8. cp (Copy): Duplicate files or directories. The -r option is a lifesaver for copying directories.bash
    $ cp source.txt destination.txt
  9. mv (Move): Move or rename files. I often misuse it to quickly rename files.bash
    $ mv oldname.txt newname.txt
  10. cat (Concatenate): Display file contents. I find it less useful for long files; that’s where less or more comes in handy.bash
    $ cat file.txt
    Hello, Raspberry Pi!

File inspection

  1. less: View content of a file one page at a time. My go-to for reading long log files.bash
    $ less /var/log/syslog
  2. head: Show the first few lines of a file. Perfect for getting a quick peek.bash
    $ head -n 5 largefile.txt
  3. tail: Opposite of head, it shows the last few lines. Use tail -f to live-watch files like logs.bash
    $ tail -n 5 largefile.txt
  4. grep (Global Regular Expression Print): Search within files. It’s like a treasure hunt for text.bash
    $ grep "error" /var/log/syslog
  5. find: Locate files and directories. It’s a bit complex but incredibly powerful once mastered.bash
    $ find / -name "python*"
  6. diff: Compare file contents. I don’t use it much, but it’s a godsend for finding subtle differences.bash
    $ diff file1.txt file2.txt
  7. file: Determine file type. Handy for mysterious files without extensions.bash
    $ file mysteryfile

System monitoring and management

  1. top: Display active processes. It’s mesmerizing to watch but can be overwhelming.bash
    $ top
  2. ps (Process Status): List running processes. Use ps aux for a comprehensive list.bash
    $ ps aux
  3. df (Disk Free): Show available disk space. Use -h to make sense of the numbers.bash
    $ df -h
  4. du (Disk Usage): Check the size of directory contents. Great for finding space hogs.bash
    $ du -sh /home/pi
  5. free: Display memory usage. Simple yet crucial for monitoring.bash
    $ free -h
  6. kill: Terminate processes. Use with care; it’s like flipping the off switch on a process.bash
    $ kill -9 1234
  7. htop: An interactive process viewer. It’s top on steroids and much more user-friendly.
  8. uptime: Show how long the system has been running. A quick way to check system stability.bash
    $ uptime

Networking commands

  1. ping: Check the connection to a server. It’s my first step in troubleshooting network issues.bash
    $ ping google.com
  2. ifconfig / ip addr: Display network interfaces and IP addresses. I prefer ip addr for its modern touch.bash
    $ ip addr
  3. netstat: Show network connections, routing tables, and interface statistics. A bit old-school but useful.bash
    $ netstat -tuln
  4. wget: Download files from the web. It’s like a command-line web browser.bash
    $ wget http://example.com/file.zip
  5. curl: Interact with URLs. More versatile than wget but with a steeper learning curve.bash
    $ curl -O http://example.com/file.zip

File permissions and ownership

  1. chmod (Change Mode): Modify file or directory permissions. Essential for managing access rights.bash
    $ chmod 755 script.sh
  2. chown (Change Owner): Change the owner and group of a file. Use sudo to wield this power.bash
    $ sudo chown pi:pi file.txt
  3. umask: Set the default creation permissions for new files. Rarely used, but good to know.bash
    $ umask 022

Package management (Debian/Raspberry Pi OS)

  1. apt-get update: Update the list of available packages. Always do this before installing new software.bash
    $ sudo apt-get update
  2. apt-get upgrade: Upgrade all installed packages to their latest versions.bash
    $ sudo apt-get upgrade
  3. apt-get install: Install new software packages. Where the magic of Linux really happens.bash
    $ sudo apt-get install nginx
  4. dpkg: Debian package manager. Use dpkg -l to list installed packages.bash
    $ dpkg -l | grep nginx
  5. apt-get remove: Remove installed packages. Don’t forget about purge to remove config files as well.bash
    $ sudo apt-get remove nginx

Archiving and compression

  1. tar: Archive files. The -czvf and -xzvf flags are my go-to for compressing and decompressing.bash
    $ tar -czvf archive.tar.gz /path/to/directory
  2. gzip / gunzip: Compress or decompress files. I use gzip for quick compression tasks.bash
    $ gzip file.txt

Text editing

  1. nano: A beginner-friendly text editor. It’s my first recommendation for newcomers.bash
    $ nano file.txt
  2. vi / vim: Advanced text editors. vim has a steep learning curve but is incredibly powerful once mastered.

Miscellaneous commands

  1. echo: Display a line of text. Great for scripting and simple output.bash
    $ echo "Hello, world!"
  2. alias: Create shortcuts for commands. I have ll aliased to ls -lah for convenience.bash
    $ alias ll='ls -lah'
  3. history: Display your command history. A lifesaver when you forget that complex command you just typed.bash
    $ history
  4. which: Locate a command. Shows the path to the binary executed.bash
    $ which python3
  5. man (Manual): Display the manual pages for a command. The first place to look when in doubt.bash
    $ man ls
  6. ssh (Secure Shell): Log into a remote machine. Essential for managing Raspberry Pis headlessly.bash
    $ ssh pi@raspberrypi.local
  7. scp (Secure Copy): Copy files over the network. Works like cp but for remote systems.bash
    $ scp file.txt pi@raspberrypi.local:/home/pi/
  8. cron: Schedule commands to run at specific times. It’s like setting an alarm clock for your scripts.bash
    $ crontab -e

Wrapping up

Embarking on your Linux journey with a Raspberry Pi is like unlocking a treasure chest of learning opportunities. While some commands, like rm -rf, can unleash chaos if misused, others, like ls and cd, will become your daily bread and butter. My personal favorites? grep for its sheer power in searching and htop for its visually appealing way of displaying system processes. I encourage you to play around with these commands, explore their options, and discover your own favorites. Remember, mastery comes with practice, and with these 50 commands, you’re well on your way to becoming a Linux maestro on your Raspberry Pi. Happy tinkering!

You may also like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.