Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Terminal (CLI) secrets

Command Line basics

$ ls -a     # lists all contents of a directory, including hidden files and directories
$ ls -l     # lists all contents in long format
$ ls -t     # orders files and directories by the time they were last modified
Multiple options can be used together, like ls -alt
From the command line, you can also copy, move, and remove files and directories:
$ cp        # copies files
$ mv          # moves and renames files
$ rm          # removes files
$ rm -r       # removes directories

Command Line secrets

Speed up your workflow with these tricks
$ sudo !!                     # Sudo the previous typed command
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
$ cd `!!`                     # Use previous output in new command
$ Ctrl+A                      # Move caret to front of current line
$ mkdir new && cd new         # Use '&&' to combine commands in 1 line
$ cat filename.txt            # View contents of file in your terminal
$ top                         # View current system processes
$ python -m SimpleHTTPServer  # Launch server of current directory
$ echo $PATH | tr ':' '\n'    # Display $PATH list on multiple lines
$ ps aux | grep apache        # Display current Apache processes
$ kill -9 12345               # Kill process id 12345
$ tail -f <filename>          # Print live file changes to terminal (useful for log files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.