Skip to content

1. File & Directory Management

  • ls – list files ls ls -l # detailed ls -a # include hidden
  • cd – change directory cd /path/to/folder cd .. # up cd ~ # home
  • cp – copy files cp file1.txt file2.txt cp -r folder1/ folder2/ # copy folder recursively
  • mv – move/rename files mv file1.txt /tmp/ mv oldname.txt newname.txt
  • rm – remove files/folders rm file.txt rm -r folder/ # remove folder recursively rm -f file.txt # force delete
  • mkdir – make directory mkdir new_folder mkdir -p path/to/folder # create parent folders
  • rmdir – remove empty directory rmdir old_folder
  • touch – create empty file or update timestamp touch file.txt
  • cat – view file content cat file.txt
  • tree – display directory tree tree tree -a # include hidden files

2. Disk & File System

  • df – disk space usage df -h # human readable
  • du – folder/file size du -sh folder/ du -sh * # size of all items
  • mount / umount – mount/unmount drives mount /dev/sdb1 /mnt/usb umount /mnt/usb
  • chmod – change permissions chmod 755 script.sh chmod +x script.sh # make executable
  • chown – change owner chown user:group file.txt
  • ln – create symbolic/hard links ln -s target link_name # symbolic link ln file1 file2 # hard link

3. System Info & Management

  • uname – system info uname -a
  • whoami – current user whoami
  • uptime – system uptime uptime
  • top / htop – processes top htop
  • ps – process snapshot ps aux ps -ef | grep python
  • kill / killall – stop processes kill 1234 killall firefox
  • df / du – disk usage info df -h du -sh folder/
  • date / timedatectl – check/set date and time date sudo timedatectl set-time "2025-09-21 12:00:00"
  • shutdown / reboot – power commands sudo shutdown -h now sudo reboot

4. Networking

  • ping – check connectivity ping google.com ping -c 4 google.com # send 4 packets
  • ifconfig / ip addr – network interfaces ifconfig ip addr
  • netstat / ss – network connections netstat -tuln ss -tuln
  • traceroute – route packets traceroute google.com
  • nslookup / dig – DNS query nslookup google.com dig google.com

5. File Searching

  • find – search files/folders find /path -name "*.txt" find . -type d -name "backup"
  • grep – search text inside files grep "hello" file.txt grep -r "error" /var/log grep -i "warning" file.txt
  • locate – fast file search (uses database) locate file.txt

6. Archive & Compression

  • tar – archive and extract tar -cvf archive.tar folder/ tar -xvf archive.tar tar -czvf archive.tar.gz folder/ tar -xzvf archive.tar.gz
  • zip / unzip – compress/uncompress zip archive.zip file1 file2 unzip archive.zip
  • gzip / gunzip – compress single file gzip file.txt gunzip file.txt.gz

7. Package Management (example: Debian/Ubuntu)

  • apt – install, update, remove sudo apt update sudo apt install package_name sudo apt remove package_name sudo apt upgrade
  • dpkg – manage local packages dpkg -i package.deb dpkg -r package_name

8. Bash Scripting Basics

  • Variables name="John" echo "Hello $name"
  • Conditionals if [ -f "file.txt" ]; then echo "File exists" else echo "No file" fi
  • Loops for i in 1 2 3; do echo "Number $i" done
  • Functions myfunc() { echo "Hello $1" } myfunc World
  • Read input read -p "Enter name: " name echo "Hello $name"

Leave a Reply

Your email address will not be published. Required fields are marked *