Linux Command Line Basics¶
Introduction¶
The Linux Command Line (Terminal, Shell) is a powerful tool that allows users to interact with the system using text-based commands. It provides greater control, automation capabilities, and flexibility compared to graphical user interfaces (GUIs). This tutorial covers essential Linux commands to help you efficiently navigate and manage the command line.
Navigating the File System¶
Case Sensitivity Matters!
Linux differentiates between uppercase and lowercase letters. Commands such as PWD
instead of pwd
will cause errors or unexpected behavior. Always ensure correct capitalization.
Display the Current Directory¶
To check your current working directory, use:
- Displays the current working directory.
Changing Directories¶
- Navigate to a specific directory:
-
Moves to the specified directory.
-
Move up one level:
-
Moves up one directory level.
-
Return to the home directory:
- Returns to the user’s home directory.
Absolute vs. Relative Paths!
- Relative Paths:
cd Documents
changes the directory relative to the current location. - Absolute Paths:
cd /etc
always goes to the same location, regardless of your current directory.
Managing Files and Folders¶
Creating Files¶
- Create an empty file:
-
Creates a new empty file.
-
Create a file with content:
- Creates a new file and writes "Hello World" into it.
Viewing Files¶
- Display the contents of a file:
- Displays the content of the specified file.
Creating Folders¶
-
Creates a new folder with the specified name.
-
Create multiple nested directories at once:
- Creates a hierarchical directory structure in one command.
Listing Directory Contents¶
- Display all files and folders in the current directory:
- Lists the contents of the current directory.
Moving and Renaming Files and Folders¶
- Move a file:
-
Moves the file to the specified folder.
-
Rename a file:
-
Renames the file.
-
Move a folder and its contents:
- Moves the entire folder and its contents.
Deleting Files and Folders¶
- Delete a file:
-
Permanently deletes the specified file.
-
Delete an empty folder:
-
Deletes the specified folder if it is empty.
-
Delete a folder and all its contents:
- Deletes the folder and all files within it recursively.
Retrieving System Information¶
- Display the current IP address:
-
Shows network and IP information.
-
Display running processes:
-
Displays a list of currently running processes.
-
Terminate a process:
- Forcefully ends all
nano
processes.
Download Cheat Sheet¶
Conclusion¶
The Linux Command Line is a useful tool for system management, automation, and file operations. With these fundamental commands, you can work more efficiently. A great way to develop CLI skills is by experimenting in a test environment.