Unix

Document Sample
Unix Powered By Docstoc
					A UNIX Commands Reference Tutorial
                                                     A UNIX Commands Reference Tutorial



                                                          Table of Contents
                                                           .
A UNIX Commands Reference Tutorial..........................................................................................................1
Introduction..........................................................................................................................................................1
Getting Started.....................................................................................................................................................1

− A −.....................................................................................................................................................................5

− B −.....................................................................................................................................................................6

  ............................................................................................................................................................................7

− C −.....................................................................................................................................................................8

− D −...................................................................................................................................................................12

− E −...................................................................................................................................................................14

−F−....................................................................................................................................................................15

− G −...................................................................................................................................................................17

− H −...................................................................................................................................................................18

− I −....................................................................................................................................................................19

− J −....................................................................................................................................................................20

− K −...................................................................................................................................................................21

− L −...................................................................................................................................................................22

− M −..................................................................................................................................................................25

− N −...................................................................................................................................................................27

− O −...................................................................................................................................................................28

−P−....................................................................................................................................................................29

− Q −...................................................................................................................................................................32

− R −...................................................................................................................................................................33

− S −...................................................................................................................................................................34

− T −...................................................................................................................................................................37




                                                                                                                                                                                  i
                                                    A UNIX Commands Reference Tutorial



                                                         Table of Contents
− U −..................................................................................................................................................................39

− V −...................................................................................................................................................................40

− W −.................................................................................................................................................................42

− X −...................................................................................................................................................................44

− Y −...................................................................................................................................................................45

− Z −...................................................................................................................................................................46




                                                                                                                                                                         ii
                   A UNIX Commands Reference Tutorial
                                                                               By ©John N. Kostaras

Introduction

This tutorial stems from and enhances a manual I once read, “INTERACTIVE UNIX Operating System
Primer – Version 3.0” [1]. It covers both Unix and Linux releases. It is basically a quick reference of the most
common commands avoiding the bundle of information currently offered by the man command. For a more
complete reference, however, one should either use the man command or another more complete source.

Getting Started

Before you can start working with UNIX, you or your system administrator must have installed the system
and set up your login account. If your system is switched off, you must first boot the Unix operating system.
In a workstation normally, the computer where the operating system has been installed, is on 24 hours per
day, and a common user simply connects to the main computer via a terminal. If this is the case, once you
switch on the terminal, a screen asking for a login name appears:
Login:
If however the operating system is installed in a PC (e.g. a LINUX release), after you switch on the computer
the operating system is booted. If this is your case then you will see a number of strange messages appearing
on your screen before the aforementioned login screen appears.

Logging in

