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.
12. history
history Command in Linux
The history command shows a list of all previously run commands in the terminal.
It’s very useful to recall or repeat past commands.
🔹 Syntax:
history
🔹 Example:
history
👉 Output:
1 ls2 pwd3 cd /home/ashwin4 mkdir test5 history
This shows:
-
Line numbers for each command
-
The exact command you typed earlier
🔹 Useful Options & Examples:
✅ 1. Run a previous command by number
!3
👉 Runs the 3rd command from the history (in this case: cd
/home/ashwin)
✅ 2. Search your command history
history | grep mkdir
👉 Finds all mkdir commands you've used before.
✅ 3. Repeat the last command
!!
👉 Runs the most recent command again.
✅ 4. Clear your command history
history -c
👉 Clears all saved history for the current session.
✅ 5. Save history to a file
history > my_history.txt
👉 Saves your full command history into my_history.txt.
Try with Linux Practice