California State University, Sacramento

Home
Syllabus
Assignments
Contact
Grades

UNIX

Here is what I consider to be "Just barely enough UNIX" to do work in the course. These instructions will be explained as you need them, so you do not need to memorize them.


  • List files in current directory

    ls : list all files by name only
    ls -alsg : list all files by name, date, protection, etc.
    ls -d */ : list all sub-directories only
    ll : same as ls -alsg without hidden files on HP-UX systems such as Gaia
    ll -al : list even hidden files


  • Change Current Directory

    cd <directory name> : change directory to new <directory name>
    chdir <sub-directory> : change to the directory under the working directory
    cd .. : change directory up one level (space between cd and ..)
    cd : return to home directory (top level)
    pwd : displays the current directory path


  • Make a New directory

    mkdir <name> : makes a new directory under the working directory


  • Move a file

    mv <filename> <path-to-the-newplace> : moves the available file named <filename> under the working directory to the location specified. The file will exist only at the new location.


  • Help

    man <command> : you must know the exact name of the command ; e.g. man ls


  • Print file to the main line printer in room ECS 2011

    lp -d<queue name> <filename> e.g. lp -printername memo.txt
    (Only works on Gaia)


  • Display contents of a file

    more <filename> : Print to the screen; e.g. more memo.txt
    This will display the file memo.txt on the screen one page at a time

    Also, tail -10 memo.txt - Displays the last 10 lines of memo.txt
    And, head -10 memo.txt - Displays the first 10 lines of memo.txt


  • Delete files

    rm <filename> : Will delete the file (DOES not give you a second chance!)

    And, rm *.gif ; Remove all files with extension .gif
    And rm *.* ; Removes everything in current directory
    (Be VERY careful with this command)


  • Change your password

    yppasswd (Reply to each prompt accordingly)


  • Diplay users logged-in at this time

    w OR who OR rwho


  • The pipe (|) command will allow you to combine commands

    <command> | <command> e.g. ls -al | more
    This will list a directory one page at a time


  • Logout

    lo OR logout OR bye


  • Change File Permission

    chmod <nnn> <filename> : each n= an octal digit where: 0 = none, 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--.
    This is tricky and will be discussed in lecture when you need the command.


  • JUST FOR FUN

    * ping <site address> e.g. ping oak.oakland.edu
    Use Ctrl-C to hold the screen to read.
    * traceroute <site address> e.g. traceroute oak.oakland.edu


  • Commands that are useful when using FTP

    cd <directory_name> : Change directory to <directory_name>
    ascii : For transferring ascii files
    binary : For transferring binary files
    dir : Full file directory
    ls : Short file directory
    dir |more : List files and directories one page at a time
    quit : exit ftp
    cd .. : back up one level in file structure
    get <filename> : downloads file
    get <filename> |more : lists contents of files on the screen one page at a time
    dir *.txt : lists all files that end with .txt
    dir README.* : lists all files that begin with README.
    ! : temporarily leave the ftp site and return to your local system -- to return to ftp, enter "exit"


FILE AND DIRECTORY PROTECTION

Information about files and directory information obtained by dir, ls or ll

File privileges are:
r for read ; w for write ; x for execute

For example: ?rwxrwxrwx The first column will be: d for directory, - for text file, or l for link to other file.

The first rwx indicates the owner privileges. The second rwx indicates the group privileges. The last rwx indicates the other user privileges (you and me when we are doing anonymous FTP)