ssh
: Access a remote computer.
Examples:
$ ssh my_username@my.server.address
$ ssh dcuser@ip-address-at-amazonaws.com
cd
: Change directory.
Examples:
$ cd my_directory/ # move into my_directory/
$ cd .. # go up one directory.
$ cd ~ # go to home directory.
ls
: List items
Examples:
$ ls # list items in current directory.
$ ls . # same as above
$ ls my_directory/ # list items in my_directory
Can be combined with 'flags' or 'modifiers' or 'arguments' to change how the output is viewed.
$ ls -F # show which items are sub-directories in current directory.
$ ls -l . # show details about each item under the current directory.
$ ls -a my_directory/ # show all items, including hidden ones, under my_directory/
pwd
: Print current working directory.
Examples:
$ pwd # prints current working directory.
Shortcuts
..
: Directory one level above.
Examples:
# cd
$ cd .. # move into directory one level up.
$ cd ../another_directory/ # move into sibling directory.
# ls
$ ls ~ # list items in home directory.
$ ls -F ~ # list items in home directory, highlighting directories with '/'.
cat
, head
and tail
, less
: Viewing files in the terminal window.
Examples:
# cat
$ cat my_file.txt
# head
$ head -5 my_file.txt # display the first 5 lines
# tail
$ tail -20 my_file.txt # display the last 20 lines
# less
$ less my_file.txt
less
has a six crucial commands:
g
: Go to beginning of fileG
: Go to end of filespacebar
: go forwardsb
: go backwardsq
: quit/
: search
This is in addition to the regular up and down arrow keys.
cp
, mv
, rm
: copy, move and remove items in filesystem
Examples:
# cp
$ cp my_file.txt my_copied_file.txt
# mv
$ mv my_file.txt ../my_other_directory/. # move my_file.txt to a sibling directory.
$ mv my_file.txt my_renamed_file.txt
# rm
$ rm my_file.txt # remove my_file.txt
$ rm -r my_directory/
mkdir
: Make a directory.
Examples:
$ mkdir my_directory # makes a directory called `my_directory`.
nano
: Opens up a shell-based text editor.
Use this only in a pinch, when it's impossible or inconvenient to use your favourite text editor.
Examples:
$ nano my_new_textfile.txt
Look at the bottom of the nano
text editor interface to see what other commands are possible. ^
is shortcut for Control-key
.