DEV Community

Sreekanth Kuruba
Sreekanth Kuruba

Posted on

10 Essential Linux Commands Every Beginner Must Know

Most beginners struggle with Linux not because it’s hard — but because they try to learn too much at once.

The truth is, you only need a small set of commands to start working confidently in DevOps, cloud computing, and system administration.

In this article, we’ll go through 10 essential Linux commands that will help you get started quickly.

Once Linux “clicks”, everything from servers to deployments suddenly starts making sense.


Linux Explained Using a Smartphone Analogy (Android Style)

Think of your phone

Your smartphone runs an operating system (like Android or iOS). In the same way, Linux is an operating system for computers.

Here’s how they match:

  • Android / iOS = Linux (the operating system)
  • Apps (Chrome, WhatsApp, Games) = Programs on Linux
  • Settings app = System configuration tools
  • Storage (photos, files) = Linux folders like /home, /data
  • Permissions popup = Linux file permissions (read, write, execute)
  • Restart phone = Rebooting the Linux system

What this means in simple terms

On your phone, you don’t directly see how everything works internally. You just open apps and use them.

Linux works in the same way.

You don’t directly interact with the core system (kernel). Instead, you use:

  • Applications (software)
  • Terminal commands
  • System tools

Real-life examples

Here’s how phone actions map to Linux:

  • Installing an app → Installing software in Linux
  • Closing a frozen app → Killing a process in Linux
  • Low storage warning → Disk space issue (df -h command)

Key idea to remember

You don’t see the system—you just use it.

Just like a smartphone hides its internal complexity, Linux hides its core operations and lets users interact in a simple way.


One-line summary

Linux is the hidden operating system inside devices that powers apps, files, and hardware—just like Android does on a smartphone.


1. ls — List Files and Directories

ls
ls -l     # Detailed list (permissions, size, date)
ls -a     # Show hidden files
ls -la    # Most commonly used combination
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used daily to check files, permissions, and directory contents.


2. cd — Change Directory

cd /home/user/documents
cd ..     # Go back one directory
cd ~      # Go to home directory
cd -      # Go to previous directory
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used to navigate between directories in servers and systems.


3. pwd — Print Working Directory

pwd
Enter fullscreen mode Exit fullscreen mode

Shows your current location in the filesystem.

Real-world usage:
Used to verify current working path.


4. mkdir — Make Directory

mkdir myfolder
mkdir -p dir1/dir2/dir3   # Create nested directories
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used to create project folders or directory structures.


5. rm — Remove Files or Directories

⚠️ Dangerous command — can delete everything permanently if misused.

rm file.txt
rm -r foldername          # Remove directory
rm -rf foldername         # Force remove (very dangerous)
rmdir foldername          # To remove only an empty directory
Enter fullscreen mode Exit fullscreen mode

Safer alternative with confirmation:

rm -ri foldername
Enter fullscreen mode Exit fullscreen mode
  • -i asks before deleting each file.

Tip: Always use ls first before deleting anything.
Tip: In Linux, there is no recycle bin in most servers. Deleted files are usually gone permanently.

Real-world usage:
Used to delete unwanted files or clean up space.


6. cp — Copy Files and Directories

cp file.txt file_backup.txt
cp -r folder1 folder2     # Copy folder
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used for backups before modifying files.


7. mv — Move or Rename Files

mv file.txt /home/user/docs/
mv oldname.txt newname.txt   # Rename file
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used to move logs, configs, or rename files.


8. cat — View File Content

cat filename.txt
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used to quickly view file contents like logs and configuration files.


9. touch — Create Empty File

touch newfile.txt
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used to create log or config files.


10. echo — Print Text / Write to File

echo "Hello World"
echo "Hello Linux" > file.txt     # Create/overwrite file
echo "New line" >> file.txt       # Append to file
Enter fullscreen mode Exit fullscreen mode

Real-world usage:
Used to write data into files or test outputs.


Beginner Basics (Highly Recommended)

What is a Terminal?

The terminal is a text-based interface used to interact with the Linux operating system using commands.


Basic Command Structure

Most Linux commands follow this format:

command [options] [arguments]
Enter fullscreen mode Exit fullscreen mode

Example

ls -la /home/user
Enter fullscreen mode Exit fullscreen mode
  • ls → command
  • -la → options
  • /home/user → argument

Linux is Case-Sensitive

Linux treats uppercase and lowercase differently.

file.txt
FILE.txt
Enter fullscreen mode Exit fullscreen mode

These are considered two different files.


Paths in Linux

Absolute Path

Starts from the root directory.

cd /home/user/documents
Enter fullscreen mode Exit fullscreen mode

Relative Path

Starts from your current location.

cd documents
Enter fullscreen mode Exit fullscreen mode

Useful Beginner Commands

man ls       # Show manual for any command
ls --help   # Quick help
whoami       # Show current logged-in user
id           # Shows user and group IDs
uname -a    # Display system information
history      # Show previously used commands
Enter fullscreen mode Exit fullscreen mode

Keyboard Shortcuts Every Beginner Should Know

Ctrl + C     # Stop a running command
Ctrl + Z     # Pause/suspend a running process
Enter fullscreen mode Exit fullscreen mode

Bonus: sudo — Run Commands as Administrator

sudo apt update
sudo mkdir /newfolder
sudo chown user:group file.txt
Enter fullscreen mode Exit fullscreen mode
  • sudo stands for “SuperUser DO” and runs commands with admin (root) privileges.
  • Gives you temporary admin rights
  • You will use it very often for installing packages and editing system files

Warning: Use sudo only when necessary.


Why These Commands Matter

These commands form the foundation of working with Linux.

Almost every advanced Linux task — DevOps, cloud computing, scripting, server management — builds on these basics.


Summary

You learned:

  • Navigation → ls, cd, pwd
  • File Management → mkdir, cp, mv, rm, touch
  • File Content → cat, echo
  • Administrator access → sudo
  • System & User Info -> whoami, id, uname -a, history

Next Steps:

After mastering these basics, next learn:
Linux File System Explained Simply,(/, /home, /etc, /var, etc.)

Top comments (0)