Docstoc

unix commands

Document Sample
unix commands Powered By Docstoc
					Command                                  Action                                     Example
alias       Creates a temporary name for a Unix command.                 alias name command
            To remove an alias:                                          unalias name
ansiprint   Prints a file to a printer connected to your computer.       ansiprint file
assets      Displays your account resources, use, and threshold.
bg          Places a suspended job in the background.
cat         Displays a specified file.                                   cat file
cd          Changes current directory to a different directory.          cd directory
            To change back to your home directory:                       cd
            Directory abbreviations:
                     ~ Home directory
                     .. Parent directory
                     .   Current working directory
chmod       Changes permission status for a file or directory.           chmod code file
                                                                         chmod code directory
            To keep a file private:                                      chmod 600 file
            To give everyone read permission:                            chmod 664 file
compress    Reduces the size of a file and adds .Z to the file's name.   compress file
            To restore a compressed file:                                uncompress file.Z
cp          Makes a copy of a file.                                      cp file1 file2
            To copy a file into a different directory:                   cp file directory
            To inquire before overwriting an existing file:              cp -i file1 file2
diff        Compares two files and displays the differences.
fg          Restarts a suspended job in the foreground.
finger      Displays user information at the specified computer.         finger userid@computer
            To change your finger entry information:                     chfn
fmail       Displays email status for all your accounts.                 fmail
            To display your email forwarding address:                    fmail -forward
            To set your email forwarding address:                        fmail -to userid@address
ftp         Starts the file transfer program with a remote computer.     ftp address
grep        Finds lines in a file matching a character pattern.          grep -icvn pattern file
                      -i Ignores case
                      -c Lists count of lines that contain pattern
                      -v Lists all lines except those with pattern
                      -n Lists line number for each found pattern
head        Displays the first ten lines of a file.                      head file
            To display the first n number of lines:                      head -n file
help        Displays an online help note.                                help note
            To display a list of help notes:                             help -l
history   Displays a list of your most recent commands.                   history
          To repeat the nth command from the list:                        ! n
          To repeat your most recent command:                             !!
jobs      Displays active jobs and their corresponding job numbers.       jobs
          To start a job in the background:                               job &
          To return a job to the foreground by the job number:            fg %number
          To send a running job to the background:                        <Control>z bg
kill      Terminates a process by its process identification number.      kill pid
          To use the strongest form of the kill command:                  kill -9 pid
logout    Ends your computer session.
ls        Lists the files and subdirectories in your current directory.   ls -Fltra
                   -l Lists long format
                   -t Lists by modification time
                   -r Lists in reverse order
                   -F Lists file type with special character
                   -a Lists all files including dot (.) files
lynx      Starts a text-only Web browser session at UW home page.         lynx
          Starts a Web browser session at a specific Web address.         lynx url
man       Displays Unix Manual entry for a command.                       man command
          To search Manual Index for a keyword or topic:                  man -k keyword
mesg      Displays your talk and write message access status.             mesg
          To set your message status to yes or no:                        mesg y (or n)
mkdir     Creates a new directory within your current directory.          mkdir directory
more      Displays a file one screen at a time.                           more file
          Use <Spacebar> to scroll forward and q to quit.
mv        Moves a file to a different directory.                          mv file directory
          Moves a directory to a second directory.                        mv directory1 directory2
          To rename file1 as file2:                                       mv file1 file2
          To rename directory1 as directory2:                             mv directory1 directory2
          To inquire before overwriting an existing file:                 mv -i file1 file2
passwd    Starts program to change account password.
pico      Starts the Pico    text editor with a file.                     pico file
pine      Starts the Pine® electronic mail program.
prt       Sends a file to a Uniform Access printer.                       prt -q printer file
          To display a list of the available printers:                    prt -printers | more
ps        Displays processes and their corresponding process
          identification numbers.
pwd       Displays absolute pathname of current directory.
rm               Permanently deletes a file.                       rm file
                 To verify prior to removal:                       rm -i file
rmdir            Deletes an empty directory.                       rmdir directory
                 To verify prior to removal:                       rmdir -i directory
spell            Checks the spelling in a file.                    spell file
staffdir         Displays the Online UW Staff Directory.           staffdir "lastname,
                                                                   firstname"
                 To display all fields:                            staffdir -full "lastname,
                                                                   firstname"
