Skip to content

Instantly share code, notes, and snippets.

@19h47
Last active January 23, 2018 03:10
Show Gist options
  • Save 19h47/5b9bf949d999a47426df6443dbfb2bad to your computer and use it in GitHub Desktop.
Save 19h47/5b9bf949d999a47426df6443dbfb2bad to your computer and use it in GitHub Desktop.
Command

cd

The cd command is used to change the current directory.

cd stand for change directory

cd path/of/directory

To move up by one directory you can hit cd .. (Source)

ls

The ls command list all files of a type other than directory, found in the current directory.

ls stand for list segments

ls

man

The man command display the online manual pages. You can specify a section as parameter. The section is normally the command, function or file name.

man stand for manual.

man name_of_command

To exit the manual you can hit q, :q, Q, :Q or ZZ.

mkdir

The mkdir command is used to create a new directory. The directory would be create in the current directory.

mkdir stand for make directories.

mkdir name-of-directory

rmdir

The rmdir command is used to remove an empty directory.

rmdir stand for remove directories.

rmdir name-of-directory

We can pass an -p option. In this case each directory argument will be treated as a single path and will be removed if they are empty.

rmdir -p name/of/directory

mv

The mv command is used to move a file into a given directory.

mv stand for move.

mv name_of_file name/of/directory/destination/

We can use mv to simply rename a file without changing file's location. (Thanks to Gary Ash for the tips.)

mv old-file-name new-file-name

open

On macOS, the open command is used to open a file or a directory. (Thanks to Ian Kirker for the correction.)

open name-of-file
@elementbound
Copy link

Nice so far, I have a few things to add:

  • You can also use mv to move folders: mv your_folder destination_folder
  • You can also use mv to rename files/folders: mv original_name new_name
  • You can use rm to remove directories ( by doing a recursive remove ): rm -r directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment