Progress: 0/62 (0%)

πŸ“ Basic Linux Commands

Basic Linux Commands

These commands are your toolbox for controlling everything from files to folders right from the terminal. Linux is built around commands, not clicks. Each command is like a mini sentence that tells the OS what to do β€” create something, move it, delete it, or view it.

ls β€” List Files and Folders

Shows the contents of the current directory.

ls
πŸ“Œ Example:
Desktop  Documents  Downloads  Pictures

Common options:

  • ls -l β†’ long listing (shows permissions, size, date)
  • ls -a β†’ includes hidden files (files starting with a dot .)
  • ls -lh β†’ human-readable file sizes (e.g., KB, MB)

Like opening a drawer to see everything inside neatly.

pwd β€” Print Working Directory

Displays where you are right now.

pwd
πŸ“Œ Example:
/home/master/Documents

Like checking your current address on a map.

cd β€” Change Directory

Moves you between folders.

cd Documents

Go one folder up:

cd ..

Go to your home directory:

cd ~

Like walking between rooms in a house.

mkdir β€” Make Directory

Creates a new folder.

mkdir Projects

Create multiple folders at once:

mkdir folder1 folder2 folder3

Like creating a new shelf to store items.

rmdir β€” Remove Directory

Deletes empty folders only.

rmdir old_folder

To remove a folder with files inside, you'll need rm -r (explained below).

rm β€” Remove Files or Folders

Deletes files (and folders if used with options).

Delete a file:

rm notes.txt

Delete a folder and its contents:

rm -r Projects

Force delete (no confirmation):

rm -rf temp

⚠️ Be careful! rm -rf / will wipe your entire system β€” never do that!

Like throwing files into a shredder β€” once gone, they're gone.

cp β€” Copy Files or Folders

Copies files from one place to another.

cp file.txt /home/master/Documents/

Copy folders (add -r for recursive):

cp -r folder1 folder2

Like photocopying a document and placing it somewhere else.

mv β€” Move or Rename Files

Moves or renames files and folders.

Move file:

mv file.txt /home/master/Desktop/

Rename file:

mv oldname.txt newname.txt

Like moving an item to another shelf β€” or just changing its label.

cat β€” View File Content

Displays the content of a text file right in the terminal.

cat notes.txt

You can also combine multiple files:

cat file1.txt file2.txt

Like opening a notebook to quickly read what's inside.

less / more β€” View Large Files Page by Page

When files are too long for one screen:

less bigfile.txt
  • Press Space β†’ to go down
  • Press q β†’ to quit

Like scrolling through a long e-book, one page at a time.

head & tail β€” View Beginning or End of a File

Show first 10 lines:

head notes.txt

Show last 10 lines:

tail notes.txt

For real-time updates (like logs):

tail -f logfile.txt

head β†’ first page of a diary. tail β†’ last page of the diary.

touch β€” Create an Empty File

Quickly create a blank file:

touch newfile.txt

Or update its modification time:

touch existingfile.txt

Like putting a new empty sheet of paper on your desk.

echo β€” Print a Message or Save Text to a File

Print text:

echo "Hello, Linux!"

Save text into a file:

echo "This is my note" > note.txt

Like writing a quick sticky note.

man β€” Manual Pages

Shows help and usage details for any command.

man ls

Use q to quit the manual.

Like asking Linux, "Hey, what exactly does this command do?"

history β€” Shows Previous Commands

Lists all the commands you've used in this session.

history

You can reuse one by number:

!25

Like scrolling through your browser history.

Real-Life Pro Tip

You can chain commands using &&:

mkdir test && cd test && touch file.txt

This means: Create a folder, Move into it, Create a file β€” all in one line!

Your Linux Command Toolkit

With these, you can manage almost everything from the terminal β€” files, folders, and navigation.

Real-life analogy

Think of these basic commands like the essential tools in a Swiss Army knife:

πŸ“ ls β†’ The magnifying glass to see what's inside
πŸ“ pwd β†’ The compass to know where you are
🚢 cd β†’ The walking tool to move around
πŸ—οΈ mkdir β†’ The hammer to build new structures
βœ‚οΈ rm β†’ The scissors to cut and remove
πŸ“‹ cp β†’ The photocopier to duplicate
🚚 mv β†’ The moving truck to relocate
πŸ“– cat β†’ The quick-read viewer

Each tool is simple on its own, but together they give you incredible control over your digital workspace!

Β© All Rights preserved with Deep Cyber

Cookie Policy

This website uses cookies to ensure you get the best experience on our website.

Go It!