Tutorial 1

Linux Commands

Master essential Linux commands with interactive examples.

1 pwd — Print Working Directory

Displays the current directory path you're working in.

bash
pwd

/home/tom

2 ls — List Directory Contents

List files and directories. Common flags:

bash
ls -la
ls -l

Long format with details

ls -a

Show hidden files

ls -lh

Human-readable sizes

ls -R

Recursive listing

3 cd — Change Directory

Navigate between directories.

bash
cd /var/www/html
cd ~

Go to home directory

cd ..

Go up one level

cd -

Go to previous directory

cd /

Go to root directory

4 mkdir — Make Directory

Create new directories.

bash
mkdir myproject
mkdir -p projects/website/assets

Create nested directories with -p (parent) flag

5 touch — Create Empty Files

Create empty files or update timestamps.

bash
touch index.html style.css app.js

6 cp — Copy Files & Directories

Copy files and directories.

bash
cp file.txt backup.txt
cp -r project/ project-backup/

7 mv — Move & Rename

Move or rename files and directories.

bash
mv file.txt /path/to/new/location/
mv oldname.txt newname.txt

8 rm — Remove Files

Remove files and directories. Use with caution!

bash
rm file.txt
rm -rf directory/

Warning: rm -rf permanently deletes files without sending them to trash. Always double-check before running.

9 cat — Concatenate & Display

View file contents or combine multiple files.

bash
cat file.txt
cat file1.txt file2.txt > combined.txt

10 grep — Search Text

Search for patterns in files using regular expressions.

bash
grep "error" log.txt
grep -r "TODO" --include="*.py" .
grep -i

Case-insensitive search

grep -n

Show line numbers

grep -v

Invert match (exclude)

grep -c

Count matching lines

11 chmod — Change Permissions

Modify file permissions (read, write, execute).

bash
chmod +x script.sh
chmod 755 file.txt
chmod -R 644 public/

12 chown — Change Ownership

Change file owner and group.

bash
sudo chown tom:tom file.txt
sudo chown -R www-data:www-data /var/www/

13 ps — Process Status

View running processes.

bash
ps aux
ps aux | grep nginx

14 top / htop — System Monitor

Real-time view of system processes and resource usage.

bash
top
htop  # Install with: sudo apt install htop

15 df / du — Disk Usage

Check disk space and directory sizes.

bash
df -h
du -sh /home/tom/*

Great job!

You've learned the 15 most essential Linux commands. Practice makes perfect!

Home Buy Me a Beer