Back to DevOps Series
All basic commands:

All basic commands:

  1. man Used to see help/manual of a command. Example: man ls
  1. ls Shows files and folders. Example: ls
  1. pwd Shows current directory path. Example: pwd
  1. cd Change directory. Example: cd Documents
  1. ls and ls -a ls → normal files ls -a → shows hidden files Example: ls -a
  1. ls -l Shows detailed file info. Example: ls -l
  1. ls -al Shows detailed + hidden files. Example: ls -al
  1. ls -alh Shows size in KB/MB (easy to read). Example: ls -alh
  1. ls -alht Sort files from newest to oldest. Example: ls -alht
  1. ls -alhtr Sort files from oldest to newest. Example: ls -alhtr
  1. ls -l --sort=time Sort by time (newest first). Example: ls -l --sort=time
  1. ls -l --sort=time -r Sort by time (oldest first). Example: ls -l --sort=time -r
  1. cd .. and cd . cd .. → go one folder up cd . → stay in same folder Example: cd ..
  1. cd / and cd ~ cd / → go to root directory cd ~ → go to home directory Example: cd ~
  1. mkdir Create a folder. Example: mkdir myFolder
  1. Touch
    1. Create a new empty file.
      If the file already exists, the touch command does not change its contents—it only updates the file's last modification time.
      Example:
      Loading...
      What happens?
      • If myFile.txt does not exist → A new empty file named myFile.txt is created.
      • If myFile.txt already exists → The file remains the same, but its last modification timestamp is updated.
       
  1. Creating Multiple Directories Using mkdir
    1. The mkdir command allows you to create one or more directories at the same time. In the example below, three directories—comedy, action, and horror—are created with a single command. Running ls confirms that all the directories were created successfully.
      notion image
 
  1. Creating Nested Directories Using mkdir -p
    1.  
      The -p option allows you to create an entire directory structure in a single command. In this example, mkdir -p kids/animation/2010 creates the kids directory, followed by the animation subdirectory and the 2010 directory. The ls, cd, and pwd commands are then used to verify that the directory hierarchy was created successfully.
       
      notion image