Bash File Manipulation/Navigation

  • ls [-la]

    ‘list’ … lists the contents of the directory you’re in. The [-l] flag adds detailed info about the files/folders in the directory. The [-a] flag shows hidden files.

  • cd [name of folder to open]

    ‘change directory’ … the main way you navigate the filesystem.

  • mkdir [name]

    ‘make directory’

  • rm [-r] [name]

    ‘remove’ … deletes a file. to delete a directory you need the [-r] flag. It recursively deletes the directory and all sub-directories.

  • mv [source] [destination]

    ‘move’ AND rename. It can move a file/directory and at the same time rename it.

  • ln [-s] [source] [name of link]

    ‘link’. Creates a shortcut to a file or folder in the directory you’re in. Can prevent a lot of extra typing. Always use the -s flag. It keeps the links symbolic. I don’t know what that means … but it’s the only way you can create a shortcut to a folder.

  • du -sh [directoryname]

    Calculates the size of a directory. -s = summary, -h = human readable.

  • df -h

    Calcualtes disk usage. -h = human readable.

Leave a Reply