In the login prompt, type in your user identification name (ID), or login name, assigned to you and press
ENTER. After a user ID is entered, the system may request a password:
Login: johnPassword:
Type in your password (if you have been assigned one) and press ENTER. The password is not shown on the
screen so that no one watching at your display at that time can see it.If you have typed your login name and
password correctly the system displays the command prompt on the screen:
$
or something similar (# or %). The prompt indicates that the system is ready to receive information. You may
enter a command or run an application when the prompt is displayed on your screen. When you interact with
the UNIX operating system (shortly OS), the commands you type are processed by the command interpreter,
which passes your commands to the OS for processing and delivers the results to you. This interactive
command interpreter is called the shell.Each time you log in, the OS places you in your home directory. This
is your personal working area. Like the DOS OS, the UNIX OS consists of files and directories. A file is a
collection of data stored under an assigned name. Examples of files are a text document you type, an
executable program etc. This tutorial is also stored in a file with filename “UNIX tutorial.doc”. A directory is
a file repository. It exists only to help you organize your files into separate thematic entities. A directory can
contain other directories (or sub−directories) and files.

Logging out

After you have finished your work with the system, you must log out. Always logout when you are finished
using the computer, to prevent unauthorised use of your account. You can log out by one of the following
ways.

      • You can hold down the CTRL key and simultaneously press d

A UNIX Commands Reference Tutorial                                                                               1
                                  A UNIX Commands Reference Tutorial


      • You may type the exit command at the prompt and press ENTER
      • You may type logout at the prompt and press ENTER.

The OS will display the login: prompt, indicating that it is ready to accept a new login name.

Shutting down the system

If you are a system administrator you can shut down the system. Switching off the terminal display does not
shut down the system. In a PC however, you cannot simply switch it off. You first must shut down the OS.
Because UNIX is a multi−tasking OS, the computer can be running many different processes (programs) at
the same time. For example, you may be printing a file while at the same time you are editing another file. To
arrange for the computer to complete all the tasks that are currently running, you should shut down first before
switching off.To shut down the computer you must first login as a system administrator, or a user with system
administrator’s privileges. If you are then you can shutdown the system by entering the following command at
the administrator’s shell prompt (which is #):
# shutdown
and press the ENTER key. The system will ask you a number of questions like when should the system go
down etc. You should answer to these questions with a y for yes or a n for no. If you want however to
shutdown the system immediately without being prompted with questions you should add either now or –g 0
or –h 0 after the shutdown command at the prompt. After a number of strange messages on the screen, the
message:
System halted
appears and the system is halted. You can then switch off the computer.If you want to reboot the computer
you should enter –r 0 after the shutdown command.

Command syntax

In a UNIX OS, the user types a command followed by the ENTER key, the system runs the program that
executes the user’s command, and it outputs the results. The commands in UNIX are case sensitive, which
means that the system distinguishes between uppercase and lowercase letters. Most system commands are
typed in lowercase letters. A UNIX command consists of three parts: the command name, its options, and its
arguments. Options typically begin with a dash (−). The command name, options and arguments are separated
by spaces. Thus, e.g. to shutdown the system you should type:# shutdown –h 0
Here is the command format I shall use in this document:

COMMAND NAME                            command name

FORMAT                                  command [option(s)] argument(s)

DESCRIPTION                             A brief description of what the command does.

OPTIONS                                 A list of the most useful options and a brief description of each.

ARGUMENTS                               Mandatory or optional arguments.

EXAMPLE                                 A simple example of how to use the command.




Getting Started                                                                                               2
                                 A UNIX Commands Reference Tutorial


UNIX Commands

Using the above command format, the first command we have learned, shutdown, is given:

COMMAND NAME                                  shutdown

FORMAT                                        shutdown [−g|h|r] time|now

DESCRIPTION                                   Shutdown or reboot the system in a safe way.

                                              −g|h      Shutdown and halt the system.
OPTIONS
                                              −r         Reboot the system after shutdown.

ARGUMENTS                                     time     Shutdown the system after time secs or now (time=0).

EXAMPLE                                       shutdown –h now




                                            Setting a password

If you were not assigned a password when your login account was set up, the system will probably request
that you choose one the first time you login. Passwords keep unauthorized users from using your account and
harm your files or others’ files. Once your password has been set, only you can access your account.




COMMAND NAME                                 passwd

FORMAT                                       passwd

                                             Set or change your login password. The program prompts for the old
DESCRIPTION                                  password (if any) and prompts twice for the new password.

OPTIONS                                      None.

ARGUMENTS                                    None.

EXAMPLE                                      passwd

Index of UNIX commands

An alphabetical index of the most common UNIX (and LINUX) commands appears on the top frame of this
web page. For more information check the references (especially [1]).

References

     1. INTERACTIVE UNIX Operating System Primer – Version 3.0.
     2. Kernighan B.W., Pike R., The UNIX Programming Environment, Prentice−Hall: 1984.
     3. Waite M., Martin D., Prata S., UNIX Primer Plus, 2nd edition, The Waite Group: 1990.
     4. Libadas K., Papageorgas L., UNIX, Christodoulidis: 1988. (in Greek).


Getting Started                                                                                                   3
                                     A UNIX Commands Reference Tutorial



Creator: John N. Kostaras − email:      jnkostaras@mail.gr Last modification: 11 February 2000.




URL: http://jnkostaras.freeservers.com/index.html




Getting Started                                                                                   4
                                                          −A−
 COMMAND NAME alias

 FORMAT                      alias abbreviation=command

                             Create your own abbreviations (aliases) for commands. With no arguments it displays a list of all
 DESCRIPTION                 aliases. To cancel the alias use unalias.

 OPTIONS                     None.

                             The abbreviation we want to use, an equal sign, and the command to be abbreviated. If the command
 ARGUMENTS                   contains spaces or other special characters (e.g \ ! *) use single quotes (' ').

 EXAMPLE                     alias dir='ls −al'




 COMMAND NAME at

 FORMAT                      at [−ffilename ][−m] time

 DESCRIPTION                 Execute the command(s) read from the standard input or from a specified file at the time specified.

                             −ffilename Read the command(s) from the file specified (not from the standard input).
 OPTIONS
                             −m        Notify the user by mail when the job has completed.

 ARGUMENTS                   The time where the commands are going to be executed.

                             at 08:00
 EXAMPLE                     at> echo "It's 8 o'clock. Wake up!"
                             at> (Ctrl−D)




Creator: John N. Kostaras − email:         jnkostaras@mail.gr Last modification: 11 March 2000.




URL: http://jnkostaras.freeservers.com/a_unix.html




−A−                                                                                                                                5
                         −B−
COMMAND NAME                  bc

FORMAT                        bc

                              Use the calculator. To use decimals, type scale = number of
DESCRIPTION                   decimal digits. To end the calculator, type Ctrl−D.

OPTIONS                       Not presented in this document.

ARGUMENTS                     Not presented in this document.

EXAMPLE                       bc



COMMAND NAME   bg or &

FORMAT         bg [ %n ]

               Execute processes in the background. With no arguments it displays the jobs that
               are currently executed in the background. If a number is provided, then the
DESCRIPTION    process with the given number is executed in the background. One can also add
               the & in the end of a command to make it processed in the background. See also
               fg.

OPTIONS        None.

ARGUMENTS      The number of the process to be executed in the background.

               bg %1 or %1 &
EXAMPLE
               cp −r /usr/man . &




−B−                                                                                               6
Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/b_unix.html.html




                                                                                           7
                                             −C−


COMMAND NAME   cal

FORMAT         cal [ month][ year ]

DESCRIPTION    Display the calendar of the current month (with no arguments) or the month and/or year given.

OPTIONS        None.

ARGUMENTS      The year we wish to display.

EXAMPLE        cal 3 2000




COMMAND NAME cat

FORMAT         cat [−sn] [ filename(s) ]

               Display one or more files on your terminal screen. If more than one filename is supplied, it is
DESCRIPTION    “concatenated” to (i.e. added in the end of) the previous file and displayed.

               −n       Display numbers in ascending order in front of each line.
OPTIONS
               −s       Be silent – do not comment about files that do not exist.

ARGUMENTS      The filename(s) in the order that you want them to display.

EXAMPLE        cat foo1 foo2 > foo




COMMAND NAME cd

FORMAT         cd [ pathname ]

DESCRIPTION    Change current directory. With no arguments the command moves you to your home directory.

OPTIONS        None.

               The (full or relative) path name of the directory to which you want to move. (.) is the current
ARGUMENTS      directory (..) is the parent directory.

EXAMPLE        cd src




COMMAND NAME chgrp


−C−                                                                                                              8
                        A UNIX Commands Reference Tutorial


FORMAT         chgrp groupname filename(s) | directoryname(s)

DESCRIPTION    Change group of the named file(s) or directory(s).

OPTIONS        None.

               The name of the group whom you want to own the file(s) or directory(ies) and the name(s) of the
ARGUMENTS      file(s) or directory(ies) you wish to change the group of.

EXAMPLE        chgrp local foo




COMMAND NAME                    chmod

FORMAT                          chmod [ugo,+−,rwx] filename(s) | directory name(s)

DESCRIPTION                     Change mode permissions of the name file(s) or directory(ies).

OPTIONS                         None.

                                The octal number or a character representation of the new file access permissions
                                and the name(s) of the file(s) or directory(ies) whose file access permissions are
                                going to be changed. It consists of 3 parts:
                                Who                    Action                                 License
ARGUMENTS
                                 u    user             + Grant license.                    r     read
                                 g    group            − Do not grant license.             w     write
                                 o    other                                                x     execute


EXAMPLE                         chmod u+x foo




COMMAND NAME chown

FORMAT         chown username filename(s) | directoryname(s)

DESCRIPTION    Change ownership of the named file or directory.

OPTIONS        None.

               The name of the user whom you want to own the file(s) or directory(ies) and the name(s) of the
ARGUMENTS      file(s) or directory(ies) you wish to change the ownership of.

EXAMPLE        chown john foo




COMMAND NAME       clear

FORMAT             clear


−C−                                                                                                                  9
                         A UNIX Commands Reference Tutorial


DESCRIPTION        Clear the display. After that only the prompt is displayed at the top left of the terminal.

OPTIONS            None.

ARGUMENTS          None.

EXAMPLE            clear




COMMAND NAME cmp

FORMAT         cmp filename1 filename2

DESCRIPTION    Compare the named files.

OPTIONS        None.

               The names of the files to compare. If they are equal, returns nothing, otherwise it returns the first
ARGUMENTS      char and line where the two files differ.

EXAMPLE        cmp foo foo1




COMMAND NAME                         compress

FORMAT                               compress [−v] filename

DESCRIPTION                          Compress the named file.

OPTIONS                              −v     Ask for verification after compressing the file.

                                     The name of the file you want to compress. The compressed file has a .Z
ARGUMENTS                            added to the end of the filename.

EXAMPLE                              compress −v foo




COMMAND NAME       cp

FORMAT             cp [−ir] filename pathname

DESCRIPTION        Copy the named file to the named directory.

                   −i     Ask before updating a file or directory that exists in the destination with the same name.
OPTIONS
                   −r     Copy recursively each subdirectory of the named directory too.

ARGUMENTS          The name of the file you want to copy and the destination to where you want to copy it.




−C−                                                                                                                    10
                                     A UNIX Commands Reference Tutorial


 EXAMPLE                         cp foo /temp




Creator: John N. Kostaras − email:      jnkostaras@mail.gr Last modification: 9 March 2000.




URL: http://jnkostaras.freeservers.com/c_unix.html




−C−                                                                                           11
                                           −D−
COMMAND NAME                                   date

FORMAT                                         date

DESCRIPTION                                    List the current date and time.

OPTIONS                                        Not presented in this document.

ARGUMENTS                                      Not presented in this document.

EXAMPLE                                        date




COMMAND NAME df

FORMAT         df [ −k ][ filesystem]

               Display the amount of disk space used and available on the given filesystem in blocks (1 block =
DESCRIPTION    512 bytes or 1024 bytes). With no arguments displays the amount of disk space used and available
               on all mounted filesystems.

OPTIONS        −k   Use 1024−byte blocks (instead of the default 512).

ARGUMENTS      The filesystem name.

EXAMPLE        df /home




COMMAND NAME                          diff

FORMAT                                diff textfilename1 textfilename2

DESCRIPTION                           Display the differences between the two text files.

OPTIONS                               None.

ARGUMENTS                             The filenames of the two text files

EXAMPLE                               diff version1.txt version2.txt




COMMAND NAME du

FORMAT         du [ −aks ] [ filename(s) | directoryname(s) ]




−D−                                                                                                           12
                                       A UNIX Commands Reference Tutorial


 DESCRIPTION                 Display the amount of disk space used by the specified file(s) or directory(ies) in blocks (1 block =
                             512 bytes or 1024 bytes). With no arguments, the disk used from the current directory is displayed.

                             −a Show counts for all files encountered, not only directories.
 OPTIONS                     −k Use 1024−byte blocks (instead of the default 512).
                             −s Display space usage of the arguments given only, not of their subdirectories.

 ARGUMENTS                   The name(s) of the file(s) or directory(ies) .

 EXAMPLE                     du −k essay




Creator: John N. Kostaras − email:          jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/d_unix.html




−D−                                                                                                                             13
                                                            −E−
 COMMAND NAME                   echo

 FORMAT                         echo characterString

 DESCRIPTION                    Display its arguments to the standard output. With no arguments an empty line is displayed.

 OPTIONS                        None.

 ARGUMENTS                      Any string of characters.

 EXAMPLE                        echo Today is my wedding day!




 COMMAND NAME                                                             exit

 FORMAT                                                                   exit

 DESCRIPTION                                                              Exit the system or logout (the same as Ctrl−D).

 OPTIONS                                                                  None.

 ARGUMENTS                                                                None.

 EXAMPLE                                                                  exit




Creator: John N. Kostaras − email:          jnkostaras@mail.gr Last modification: 9 March 2000.




URL: http://jnkostaras.freeservers.com/e_unix.html




−E−                                                                                                                           14
                         −F−

COMMAND_NAME   fg

FORMAT         fg [ %n ] or %n

               Restart a process (i.e. execute in the foreground) that is executed in the
               backgound. With no arguments it restarts the process with the + sign. If a number
DESCRIPTION    is provided, then the process with the given number is restarted. It is the opposite
               of bg.

OPTIONS        None.

ARGUMENTS      The number of the process to be executed in the foreground.

EXAMPLE        fg %2




COMMAND_NAME     find

FORMAT           find directory−path(s)search−pattern action(s)

                 Search the specified directorie(s) for files that satisfy the search−pattern and
                 act on them according to action(s).

                 Search−patterns:
                            −name filename: Search for files with the specified
                 filename.
                           − size n: Search for files of n blocks (usually 512 or 1024
                 bytes).
                           − links n: Search for files with n links.
                           − atime n: Search for files that have been last accessed
                 before n days.
                           − mtime n: Search for files that have been last modified
                 before n days.
DESCRIPTION                − newer filename: Search for files that have been modified
                 more recently than the specified file.
                 Actions:
                           − print: Display the path(s) of the files found.
                           − exec command: Run for each file found; {} represents
                 the file specified.
                           − ok command: As the previous one, but it asks for your
                 approval before every action.
                 Note: Search−patterns can be combined.
                           ! means negation;
                                    − o means logical or;
                           one or more search−patterns are combined using logical and;
                                    (    ) or \ \ can be used to define groups of
                 search−patterns.


−F−                                                                                                 15
                                     A UNIX Commands Reference Tutorial


 OPTIONS                                      None.

                                              The search−path(s), the search−pattern and the action(s) to perform for each
 ARGUMENTS                                    file found.

 EXAMPLE                                      find / −name "Hallo world!" −print




Creator: John N. Kostaras − email:      jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/f_unix.html




−F−                                                                                                                      16
                                                           −G−
 COMMAND NAME grep

 FORMAT                      grep [ −c,−n,−i,−v,−w,−y ] pattern [ file(s) ]

                             Search the specified file(s) for lines that contain the pattern and then display these lines. If more
 DESCRIPTION                 than one files are given, the filename is displayed before the line(s). If no file(s) are given, the
                             standard input is searched.

                             −c Displays only the number of lines that match.
                             −n Displays the line number in front of every displayed line.
                             −i          Ignore case.
 OPTIONS                     −v Displays all other lines except those lines that match.
                             −w Matches whole words only.
                             −y Case independent pattern matching, i.e. lower case letters in pattern will also match upper
                             case letters in the input.

 ARGUMENTS                   The file(s) to be searched.

 EXAMPLE                     grep −y classpath *




Creator: John N. Kostaras − email:          jnkostaras@mail.gr Last modification: 15 February 2001.




URL: http://jnkostaras.freeservers.com/g_unix.html




−G−                                                                                                                                  17
                                                            −H−
 COMMAND NAME                 head

 FORMAT                       head [ −n]filename(s)

                              Display the first n lines of the named file(s). If no option number is given then the first 10 lines are
 DESCRIPTION                  displayed.

 OPTIONS                      −n The number of the lines to display from the top of the file.

 ARGUMENTS                    The filename(s) to display.

 EXAMPLE                      head −15 mydiary




 COMMAND NAME                                               hostname

 FORMAT                                                     hostname

 DESCRIPTION                                                Display the name of the host machine.

 OPTIONS                                                    None.

 ARGUMENTS                                                  None.

 EXAMPLE                                                    hostname




Creator: John N. Kostaras − email:          jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/h_unix.html




−H−                                                                                                                                 18
                                                    −I−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/i_unix.html




−I−                                                                                        19
                                                    −J−
 COMMAND NAME                                              jobs

 FORMAT                                                    jobs

 DESCRIPTION                                               Display active processes

 OPTIONS                                                   None.

 ARGUMENTS                                                 None.

 EXAMPLE                                                   jobs




Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/j_unix.html




−J−                                                                                       20
                                                    −K−
 COMMAND NAME                                       kill

 FORMAT                                             kill [ −signo ] process_ID

 DESCRIPTION                                        Terminate the process with process ID.

 OPTIONS                                            −9         Send a definite kill signal.

 ARGUMENTS                                          The ID of the process you want to kill (returned from ps).

 EXAMPLE                                            kill –9 10965




Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 15 February 2000.




URL: http://jnkostaras.freeservers.com/k_unix.html




−K−                                                                                                              21
                                              −L−
COMMAND NAME                                               learn

FORMAT                                                     learn

                                                           Learn UNIX. This command provides a
DESCRIPTION                                                Computer Aided Interface (CAI). To end the
                                                           command type either bye or Ctrl−c.

OPTIONS                                                    None.

ARGUMENTS                                                  None.

EXAMPLE                                                    learn



COMMAND NAME lpq

FORMAT         lpq [ −Pprinterqueue ]

               Display printer queues' jobs. Displays information about the file(s) in the printer's queue; its owner
DESCRIPTION    name, id, size and its filename. The filename displayed is the temporary filename in the printer's
               queue and not the file's name.

OPTIONS        −Pprinterqueue Specify the printer's queue instead of using the default.

ARGUMENTS      None.

EXAMPLE        lpq




COMMAND NAME                  lpr

FORMAT                        lpr [ −h −Pprinterqueue ] filename(s)

                              Print the filename(s) to the line printer. Sends the filename(s) to the line printer's
DESCRIPTION                   queue. With no arguments, standard input is being printed (end with Ctrl−q).

                              −h            Print no header.
OPTIONS
                              −Pprinterqueue Specify the printer's queue instead of using the default.

ARGUMENTS                     The name(s) of the file(s) to be printed.

EXAMPLE                       lpr −Php5000 myaddressbook.txt




COMMAND NAME           lprm


−L−                                                                                                                    22
                       A UNIX Commands Reference Tutorial


FORMAT               lprm [ −Pprinterqueue ] fileid(s) | fileowner| filename

                     Remove the file(s) with the information provided from the printer's queue. The file id and
DESCRIPTION          filename are provided by lpq.

OPTIONS              −Pprinterqueue Specify the printer's queue instead of using the default.

                     fileowner    Removes from printer's queue all the files with the file owner provided.
ARGUMENTS            fileid       Remove from printer's queue the file with the file id provided.
                     filename     Remove from printer's queue the file with the specified filename.

EXAMPLE              lprm 03847




COMMAND_NAME ls

FORMAT        ls [−CFRR*acdglrstu] [ list of filenames|directories ]

              For each directory named, list its contents and any other information requested; for each filename,
DESCRIPTION   list the requested information.

OPTIONS       −C List entries by columns.
              −F List directories with /.
              −R List subdirectories too.
              −R* List subdirectories too (only two levels lower from current directory).
              −a List all entries, including files that begin with a dot (.).
              −c Sort entries by time of last modification (latest first) rather than by name.
              −d List directories only.
              −g List hidden files or directories (that begin with a dot (.)).




−L−                                                                                                                 23
                                         A UNIX Commands Reference Tutorial


                              −r List in reverse order.
                              −s List size into 1024 byte−blocks.
                              −t Sort contents by time of last modification (latest first) rather than by name.
                                     Use time of last access instead of last modification for sorting (with –t option) or printing on
                              −u
                                     the screen (with −l option).

                             A file name or a directory name. If no filename or directory name is given, the current directory is
 ARGUMENTS                   listed.

 EXAMPLE                     ls −Fal




Creator: John N. Kostaras − email:            jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/l_unix.html




−L−                                                                                                                                 24
                             −M−
COMMAND NAME   man

FORMAT         man [ −k ] [ command_name ]

               Show information about the specified command. To end the command
DESCRIPTION
               type Ctrl−q.

OPTIONS        −k     Display a summary.

ARGUMENTS      The name of the command you want to find information for.

EXAMPLE        man cat



COMMAND NAME            mesg

FORMAT                  mesg [ y|n ]

                        Allow or prevent messages from being received due to the talk
DESCRIPTION             command. With no arguments the command returns a y or n
                        denoting the current state of the command.

OPTIONS                 None.

                        y Allow other users to pass on messages to you using the
                        talk command.
ARGUMENTS
                        n Prevent other users to pass on messages to you using the
                        talk command.

EXAMPLE                 mesg n



COMMAND NAME        mkdir

FORMAT              mkdir name(s)

DESCRIPTION         Create a directory with the name provided.

OPTIONS             None.

ARGUMENTS           The name(s) of the directory(ies) you want to create.

EXAMPLE             mkdir src


COMMAND NAME                    more


−M−                                                                                  25
                                          A UNIX Commands Reference Tutorial


 FORMAT                                                        more filename(s)

                                                               Display the file(s) on the standard output, one page at a time. If no
                                                               filename is specified the standard input is displayed. See also pg.

                                                               [RETURN or ENTER]: Display next line
                                                               [Space]: Dislpay next page
                                                               b: Display previous page
 DESCRIPTION                                                   /<s>[RETURN]: Search forward for string <s>
                                                               !<c>[RETURN]: Execute command <c>
                                                               v: load vi editor
                                                               .: Repeat previous command
                                                               h: Display help page
                                                               q: quit more command.

 OPTIONS                                                       None.

 ARGUMENTS                                                     The names of the files to display.

 EXAMPLE                                                       more foo




 COMMAND NAME                        mv

 FORMAT                              mv filename | directoryname pathname

 DESCRIPTION                         Move the named file or directory to the named position.

 OPTIONS                             None.

 ARGUMENTS                           The name of the file or directory you wish to move and its destination.

 EXAMPLE                             mv foo /temp



Creator: John N. Kostaras − email:           jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/m_unix.html




−M−                                                                                                                                26
                                                   −N−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/n_unix.html




−N−                                                                                        27
                                                   −O−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/o_unix.html




−O−                                                                                        28
                                           −P−
COMMAND NAME passwd

FORMAT         passwd

               Set or change your login password.The program prompts for the old password (if any) and prompts
DESCRIPTION    twice for the new password.

OPTIONS        None.

ARGUMENTS      None.

EXAMPLE        passwd




COMMAND NAME                          pc

FORMAT                                pc [ −c, −ofilename ] filename(s).p|.o

                                      Compile Pascal source files (.p) or Pascal object files (−o). The
DESCRIPTION                           executable file that is produced is named a.out.

                                      −c Suppresses the creation of a a.out file and forces the creation of an
                                      executable file.
OPTIONS
                                      −ofilename Produces an executable file with the given filename instead
                                      of a.out.

ARGUMENTS                             The name(s) of the Pascal file(s) to be compiled.

EXAMPLE                               pc −o foo foo.p math.o



COMMAND NAME                                  pg

FORMAT                                        pg filename(s)

                                              Display the file(s) on the standard output, one page at a time. If no
                                              filename is specified the standard input is displayed. See also
                                              more.

                                              [RETURN or ENTER]: Display next line
                                              [Space]: Dislpay next page
DESCRIPTION                                   b: Display previous page
                                              /<s>[RETURN]: Search forward for string <s>
                                              !<c>[RETURN]: Execute command <c>
                                              v: load vi editor
                                              .: Repeat previous command
                                              h: Display help page
                                              q: quit pg command.



−P−                                                                                                               29
                         A UNIX Commands Reference Tutorial


OPTIONS                                           None.

ARGUMENTS                                         The names of the files to display.

EXAMPLE                                           pg foo




COMMAND NAME pr

FORMAT         pr [ −ln ] filename(s)

               Print the file(s) on the standard output, one page at a time. Each page consists of 66 lines with an
               additional margin of 5 empty lines at the bottom of the page and a 5 line−header at the top. The
DESCRIPTION    header consists of two empty lines, one line for the date, the filename and the page number, and two
               more empty lines.

OPTIONS        −ln      Set the page height to n lines.

ARGUMENTS      The names of the files to print.

EXAMPLE        pr foo | lpr




COMMAND NAME                        ps

FORMAT                              ps [ −aefx]

DESCRIPTION                         Report the status of all currently active processes.

                                    −a Display all processes of all users in the system.
                                    −e Display all processes using standard syntax.
OPTIONS
                                    −f Generate a full listing.
                                    −x Display processes that did not start from your terminal.

ARGUMENTS                           None.

EXAMPLE                             ps −ef




COMMAND NAME    pwd

FORMAT          pwd

                Print the current working directory. Displays the complete path name of the directory you are
DESCRIPTION     currently in.

OPTIONS         None.

ARGUMENTS       None.


−P−                                                                                                              30
                                     A UNIX Commands Reference Tutorial


 EXAMPLE                       pwd




Creator: John N. Kostaras − email:      jnkostaras@mail.gr Last modification: 14 May 2000.




URL: http://jnkostaras.freeservers.com/p_unix.html




−P−                                                                                          31
                                                   −Q−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/q_unix.html




−Q−                                                                                        32
                                                    −R−
 COMMAND NAME                              rm, rmdir

 FORMAT                                    rm [−fri] [ filename(s) ]rmdir [ directory name(s) ]

 DESCRIPTION                               Remove the name file(s) or directory(ies).

                                           −f Ask no questions about removal. −i Ask before removing
 OPTIONS                                   each file or directory. −r Examine each directory before
                                           removing it.

 ARGUMENTS                                 One or more file or directory.

 EXAMPLE                                   rm –i foormdir src



Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 15 February 2000.




URL: http://jnkostaras.freeservers.com/r_unix.html




−R−                                                                                                    33
                         −S−
COMMAND NAME    set

FORMAT          set variable= value

                Set a variable. With no arguments, display the values of all defined variables.
DESCRIPTION     Dispose of the variable with unset.

OPTIONS         Not presented in this document.

ARGUMENTS       The name of the variable to set and its value.

EXAMPLE         set CLASSPATH=$CLASSPATH:/usr/java/lib




COMMAND NAME   setenv

FORMAT         setenv variable value

DESCRIPTION    Set an environment variable.

OPTIONS        None.

ARGUMENTS      The name of the environment variable to set and its value.

EXAMPLE        setenv COLORS 8




COMMAND NAME           shutdown

FORMAT                 shutdown [−g|h|r] time

DESCRIPTION            Shutdown or reboot the system in a safe way.

                       −g|h     Shutdown and halt the system.
OPTIONS
                       −r       Reboot the system after shutdown.

ARGUMENTS              time Shutdown the system after time secs or now (time=0).

EXAMPLE                shutdown –h now




−S−                                                                                           34
                         A UNIX Commands Reference Tutorial




COMMAND NAME sort

FORMAT         sort [−dfnr] [−ooutput file ] [ filename(s) ]

               Sort the lines of the named file(s) together and write the result(s) to the standard output. Sort
DESCRIPTION    standard input if no input files are given. Write the results to standard output if no output file is
               given.

               −d Use “dictionary” order. Only letters, digits and blanks are significant.−f Ignore case when
OPTIONS        sorting.−n Sort numeric strings arithmetically.
               −r Reverse sort.

ARGUMENTS      One or more file(s) or directory(ies).

EXAMPLE        sort –d –osorted phoneindex




COMMAND NAME spell

FORMAT         spell filename(s)

               Checks the spelling of the input file and lists the words that do not appear in its dictionary on the
DESCRIPTION    standard output.

OPTIONS        Not presented in this document.

ARGUMENTS      Not presented in this document.

EXAMPLE        spell foo




COMMAND NAME              stty

FORMAT                    stty [all|erase|everything] [erase char] [kill char] −tabs

DESCRIPTION               Set terminal settings.

OPTIONS                   all Display information for all normally used settings.

                          erase Character for erase.



−S−                                                                                                                    35
                                     A UNIX Commands Reference Tutorial


                                     everything Display information about stty.

                                     kill Character for line kill.

                                     −tabs Causes tabs to be replaced by spaces when printed on the terminal.

 ARGUMENTS                           Depend on options.

 EXAMPLE                             stty erase ^h



Creator: John N. Kostaras − email:      jnkostaras@mail.gr Last modification: 4 December 2000.




URL: http://jnkostaras.freeservers.com/s_unix.html




−S−                                                                                                             36
                                             −T−
COMMAND NAME   tail

FORMAT         tail [ −n|+n ][lbc] filename(s)

               Display the last n lines of the named file(s). If no option number is given then the last 10 lines are
DESCRIPTION    displayed.

               +n The number of the lines to display starting from the beginning of the file.
               −n The number of the lines to display from the bottom of the file (i.e. the last nth lines of the
OPTIONS
               file).
               lbc Determines the meaning of the number, i.e. either lines (l), blocks (b) or characters (c).

ARGUMENTS      The filename(s) to display.

EXAMPLE        tail −20c mydiary



COMMAND NAME                          talk

FORMAT                                talk username_connection

                                      Communicate with another user. The command passes on what you type on
DESCRIPTION                           your terminal to the other user's terminal. To end the transmission type
                                      Ctrl−c.

OPTIONS                               None.

ARGUMENTS                             The login name of the user you wish to talk with.

EXAMPLE                               talk john




COMMAND_NAME          tar

FORMAT                tar [b|c|f|t|x|v] [n] [tar−file] [filenames or directory names]

DESCRIPTION           Backup files.

OPTIONS               bn      (block) Number of blocks (512 bytes) to use.

                      c (create) Create tar file.

                      f    tar−file (file) The name of the tar file to use.

                      t Display tar file contents.

                      x (extract) Extract files from tar file.



−T−                                                                                                                 37
                                      A UNIX Commands Reference Tutorial


                                     v (verbose) Display files or directories as they are processed.

                                     The name of the backup (.tar) file and the filenames or directory names that are contained
 ARGUMENTS                           in the tar file.

 EXAMPLE                             tar xvf backup.tar




 COMMAND NAME                                                  touch

 FORMAT                                                        touch filename

 DESCRIPTION                                                   Create an empty file.

 OPTIONS                                                       None.

 ARGUMENTS                                                     The name of the file to create.

 EXAMPLE                                                       touch empty




 COMMAND_NAME                                    tty

 FORMAT                                          tty

                                                 Returns the path of the terminal the user is using. It returns something like:
 DESCRIPTION                                     /dev/tty08 meaning that the user is using terminal 8.

 OPTIONS                                         None.

 ARGUMENTS                                       None.

 EXAMPLE                                         tty




Creator: John N. Kostaras − email:        jnkostaras@mail.gr Last modification: 4 December 2000.




URL: http://jnkostaras.freeservers.com/t_unix.html




−T−                                                                                                                               38
                                                  −U−
 COMMAND NAME                            unalias

 FORMAT                                  unalias abbreviation

 DESCRIPTION                             Undo alias. The reverse command of alias.

 OPTIONS                                 None.

 ARGUMENTS                               The abbreviation of the command you want to cancel alias.

 EXAMPLE                                 unalias dir




 COMMAND NAME                                        unset

 FORMAT                                              unset variable

 DESCRIPTION                                         Dispose of a variable that was defined by set.

 OPTIONS                                             None.

 ARGUMENTS                                           The name of the variable to unset.

 EXAMPLE                                             unset CLASSPATH



Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 4 December 2000.




URL: http://jnkostaras.freeservers.com/u_unix.html




−U−                                                                                                   39
                                            −V−
COMMAND_NAME vi

FORMAT        vi [ filename(s) ]

DESCRIPTION   Create or edit a text file with the given filename. If no filename is given, a new empty file is created.
              The editor operates in two modes:

                     • command mode: allows the use of commands (it is in this mode when vi is started or
                        whenever the user presses Esc)
                     • text mode: allows text editing (to enter this mode use one of the commands a, i, o,
                        O, R or c).

                                                              commands for text editing
              commands for cursor movement
                                                              a adds text after cursor's position
              j moves cursor one line down
                                                              i inserts text before cursor's position
              k moves cursor one line up
                                                              o adds an empty line under cursor's position
              h moves cursor one space to the left
                                                              O adds an empty line after cursor's position
              l moves cursor one space to the right
                                                              commands for text deletion
              Ctrl−d moves screen half a page down
                                                              x deletes the character at the cursor

              Ctrl−u moves screen half a page up
                                                              dw deletes the characters from the cursor position to the
                                                              beginning of the next word
              Ctrl−w moves screen one page up
                                                              dd deletes the line containing the cursor
              Ctrl−f moves screen one page down
                                                              d) deletes the rest of the line from cursor onwards
              nG moves cursor to the n−th line of the
              document                                        d} deletes the rest of the paragraph from cursor
                                                              onwards
              commands for text modification                  search commands

              r replaces character with the next character    /template searches for the next appearance of the
              you type                                        template

              R ovewrites previous characters, starting at    ?template searches for the previous appearance
              cursor position                                 of the template

              cw changes word with the next word you          n repeats the last search command
              type
                                                              commands for text movement
              c) changes sentence
                                                              yy copies a line to the clipboard




