Startseite Majordomo CSS Unix Intro HTTP

Quick reference to simple Unix commands

  • Introduction:


    There are only a few commands that you have to know in order to get started on Unix. These will be presented in this introduction. For a more detailed description of the syntax od the commands and available options, you can consult the help files ( so called manual pages ) on the computer, or read a good Unix book.
    I know that it is quite boring starting to read books. I hope that you will enjoy this quick reference.
    Unix commands sometimes have cryptic names and a very strict calling sequence for their options and parameters. The commands are case senitive, as are the file names on the system, but most of the Unix commands are lower case letters. Options are usually preceded by a "-" sign,or sometimes by a "+" sign.

    The general syntax is :

    command – options parameter

    As usual there are exceptions. Most commands allow more than one option. Theses options can either be put individually on the command line ( e.g. cmd –1 –2 –3 … ) or combined to a single option string ( cmd –123 … )

  • File and Directory Names:


    Unix has a tree like file and directory structure, where you can address any file or directory with its absolute path name starting at the file system root ( denoted by / ), or with a name relative to the current position in the file tree.

    .

    the dot denotes the current working directory

    ..

    two dots denote the directory above the current one

    /sbin/lib/joe

    is an absolute path name for the command file joe

    ../otherdir

    is a directory parallel to the current

    subdirectory

    is the name of a subdirectory below the current one

    ~

    is your home directory

    ~marc

    home directory of the user marc

    .controlfile

    name of a control file in the current directory ( e.g. for mail, editors, … )
    usually these "dotted files" are found in the home directory

  • Manipulate Files:


    Wildcards ( ? single character, * word ) are very useful in handling files. Be very careful when you use wildcards with the copy, move or remove command. Unix will delete or overwrite existing files without warning. Normaly the cannot be restored.

    cat name

    list file with name name

    head name

    list first 10 lines of file ( option –number, e.g. head –20 for the first 20 lines)

    tail name

    list last 10 lines of file ( option –number, e.g. tail –20 for the last 20 lines)
    tail –f continuously lists the end of a file : This can be used to check the system.
    tail –f /var/log/mail shows what sendmail is working

    less name

    list file page by page

    cp name newname

    copy file to new name or new directory

    mv name newname

    move file to new name or new directory

    rm name

    remove file ( At the beginning please use the option –i in order to be prompted before deletion
    rm * will remove all files in the directory

    file name

    analyse file type and contents

    find path-name expression

    find a file in the file tree (relatively slow)

  • Manipulate Directories:


    mkdir name

    create a directory with name name

    mkdir name

    remove a (empty)directory with name name

    cd name

    change to working directory with the name name

    pwd

    print working directory ( = print name of the current working directory )

    ls name

    list contents of the directory with the name name
    ( = under DOS =: dir )
    if name is omitted, the current working directory is listed
    options : ls -lsa
    -l long detailed listing ( owner group rights ...)
    -s shows the file size in KB
    -a lists also the dotted files

  • Miscellaneous Commands


    chmod rights file

    change access rights ( who±right )of files or directories,
    e.g. chmodg+x filename will add execution right for members of the group
    chmodu+x filename will add execution right for user
    chmodg+rwx filename will add reading, writing, execution right for members of the group

    who

    list all logged in users on local machine

    passwd

    change your password

    finger user@host

    list information about ussers on local or remote machines

    last

    display last login information of users on the system

    grep string file

    find a string or regular pattern in a file

    diff file1 file2

    display differences between two text files

    tar

    tape file archiver ( files with name.tar )

    su user

    change the user

  • Root Commands


    chown user.group file

    change owner and group of files or directories,

    chgrp group file

    change possesion of files or directories,

    shutdown

    switch off the server

    reboot

    shutdown the server and restarts it

Top
© 2000 by Sprott Networks Service Center (helpdesk@sprott.net)
© 2000 by Sprott Networks Service Center