Sunday, August 8, 2010

Some Useful UNIX Commands


  • Changing your password:

    passwd
    Change your password. Do this regularly, and keep your password secret.

    File manipulation commands:

    cp file1 file2
    Copies file1 to file2. mv file1 file2
    Moves file1 to file2. If the arguments are in same directory, this command just renames file1 to file2. If file2 is a directory, file1 is moved to that directory rm filename
    Removes filename. cat file1 file2
    Concatenates file1 and file2 and prints the result to the screen. cat file1 file2 > file3
    Concatenates file1 and file2 and puts the result into file3. more file1
    Prints file1 to the screen, but pauses when the screen is full. less file1
    Another paginator, similar to more. lp file1
    Sends file1 to a printer. cancel job-id
    Cancel a printer request. You must use the job identification reported by the lp command when you ran it. lpstat
    Show the print queues. You can use this to show how many print requests are ahead of (or behind) yours in the queue. lpq will also report request ids, if you forget them.

    Directory commands:

    ls
    List the contents of the current directory. ls dirname
    List contents of the directory dirname. ls -a
    List all the files in a directory, including ones whose names begin with a period (.) ls -l
    Long listing. List the contents of a directory, with the protection, owner, size, modification date, and name of the files. ll
    Long listing. Synonym for ls -l. pwd
    Print working directory. Prints the name of the current directory. cd dirname
    Change directory. Changes the current directory to dirname. cd ..
    Change to parent directory. Moves up one level in the directory hierarchy. cd
    cd with no arguments will change the current directory to the home directory. cd ~
    ~ is shorthand for the home directory, so cd ~ will change the current directory to the home directory. cd ~username
    ~username is shorthand for username's home directory, so cd ~username will change the current directory to that user's home directory. mkdir dirname
    Make directory. Creates a new, empty directory named dirname. rmdir dirname
    Remove directory. A directory must be empty before it can be removed. du
    Disk usage. Summarizes the space taken up by all the files in a directory and its subdirectories. quota -v
    Report information about your disk quota.

    Electronic mail:

    pine
    Bring up the Pine mail reader. pine username
    Send mail to another user.

    Editing:

    emacs file
    Emacs editor. vi file
    vi editor.

    Document preparation:

    latex file
    Invokes the LaTeX typesetting program. dvips file
    dvips converts the output of LaTeX to postscript for the printers. The output is automatically sent to the printers unless the -o option is used. ispell file
    Spelling checker. xfig
    Drawing program. xdvi file
    DVI previewer. Displays a DVI file produced by LaTeX on the screen. You can use previewers to check how a document looks without wasting paper to print it. ghostview file.ps
    Postscript previewer. Displays a postscript file on the screen. Another good way to save paper.

    Languages:

    cc
    c compiler. g++
    c++ compiler (GNU). f90
    Fortran compiler. pc
    Pascal compiler. make
    Utility for building and maintaining large programs.

    On-line manual pages:

    man cmd
    Bring up the on-line manual page for a command. man man
    Bring up the on-line manual page for the man command. man -k keyword
    Searches all the manual pages for ones relevant to the keyword.

    Miscellaneous commands:

    date
    Shows current date and time.
    Link
    who
    Shows other users logged into a system. w
    Shows other users logged into a system, and what they are doing. grep pattern filename
    Searches files for lines containing pattern.

    Exiting:

    exit
    Exits an xterm window. If you are logged in remotely, this command will log you out of the system.

    No comments:

    Post a Comment