−V−                                                                                                                       40
                                       A UNIX Commands Reference Tutorial


                              j joins the sentence of the cursor and the    p pastes the text in the clipboard after cursor position
                              next sentence
                                                                            P pastes the text in the clipboard before cursor
                              u undo last command                           position

                              . redo last command

                              U undo all commands at the sentence of the
                              cursor
                              commands for save of document

                              Esc :w save current document

                              Esc :q quit vi if no changes were made
                                                                            commands for screen improvement

                              Esc :q! quit without saving
                                                                            Esc :set nu display line numbers

                              Esc :wq save document and exit vi
                                                                            Esc :set wm = k set margin on the right to k
                                                                            characters
                              Esc ZZ save document and exit vi
                                                                            Esc :set redraw keep the current display
                              Esc :n,kw filename save lines n to k
                              to another filename

                              Esc :n,kw>>filename append lines n
                              tok to another filename


 OPTIONS                     None.

 ARGUMENTS                   The name(s) of the file(s) to edit.

 EXAMPLE                     vi newtextfile




Creator: John N. Kostaras − email:          jnkostaras@mail.gr Last modification: 10 February 2001.




URL: http://jnkostaras.freeservers.com/v_unix.html




−V−                                                                                                                               41
                                           −W−
COMMAND_NAME wc

