Basic Linux Commands
- ls – List files and directories in the current directory. Example: lsExplanation: This command will display a list of files and directories in the current location.
- pwd – Print working directory. Example: pwdExplanation: This command shows the path of the current directory you are in.
- cd – Change directory. Example: cd /home/user/documentsExplanation: This command changes the current directory to “/home/user/documents”.
- mkdir – Make directory. Example: mkdir new_folderExplanation: This command creates a new directory named “new_folder” in the current directory.
- rmdir – Remove directory. Example: rmdir empty_folderExplanation: This command deletes an empty directory named “empty_folder” from the current directory.
- cp – Copy files or directories. Example: cp file.txt /path/to/destinationExplanation: This command copies “file.txt” to the specified destination path.
- mv – Move or rename files or directories. Example 1: mv file.txt /path/to/destinationExplanation 1: This command moves “file.txt” to the specified destination path. Example 2:mv old_file.txt new_file.txtExplanation 2: This command renames “old_file.txt” to “new_file.txt”.
- rm – Remove files or directories. Example 1: rm file.txtExplanation 1: This command deletes the file named “file.txt”. Example 2:rm -r folderExplanation 2: This command deletes the “folder” directory and all its contents recursively.
- touch – Create an empty file or update the file’s timestamp. Example 1: touch new_file.txtExplanation 1: This command creates a new empty file named “new_file.txt”. Example 2:touch existing_file.txtExplanation 2: This command updates the timestamp of the “existing_file.txt” without changing its content.
- cat – Concatenate and display the content of files. Example: cat file.txtExplanation: This command displays the content of “file.txt” on the terminal.
- more / less – Display the content of files page by page. Example: less large_file.txtExplanation: This command allows you to view the content of “large_file.txt” page by page, making it easier to read large files.
- head – Display the beginning of a file. Example: head file.txtExplanation: This command shows the first few lines of “file.txt”.
- tail – Display the end of a file. Example: tail file.txtExplanation: This command shows the last few lines of “file.txt”.
- grep – Search for a pattern in files. Example: grep "keyword" file.txtExplanation: This command searches for the word “keyword” in “file.txt” and displays matching lines.
- echo – Print a message or value to the terminal. Example: echo "Hello, World!"Explanation: This command prints the message “Hello, World!” to the terminal.
- chmod – Change file permissions. Example: chmod +x script.shExplanation: This command adds the executable permission to “script.sh”, allowing it to be run as a script.
- chown – Change file ownership. Example: chown user:group file.txtExplanation: This command changes the owner and group of “file.txt” to the specified user and group.
- ps – Display the currently running processes. Example: ps auxExplanation: This command shows a list of all running processes on the system along with additional details.
- kill – Terminate a process. Example: kill PIDExplanation: This command sends a termination signal to the process with the specified PID (Process ID).
- top – Display dynamic real-time information about running processes. Example: topExplanation: This command provides a live view of the system’s processes, updating regularly.
These are just some of the most basic Linux commands. The Linux command line offers a plethora of powerful utilities and options to explore and master.










Leave a Reply
Want to join the discussion?Feel free to contribute!