Practical 2 MonikaSethi
Practical 2 MonikaSethi
Prepared By
2
pwd Command
3
cd (Change Directory) Command
1. Basic Usage
cd directory_name
Example:
cd Documents
🔹 Path:
cd /
🔹 Key Features:
● It contains all system files and directories (like /bin, /etc, /var).
● Accessible only by the root user for critical tasks.
● Modifying system files here without care can break the system.
5
2. Home Directory (/home/username)
🔹 Definition:
● A personal space for each user to store files and settings.
● Every user gets a separate home directory.
🔹 Path:
cd ~
# OR
cd /home/yourusername
# OR
cd
🔹 Key Features:
● Normal users have full control over their home directory.
● Stores personal files, downloads, and configuration files (like .bashrc).
● Safer for regular work compared to /. 6
4. Move Up One Level (..)
cd ..
Example:
cd ..
Example:
cd /var/log
cd /home/user
cd -
8
8. Move to a Relative Path
cd Documents/Work
9
10
mkdir Command
1. mkdir Command (Make Directory)
Basic Usage
mkdir myfolder
Common Options
12
rmdir Command (Remove Directory)
Basic Usage
rmdir myfolder
🔹 This deletes the folder myfolder only if it is empty.
🚨 rmdir cannot remove non-empty directories. If a folder has files inside, use:
rm -r myfolder
13
1. rm (Remove)
✅ Used to delete files and directories
✅ Can remove both empty and non-empty directories
✅ Supports forceful deletion (-f) and recursive deletion (-r)
14
15