β So these are SAME:
cd ~
cd /Users/jumptotech
πΉ Correct usage examples
Go to home:
cd ~
Go to Desktop:
cd ~/Desktop
π Expands to:
cd /Users/jumptotech/Desktop
Create file in home:
touch ~/file.txt
πΉ Absolute vs Shortcut
| Type | Example | Meaning |
|---|---|---|
| Absolute | /Users/jumptotech/Desktop |
Full path |
| Shortcut | ~/Desktop |
Same, shorter |
π ~ ONLY works at the beginning
β
Correct:
~/Desktop
β Wrong:
/Desktop/~
/Users/jumptotech/~
πΉ Real DevOps Example
When installing tools:
mv terraform ~/bin/
π Means:
/Users/jumptotech/bin/
π
β~ is a shortcut for your home folder.
Donβt mix it with full paths.β
π₯ Interview answer (short)
π
β~ represents the current userβs home directory. It is a shortcut used instead of writing the full absolute path.β
πΉ 1. Navigation Commands
pwd
π Show current directory
pwd
ls
π List files and folders
ls
ls -l # detailed view
ls -a # show hidden files
cd
π Change directory
cd /home/ubuntu
cd .. # go back one folder
cd ~ # go to home
πΉ 2. File & Directory Management
mkdir
π Create folder
mkdir project
touch
π Create empty file
touch file.txt
cp
π Copy files
cp file.txt backup.txt
cp -r folder1 folder2
mv
π Move or rename
mv file.txt newfile.txt
mv file.txt /home/ubuntu/
rm
π Delete files/folders
rm file.txt
rm -r folder
rm -rf folder # force delete (danger)
πΉ 3. File Viewing
cat
π Show file content
cat file.txt
less
π View large file (scroll)
less file.txt
head / tail
π Show start/end of file
head file.txt
tail file.txt
tail -f log.txt # live logs (VERY IMPORTANT)
πΉ 4. Permissions & Ownership
chmod
π Change permissions
chmod 777 file.txt
chmod +x script.sh
chown
π Change owner
sudo chown ubuntu file.txt
πΉ 5. User Management
whoami
π Current user
whoami
sudo
π Run as admin
sudo apt update
πΉ 6. Package Management (Ubuntu)
apt
π Install/update packages
sudo apt update
sudo apt install nginx
sudo apt remove nginx
πΉ 7. Process & System
ps
π Show processes
ps aux
top
π Live system monitoring
top
kill
π Stop process
kill 1234
πΉ 8. Networking
ping
π Check connectivity
ping google.com
curl
π Call API / URL
curl http://example.com
ssh
π Connect to server
ssh ubuntu@ip-address
πΉ 9. Disk & Storage
df -h
π Disk usage
df -h
du -sh
π Folder size
du -sh *
πΉ 10. Redirection & Output (VERY IMPORTANT)
echo
π Print text
echo "Hello"
>
π Overwrite file
echo "Hello" > file.txt
>>
π Append to file
echo "World" >> file.txt
πΉ 11. Search & Text Processing
grep
π Search text
grep "error" log.txt
find
π Find files
find . -name "file.txt"
πΉ 12. Archive & Compression
tar
π Compress/extract
tar -cvf archive.tar folder/
tar -xvf archive.tar
πΉ 13. History & Help
history
π Show commands history
history
man
π Command manual
man ls
π₯ MOST IMPORTANT (Tell your students)
If they remember only these β they will survive:
ls
cd
pwd
mkdir
touch
cp
mv
rm
cat
tail -f
chmod
sudo
apt
grep
ssh
Top comments (0)