INLS161-001 | Spring 2018

Basics: Command Line Cheat Sheet


go Back to Server Page

These are my class lesson plan notes. I have posted them here for your convenience. We may not get finished with these today.

All of these commands can be studied in more depth by reading the Server Session Preparation Materials or links on that page below the Task box.

What is the Bash Shell?

GIT BASH prompt (BASH stands for Born Again SHell)
_________________________________________________________________________________
   1        2                   4a
   |        |                    |
   username@computername MINGW64 ~
   $
   |
  5a

 MINGW64 is just the brand of the terminal, ignore it

MacTerminal:
   1        2           3 4a 5a
   |        |           |  |  |
a) username@computername:  ~  $
b) username@computername:  /  #
                           |  |
                          4b 5b

1 )       User Name
2 )       Computer Name
3 )  :    specific to mac Terminal
4a)  ~    means home (user) directory
4b)  /    means root directory
5a)  $    means normal mode; normal permissions
5b)  #    your are logged in as root; dangerous!

SYNTAX
_________________________________________________________________________________

How syntax works (Expanded for ease of understanding):

command  applies to:  directory
      |                       |    
     cd                  ~/.ssh

command  applies to:   filename   applies to: new filename
      |                       |                          |
     mv              index.html                  home.html  (careful! This overwrites home.html if it exits)


command  applies to:   filename   applies to:  existing directory  (and current or new filename)
     ||                       |                                 |    
     mv            portrait.jpg              images/portrait2.jpg


COMMANDS
_________________________________________________________________________________

pwd               # see your present working directory
touch (filename)  # create a new file
clear             # clears the screen by moving it up, does not delete
cd filename       # change directory
cd directoryname  # will autocomplete to the change in file name
up arrow          # cycle through commands
down arrow        # cycle through commands
cd ..             # move up a directory
cd /              # move to the root directory
cd ~              # go to the home directory
cd -              # go to the previous directory we just came from
cd ../..          # move up two directories
cd ~/.ssh         # move into the user directory with a specific subdirectory

ls                # list files and directories
ls -a             # list all files including hidden files
ls -l             # list long format
ls -la            # list all files and in long format
cp one two        # copy
mv                # move and rename
rm                # remove file (delete) NO UNDO FOR THIS!!! won't remove a directory
rm *.jpg          # remove all files ending in .jpg
rm -r             # remove recursively. Use this to delete directory and contents
mkdir             # make a directory
cat               # see two or more files, or use it to
                    just view one file (like our ssh public key)
|                 # pipe command; runs more that one command at once

>              # used with the cat command to create one file out of two
                    Example: cat file file2 > file3

EDITORS
_________________________________________________________________________________
vi or vim         #  vim command line editor
nano              # nano command line editor


more                     # see the link below
less                     # see the link below
head                     # see the link below
tail                     # see the link below
https://2buntu.com/articles/1491/viewing-text-files-on-linux-cat-head-tail-more-and-less/

Instructor

Lawrence Jones

Office hours by appointment.