Graduate Program KB

Commonly Used Linux CLI Commands

  • Note: Extra information in parenthesis, is not included part of command
  • List files/folders
    ls
    #(Flags that help)
    -a #(Shows all files, including hidden files)
    -lh #(Shows permissions -l and -h makes it human readable)
  • Change directory/folder
    cd </path/directoryName/>
    cd ~ #(Changes straight to home directory)
  • Make new directory
    mkdir <directoryName>
  • Move a file or renaming a file
    mv <file> <DestinationPath> #(Moves a file into a new directory)
    mv <file> <newFileName> #(Renames a file)
  • Deleting a file
    rm <fileName>
    rm -r <directoryName> #(removes a directory, needs -r for recursive)
  • Archive a directory/folder using Tar gz
    tar --cfz <fileName.tar.gz> <directory>
  • Extracting a Tar
    tar --xzf <file.tar.gz> -C <extractedFolderName>
  • Changing Permissions (Just use this calculator Link)
    chmod +x <file> #(Adds execute permissions)
    #(Can do +xrw or numbers ###)
  • Outputting content of file without editor
    cat <fileName>
  • Quickly creating/editing a file without editing it
    touch <fileName>
    #(Or)
    echo "Whatever text you want in the file" >> <fileName.txt>
    #(>> is appending, > is overwriting)