FORMAT         wc [ −clw ] filename(s)

               Count the lines, words and characters of the named file(s). With no arguments the standard input is
DESCRIPTION    used. If more than one filenames are given then it also calculates the sum of the lines, words and
               characters of all files.

               −c Count the characters.
OPTIONS        −l Count the lines.
               −w Count the words.

ARGUMENTS      A list of filenames.

EXAMPLE        wc −w essay




COMMAND NAME                              who

FORMAT                                    who [am i]

DESCRIPTION                               List the users logged into the system.

OPTIONS                                   Not presented in this document.

ARGUMENTS                                 List the information for the users only.

EXAMPLE                                   who



COMMAND_NAME write

FORMAT         write login−name

               Communicate with a user by writing on their terminal. The requested user has to
DESCRIPTION
               take explicit action to accept the conversation.

OPTIONS        Not presented in this document.

ARGUMENTS      The login name of the user to write to.

EXAMPLE        write john




−W−                                                                                                              42
                                     A UNIX Commands Reference Tutorial

Creator: John N. Kostaras − email:      jnkostaras@mail.gr Last modification: 4 December 2000.




URL: http://jnkostaras.freeservers.com/w_unix.html




−W−                                                                                              43
                                                   −X−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/x_unix.html




−X−                                                                                        44
                                                   −Y−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/y_unix.html




−Y−                                                                                        45
                                                    −Z−

Creator: John N. Kostaras − email:   jnkostaras@mail.gr Last modification: 5 March 2000.




URL: http://jnkostaras.freeservers.com/z_unix.html




−Z−                                                                                        46

				
DOCUMENT INFO
Shared By:
Tags: reference
Stats:
views:96
posted:8/18/2009
language:English
pages:49
Description: Unix Doc for Beginners