Linux Basic Commands
Completion requirements
Linux provides a set of powerful and commonly used commands to interact with the system efficiently. The
Linux provides a set of powerful and commonly used commands to interact with the system efficiently. The cd command is used to change directories, while ls lists the contents of a directory. To clear the terminal screen, the clear command is used. The mkdir command helps create new folders, and pwd shows the current working directory. The rm command is used to remove files or directories, and touch is used to create empty files. To edit or view text files directly in the terminal, vi is a powerful editor. The / symbol represents the root directory, which is the top level of the Linux filesystem. To manage users, adduser is used to create a new user, and userdel is used to delete an existing one. The history command displays a list of previously executed commands, allowing users to track or reuse them easily. These commands form the foundation for working effectively in a Linux environment.
6. rm
rm stands for remove.
It is used to delete files and directories in Linux.
⚠️ Be careful: Once deleted with rm, files cannot be recovered easily.
🔹 Basic Syntax:
rm [options] [file_or_directory]
🔹 Examples:
✅ 1. Remove a single file
rm file.txt
👉 Deletes file.txt from the current directory.
✅ 2. Remove multiple files
rm file1.txt file2.txt
👉 Deletes both files at once.
✅ 3. Remove an empty directory (use -d)
rm -d empty_folder
👉 Deletes an empty folder.
✅ 4. Remove a non-empty directory (use -r or -rf)
rm -r myfolder
👉 Recursively deletes the folder and everything inside it.
Use -f to force delete (no confirmation):
rm -rf myfolder
⚠️ Dangerous! This will delete everything inside without asking.
🔹 Practice Example:
mkdir testfoldertouch testfolder/file1.txtrm -r testfolder
👉 This creates a folder, adds a file, and then deletes the whole folder.
Try with Linux Practice