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.
10. cat
cat Command in Linux
cat stands for "concatenate", but it’s commonly used to view the contents of a file.
🔹 Basic Syntax:
cat [options] filename
🔹 Most Common Uses & Examples:
✅ 1. View contents of a file
cat file.txt
👉 Displays the content of file.txt in the terminal.
✅ 2. Create a new file using cat
cat > newfile.txt
Then type your content:
Hello, this is a new file.
Press Ctrl
+ D to save and exit.
✅ 3. Append content to an existing file
cat >> file.txt
Type new content and press Ctrl
+ D.
✅ 4. Combine multiple files into one
cat file1.txt file2.txt > combined.txt
👉 Combines file1.txt and file2.txt into combined.txt.
✅ 5. Show line numbers
cat -n file.txt
👉 Displays the file with line numbers:
1 This is line 12 This is line 2
🔹 Summary Table:
|
Task |
Command |
|---|---|
|
View file |
|
|
Create file |
|
|
Append file |
|
|
Combine files |
|
|
Line numbers |
|
Try with Linux Practice