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.
9. vi
vi Command in Linux
vi is a text editor in Linux, used to view and edit files directly in the terminal.
It's one of the most powerful and widely available editors on Unix/Linux systems.
🔹 Basic Syntax:
vi filename
🔹 Example:
vi notes.txt
👉 This opens (or creates, if not exists) a file named notes.txt for editing.
🔹 Modes in vi:
-
Normal Mode (default when you open
vi)
– For navigation and commands -
Insert Mode
– For typing text
– Pressito enter Insert mode -
Command Mode
– For saving, quitting, searching
– Press:to enter command mode
🔹 Basic Commands:
|
Action |
Key |
|---|---|
|
Enter Insert Mode |
|
|
Save File (Command Mode) |
|
|
Quit |
|
|
Save & Quit |
|
|
Quit without saving |
|
|
Delete a line |
|
|
Copy a line |
|
|
Paste |
|
|
Move up/down |
|
|
Move left/right |
|
🔹 Example Flow:
-
Open a file:
vi hello.txt
-
Press
i→ Enter Insert Mode -
Type:
Hello, this is my first vi file!
-
Press
Esc→ Go back to Normal Mode -
Type
:wq!→ Save and quit
Try with Linux Practice