telnet           Starts a telnet session with a remote computer.   telnet address
vi               Starts the vi text editor with a file.            vi file
w                Displays a list of who is on system.
wc               Counts lines, words, and characters in a file.    wc file


Special commands and characters:

Redirection

     <     Routes input to command from file
     >     Routes output from command to file
     >> Appends output to existing file
     |     Routes output between commands

Wildcards used in filenames

     *   Matches any number of characters
     ?   Matches one character

Control codes

     <Control>s      Suspends the screen display
     <Control>q      Restarts suspended display
     <Control>d      Signals end of file
     <Control>c      Cancels a command
     <Control>z      Suspends a process or job:
                     use fg to restart
     <Control>u      Clears the command line
Directory and File Commands
       Command                    Description

       cd d                        Change to directory called "d"

       mkdir d                     Create new directory called "d"

       mv f1 [f2...] d             Move file "f" to directory called
       "d"

       mv d1 d2                    Rename directory d1 as d2

       ls                          List files in directory

       ls -1     filename          List files in detail
          -a     filename          Display of hidden files

       cat     filename            List contents of file

       more     filename           List file contents by screen

       chmod mode filename         Change permission(r/w/x) of file

       cp f1 f2                    Copy file f1 into f2

       sort filename               Alphabetically sort file called "f"

       mv f1     f2                Rename file f1 as f2

       rm f                        Delete (remove) file f
          -r filename              Delete (remove) file f recursively
             dirname               Delete (remove) directory
       recursively

       rmdir dirname               Delete (remove) directory(if given
                                   directory is empty)
Return to Table of contents


Print Commands
       Command                    Description

       lpr -P printername f        Output file to line printer
       For ICL:
       lpr -Picl2 filename

       lpq -P printername          display the queue of printer jobs
       For ICL:
       lpq -Picl2

       lprm -P printername #job    Removes the job from the printer
       queue
       For ICL:
       lprm -Picl2 -
Return to Table of Contents


Process Control
       Command                     Description

       CTRL/c *                     Interrupt processes

       sleep n                      Sleep for n seconds

       ps                           Print process status stats

       kill   -9 n                  Remove process n

       CTRL/z *                     Suspend current process

       exit                         Exit from shell
Return to Table of Contents


Mail Programs
           Command Description pine Mail reader and composer elm Read
       and/or
           compose e-mail from list the senders of mails newmail notify
       new mail has
           arrived (part of elm package) frm List the senders of mails
       with subject mail
           username@host Send mail to user For EECS: mail
       userid@eecs.uic.edu biff [y/n]
           Instant notification of mail
Return to Table of Contents


Text Editors
           Command Description pico filename A simple text editor vi
       filename
           Vi editor emacs filename Emacs editor xemacs filename X
       window Emacs editor
           nedit filename Nedit editor xedit filename A simple X window
       text editor
Return to Table of Contents


File Transfer
           Command Description ftp hostname using ftp program to
       perform
           FTP to/from hostname ncftp hostname A user-friendly FTP
       program (for a tutorial,
           click here) xftp
           X-window interface to FTP
Return to Table of Contents


Compilers
       Command                     Description

       cc     filename              C compiler

       CC     Filename              Sun's C++ Compiler

       gcc Filename                 GNU C Compiler

       g++ Filename                 GNU C++ Compiler

       f77 Filename                 Fortran77 Compiler

       f90 Filename                 Fortran90 Compiler

       pc     Filename              Pascal Compiler
Return to Table of Contents


