How to use them?

| Aug 17, 2024 min read

How to use them?

  1. ls: To list directories and files in the current directory, simply type ls and press Enter. You can also specify a directory as an argument to list its contents.
  2. pwd: Typing pwd and pressing Enter will display the current working directory.
  3. cd: To navigate through directories, use cd followed by the directory path you want to move to. For example, cd /path/to/directory will change the current directory to the specified path.
  4. mkdir: Use mkdir followed by the name of the directory you want to create. For example, mkdir new_directory will create a directory named “new_directory” in the current location.
  5. mv: To move or rename files and directories, use mv followed by the source file/directory and the destination. For moving, you can specify the destination directory. For renaming, you can provide the new name for the file or directory.
  6. cp: To copy files and directories, use cp followed by the source file/directory and the destination. Specify the destination directory to copy to a different location.
  7. rm: To delete files and directories, use rm followed by the file(s) or directory you want to delete. Be cautious with this command as it permanently deletes the specified files or directories.
  8. touch: To create an empty file, type touch followed by the filename. If the file already exists, touch will update its access timestamp.
  9. ln: Use ln to create symbolic links (shortcuts) to other files or directories. Provide the target file/directory as the first argument and the name of the link as the second argument.
  10. cat: To display the contents of a file, use cat followed by the file name. For example, cat myfile.txt will print the contents of “myfile.txt” to the terminal.
  11. clear: Typing clear and pressing Enter will clear the terminal screen, providing a fresh blank slate.
  12. echo: To print text to the terminal, type echo followed by the text you want to display. For example, echo "Hello, World!" will print “Hello, World!” to the terminal.
  13. less: Use less to display file contents one page at a time. For example, less myfile.txt will open “myfile.txt” in a pager where you can scroll through the content.
  14. man: To access manual pages for Linux commands, type man followed by the command you want to learn more about. For example, man ls will display the manual page for the “ls” command.
  15. uname: Typing uname and pressing Enter will print system information, including the operating system name.
  16. whoami: Typing whoami and pressing Enter will display the current user’s username.
  17. tar: To extract or compress files, use tar followed by the appropriate options and file names. For example, tar -xvf archive.tar will extract the files from “archive.tar”.
  18. grep: To search for a specific pattern in files or outputs, use grep followed by the pattern and the file(s) to search. For example, grep "keyword" myfile.txt will search for the “keyword” in “myfile.txt”.
  19. head: Use head followed by the file name to display the first few lines of a file. By default, it shows the first 10 lines, but you can specify
  20. tail: Use tail followed by the file name to display the specified number of lines from the bottom of the file. For example, tail -n 5 myfile.txt will show the last 5 lines of “myfile.txt”.