Basic Linux Commands

  1. ls – List files and directories in the current directory. Example: ls Explanation: This command will display a list of files and directories in the current location.
  2. pwd – Print working directory. Example: pwd Explanation: This command shows the path of the current directory you are in.
  3. cd – Change directory. Example: cd /home/user/documents Explanation: This command changes the current directory to “/home/user/documents”.
  4. mkdir – Make directory. Example: mkdir new_folder Explanation: This command creates a new directory named “new_folder” in the current directory.
  5. rmdir – Remove directory. Example: rmdir empty_folder Explanation: This command deletes an empty directory named “empty_folder” from the current directory.
  6. cp – Copy files or directories. Example: cp file.txt /path/to/destination Explanation: This command copies “file.txt” to the specified destination path.
  7. mv – Move or rename files or directories. Example 1: mv file.txt /path/to/destination Explanation 1: This command moves “file.txt” to the specified destination path. Example 2: mv old_file.txt new_file.txt Explanation 2: This command renames “old_file.txt” to “new_file.txt”.
  8. rm – Remove files or directories. Example 1: rm file.txt Explanation 1: This command deletes the file named “file.txt”. Example 2: rm -r folder Explanation 2: This command deletes the “folder” directory and all its contents recursively.
  9. touch – Create an empty file or update the file’s timestamp. Example 1: touch new_file.txt Explanation 1: This command creates a new empty file named “new_file.txt”. Example 2: touch existing_file.txt Explanation 2: This command updates the timestamp of the “existing_file.txt” without changing its content.
  10. cat – Concatenate and display the content of files. Example: cat file.txt Explanation: This command displays the content of “file.txt” on the terminal.
  11. more / less – Display the content of files page by page. Example: less large_file.txt Explanation: This command allows you to view the content of “large_file.txt” page by page, making it easier to read large files.
  12. head – Display the beginning of a file. Example: head file.txt Explanation: This command shows the first few lines of “file.txt”.
  13. tail – Display the end of a file. Example: tail file.txt Explanation: This command shows the last few lines of “file.txt”.
  14. grep – Search for a pattern in files. Example: grep "keyword" file.txt Explanation: This command searches for the word “keyword” in “file.txt” and displays matching lines.
  15. echo – Print a message or value to the terminal. Example: echo "Hello, World!" Explanation: This command prints the message “Hello, World!” to the terminal.
  16. chmod – Change file permissions. Example: chmod +x script.sh Explanation: This command adds the executable permission to “script.sh”, allowing it to be run as a script.
  17. chown – Change file ownership. Example: chown user:group file.txt Explanation: This command changes the owner and group of “file.txt” to the specified user and group.
  18. ps – Display the currently running processes. Example: ps aux Explanation: This command shows a list of all running processes on the system along with additional details.
  19. kill – Terminate a process. Example: kill PID Explanation: This command sends a termination signal to the process with the specified PID (Process ID).
  20. top – Display dynamic real-time information about running processes. Example: top Explanation: 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.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.