Window Manager
       Command                     Description

       fvwm                        feeble window manager

       mwm                         Motif window manager

       olvwm                       OpenLook virtual window manager

       olwm                        OpenLook window manager

       twm                         Tom's window manager
                                   (Credits: John
       Yancey(jyancey@acm.org)
Return to Table of Contents


X window programs
       Command                     Description
       filemgr                 OpenWindows file manager

       xclock                  display clock

       oclock                  display oclock

       xcalc                   calculator

       xlock                   lock your screen

       xterm                   a terminal or shell session

Return to Table of Contents


File Compression
       Command                Description

       compress filename       Compressed filename
                               (filename will be replaced
                                by filename.Z(it will add .Z
       extension)

       uncompress filename     Expand filename.Z into its original
                               size and remove .Z extension
                               (Reverse of compress command)

       gunzip filename.gz      Expand filename.gz into its original
       size
                               and remove .gz extension

       gzip filename           Compress filename with GNU zip(gzip)
       and
                               add .gz extension

       zip zipname files       Create an archive compressed file
       called
                               which contains all
       files


       unzip filename.zip      Extract files from filename.zip.
                               (Reverse of zip command)

       unarj filename.arj      Extract files from filename.arj

       tar                     Create tape archives and add or
       extract files
                               (use man tar for more information)
Return to Table of Contents
Floppy Drive Commands
       Command                     Description

       mdir                          List the contents of the floppy
       disk

       mcopy file.unix a:file.floppy copies file from current directory
       to floopy

       mcopy a:file.floppy file.unix copies file from floppy to current
       directory

       mformat                       Formats the floppy disk into a MS-
       DOS like
                                     disk

       mdel a:filname                Deletes a file called filename from
       the
                                     floppy

       eject                         Ejects the floppy from the drive

Return to Table of Contents


Miscellaneous Commands
       Command                     Description

       telnet hostname              Connect to hostname using telnet
       program

       who                          List logged in users

       whoami                       Display current user

       finger     [username]        Output user information

       talk userid@hostname         talk to userid at given hostname

       write userid                 write to userid screen/session

       ping hostname                check if hostname is alive

       man name                     Unix manual entry for name

       pwd                          Print working directory

       gs filename                  A postscript previewer

       xv filename                  Image previewer

       date                         Print date & time
                 history                          Display recent commands

                 alias     [name]                 Display command aliases

                 quota -v                         Display disk quota for User

                 head f                           Output beginning of file f

                 tail f                           Output end of file f

                 passwd/yppasswd                  Change password

                 alias name1 name2                Create command alias

                 unalias name1[na2...]            Remove command alias na

                 script filename                  Save terminal session to given
                 filename
                                                  (Useful to store a.out)

                 logout/exit/quit/bye             End terminal session



           new
Unix
command
List
          Useful commands:

           cd................Change Directory
           cp................Copy File(s)
           cat...............Print Out A File Onto The Screen
           mv................Move File(s)
           mkdir.............Make A Directory
           locate............Find A File(s)
           ed................Editor
           vi................Editor
           ls -a.............List ALL Files
           locate /..........List ALL Files on entire hard drive
           rm................Delete
           tar...............Untar (like zip) a file
           netstat -r........Show all computers connected
           pine..............Opens pine, and e-mail system
           telnet............Program to connect to other computers
           lynx..............Internet browser
           who...............Show who you are
           kill..............Stop a program
           man...............Get help
           passwd...........Change password

          Another list:
           ls .................     show directory, in alphabetical order
           logout .............     logs off system
           mkdir ..............     make a directory
           rmdir ..............     remove directory (rm -r to delete folders with files)
rm .................    remove files
cd .................    change current directory
man (command) ......    shows help on a specific command
talk (user) ........    pages user for chat - (user) is a email address
write (user) .......    write a user on the local system (control-c to end)

pico (filename) .... easy to use text editor to edit files
pine ............... easy to use mailer
more (file) ........ views a file, pausing every screenful

sz ................. send a file (to you) using zmodem
rz ................. recieve a file (to the unix system) using zmodem

telnet (host) ......    connect to another Internet site
ftp (host) .........    connects to a FTP site
archie (filename) ..    search the Archie database for a file on a FTP site
irc ................    connect to Internet Relay Chat
lynx ...............    a textual World Wide Web browset
gopher .............    a Gopher database browser
tin, trn ...........    read Usenet newsgroups

passwd ............. change your password
chfn ............... change your "Real Name" as seen on finger
chsh ............... change the shell you log into

grep ...............    search for a string in a file
tail ...............    show the last few lines of a file
who ................    shows who is logged into the local system
w ..................    shows who is logged on and what they're doing
finger (emailaddr)..    shows more information about a user
df .................    shows disk space available on the system
du .................    shows how much disk space is being used up by folders
chmod ..............    changes permissions on a file
bc .................    a simple calculator

make ............... compiles source code
gcc (file.c) ....... compiles C source into a file named 'a.out'

gzip ...............    best compression for UNIX files
zip ................    zip for IBM files
tar ................    combines multiple files into one or vice-versa
lharc, lzh, lha ....    un-arc'ers, may not be on your system

dos2unix (file) (new) - strips CR's out of dos text files
unix2dos (file) (new) - adds CR's to unix text files



display list of files          dir/w dir               ls
                              dir                     ls -l
display contents of file       type                    cat
display file with pauses       type filename | more    more

copy file                      copy                    cp
find string in file            find                    grep
                                                      fgrep
compare files                  comp                    diff
 rename file                    rename OR ren              mv
 delete file                    erase OR del               rm
 delete directory               rmdir OR rd                rmdir
 change file protection         attrib                     chmod
 create directory               mkdir OR md                mkdir
 change working directory       chdir OR cd                cd
 get help                       help                       man
                                                          apropos
 display date and time          date, time                 date
 display free disk space        chkdsk                     df
 print file                     print                      lpr
 display print queue            print                      lpq


Unix commands reference card

--------------------------------------------------------------------------------

Environment Control
Command                        Description

cd d                            Change to directory d

mkdir d                         Create new directory d

rmdir d                         Remove directory d

mv f1 [f2...] d                 Move file f to directory d

mv d1 d2                        Rename directory d1 as d2

passwd                          Change password

alias name1 name2               Create command alias (csh/tcsh)

alias name1="name2"             Create command alias (ksh/bash)

unalias name1[na2...]           Remove command alias na

ssh nd                          Login securely to remote node

exit                            End terminal session

sentenv name v                  Set env var to value v (csh/tcsh)

export name="v"                 set environment variable to value v (ksh/bash)




--------------------------------------------------------------------------------

Output, Communication, & Help
Command                     Description

lpr -P printer f
  or
lp -d printer f              Output file f to line printer

script        [f]            Save terminal session to f

exit                         Stop saving terminal session

mailx username               Send mail to user

man name                     Unix manual entry for name




--------------------------------------------------------------------------------

Process Control
Command                     Description

CTRL/c *                     Interrupt processes

CTRL/s *                     Stop screen scrolling

CTRL/q *                     Resume screen output

sleep n                      Sleep for n seconds

jobs                         Print list of jobs

kill %                       Kill job n

ps                           Print process status stats

kill     -9 n                Remove process n

CTRL/z *                     Suspend current process

stop     %n                  Suspend background job n

cmmd&                        Run cmmd in background

bg     [%n]                  Resume background job n

fg     [%n]                  Resume foreground job n

exit                         Exit from shell



--------------------------------------------------------------------------------

Environment Status
Command                     Description

ls     [d]     [f...]        List files in directory

ls -1        [f...]          List files in detail
alias              [name]          Display command aliases

printenv                 [name]    Print environment values

quota                              Display disk quota

date                               Print date & time

who                                List logged in users

whoami                             Display current user

finger              [username]     Output user information

chfn                               Change finger information

pwd                                Print working directory

history                            Display recent commands

! n                                Submit recent command n



--------------------------------------------------------------------------------

File Manipulation
Command                           Description

vi     [f]                         Vi fullscreen editor

emacs              [f]             Emacs fullscreen editor

ed     [f]                         Text editor

wc     f                           Line, word, & char count

cat        f                       List contents of file

more           f                   List file contents by screen

cat f1 f2 >f3                      Concatenates f1 & f2 into f3

chmod mode f                       Change protection mode of f

cmp f1 f2                          Compare two files

cp f1 f2                           Copy file f1 into f2

sort f                             Alphabetically sort f

split              [-n]     f     Split f into n-line pieces

mv f1              f2              Rename file f1 as f2

rm f                               Delete (remove) file f
grep 'ptn'      f            Outputs lines that match ptn

diff f1 f2                   Lists file differences

head f                       Output beginning of f

tail f                       Output end of f



--------------------------------------------------------------------------------

Compiler
Command                     Description

cc    [-o f1]       f2       C compiler

lint f                       Check C code for errors

f77    [-o f1] f2            Fortran77 compiler

pc    [-o f1]       f2       Pascal compiler

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:57
posted:7/24/2010
language:English
pages:14