Introduction to Basic Commands
What are Basic Commands?
Basic commands are the fundamental instructions that you can give to your Linux operating system through the command line interface. These commands allow you to navigate the filesystem, manage files and directories, and carry out essential administrative tasks.
Opening the Terminal
To start using basic commands, you need to open the terminal. The terminal is a text-based interface that allows you to interact with the operating system. On most Linux distributions, you can open the terminal by searching for "Terminal" in the application menu or by pressing Ctrl + Alt + T.
Navigating the Filesystem
1. The pwd Command
The pwd (print working directory) command displays the path of the current directory you are in.
Example:
2. The ls Command
The ls command lists the contents of the current directory.
Example:
3. The cd Command
The cd (change directory) command allows you to navigate between directories.
Example:
After running cd Documents
, you can use pwd
to confirm you are in the Documents directory:
Managing Files and Directories
1. The touch Command
The touch command creates a new empty file.
Example:
This command creates a new empty file named newfile.txt
.
2. The mkdir Command
The mkdir (make directory) command creates a new directory.
Example:
This command creates a new directory named newdir
.
3. The rm Command
The rm (remove) command deletes files.
Example:
This command deletes the file named newfile.txt
.
4. The rmdir Command
The rmdir (remove directory) command deletes empty directories.
Example:
This command deletes the directory named newdir
, provided it is empty.
Viewing and Editing Files
1. The cat Command
The cat (concatenate) command displays the content of a file.
Example:
This command displays the content of example.txt
.
2. The nano Command
The nano command opens a text editor to create or edit files.
Example:
This command opens example.txt
in the nano text editor.
Getting Help
1. The man Command
The man (manual) command displays the manual page for a command, providing detailed information about its usage.
Example:
This command displays the manual page for the ls
command.
2. The --help Option
Most commands support the --help option to display a brief summary of their usage.
Example:
This command provides a summary of the usage and options available for the ls
command.