Introduction to Unix

General Information Commands

date           display the current date and time.
who           show login name, terminal name, and login time for each user who is logged in.
whoami      display your login name.
who am i    display more information about your login.
finger         display information about users.  By itself, just displays info about users logged in.
other forms: finger username    or     finger username@address

File Information Commands

ls        display the names of files in a directory. Some options are:
                -l      long format
                -a      list all files, including invisible files (files whose
                        names begin with a period (.))
                -t      sort the file list by time last modified (most recent
                        first).
wc       count the number of lines, words and characters in one or more files. Options are:
                -l      count lines
                -w      count words
                -c      count characters

Commands for Displaying Files

cat
(short for catenate, a form of concatenate) display the contents of one or more files
more
display the contents of one or more files, one screenful at a time. (Press the space bar to go to the next screen.enter q to terminate the display.  You can also search forward for text by using /searchtext)
less      similar to more but you can scroll backwards using b
head    display the first ten lines of a file
tail       display the last ten lines of a file

Commands for Manipulating Files

cp        make a copy of a file (caution! will overwrite any existing file of the new name) form: cp sourcefile newfile
mv       rename (move) a file (caution! will overwrite any existing file of the new name)
                form: mv oldfilename newfilename
Note: Using the -i option with cp or mv will cause the system to query you, if the newfilename already exists.
 
mkdir      create a directory under the current directory.  form:   mkdir directoryname
rm           delete (remove) one or more files
        form:         rm filenames
                examples: rm x.[1-4]
                          rm trees marbles
chmod     change mode.  Change file permissions.
     examples:

          chmod u+w file1         add write permission for the user to file1
          chmod g+x file1         add execute permission for the group to file1
          chmod o-r file1         remove read permission for the world from file1

Commands for Comparing Files

cmp        compare two files, displaying the location of the first difference
                form:         cmp filel file2
diff         compare two files, displaying all differences
                form:         diff file1 file2
Following are metacharacters (wild cards) for specifying filenames for many commands.
*               match any zero or more characters
?               match any single character
[set]           match any single character in the set, as
                [a-z] match any lower case character
                [0-9] match any numeric character
                [CcDd] match capital C or D or lower case c or d
Note: The Shell's expansion of filenames before passing them to the command is called "globbing".
 

Process management commands

ps           show all of  your processes on that machine by process ID number (pid)
kill -9      kill one of your processes.    form:   kill -9 pid     where pid is the number of the process
&           placed at the end of a command line, executes that command as a job in the background
jobs        display a list of all of your jobs by job number
fg           move a job from background to foreground (ie, make it active)
bg          show jobs in the background

 
 
 
 
 

Commands                         Description

date                    Display the current date and time.

who                     Who is currently logged in?

whoami                  Who am I?

finger alster           Who is user alster?

ls                      Display the names of the files in your directory.
ls -al                  Display all the file names in the long format.
ls -At                  Display most files sorted by date.

cat filename            Display the contents of file filename.

wc filename             Count the number of lines, words, and
                        characters in file filename.
wc -l filename          Count the number of lines in file filename.

more filename           Display the contents of filename one screen
                        at a time

head filename           Display the first 10 lines of file filename.

tail filename           Display the last 10 lines of file filename.

cp colors colors.new    Make a copy of file colors.

mv colors.new my.colors Rename colors.new  to my.colors.

rm colors               Remove (delete) the file colors.

cat memo.l              Display contents of files memo.l, memo.2, memo.3.
cat memo.2
cat memo.3

cmp memo.l memo.3       Compare the two files, displaying the location
                        of the first difference.

diff memo.l memo.3      Compare files memo.l  and memo.3, displaying
                        all differences.

cmp memo.l memo.2       Compare files memo.l  and memo.2.

ls m*                   List the names of all files beginning with
                        the character m .
ls *[0-9]               List the names of all files having a numeric
                        character as the last character.