| CIRCA NERDC Services
This handout can be found online at: | Quick guide to Unix commands
on NERSP January 25, 1999 |
Files are stored in directories. You have a home directory to store your files in, and you can create more directories in your home directory.A pathname is a complete specification for a file with all its directories. An absolute pathname begins with a slash and specifies the full name of the directory, for example:
/home/bob/prog.c
A relative pathname is based on the current working directory. For example, this pathname specifies a file named test in the subdirectory project1:
project1/test
These special symbols can be used in a path:
symbol meaning ------ ------------------------------- ~ your home directory . the current directory .. the directory above the current directoryThese examples show where Unix would look for the file abc based on the path you specify:
abc in the current directory subs/abc in the subdirectory subs of the current directory /staff/fred/abc in the directory /staff/fred ../abc in the directory above the current directory ~/abc in your home directory
In Unix, upper case and lower case letters are not equivalent. You must type commands in the correct case. Almost all Unix commands are in lowercase.Many commands have optional flags. Flags are usually preceded by a "-" and are typed as a single letter. For example, the "a" and "l" flags on the ls command:
ls -al /etc
Some commands require a parameter, such as the name of a file. For example, to display the file emacs.txt:
cat emacs.txt
If a file name without a path is specified on a command, the file is assumed to be in the current directory. You always can specify the complete path for the file.
When a file name is used on command, you usually can use wild cards to specify a group of commands. A question mark (?) in a file name means that any name with any character at that position will match. An asterisk (*) will match a group of characters.
These are some commands you can use to display information about your Unix system:
command what's displayed ----------- ------------------------------------------ man command online manual page for command whatis command one line description of command apropos keyword names of manual pages that are relevant to specified keyword pwd current directory pathname who who's logged in date date and time
These are some of the commands you can use to display or manipulate files on your computer:
command function ------- ----------------------------------- rm remove (delete) named file or files mv move (rename) a file to a new name cp copy the first file to the second file cat display file on screen more display file, pause for each screen head display first few lines of a file tail display last few lines of a fileHere are some examples of these commands:
rm test.f delete the file test.f cp proj.c saveme copy the file proj.c to the file saveme more log.txt displays the file log.txt, stopping at each screen
The ls command displays the names of the files in a directory. Some ls command options are:
option meaning ------ ------------------------------------------------ a include files with names starting with a period l list in long format with sizes and dates R list files in subdirectories also F mark directories with /, executable files with *Here are some examples of the ls command:
ls list names of files in current directory ls -al list all files in long format ls /etc/bin list files in /etc/binThese commands manipulate directories and require the name of a directory as a parameter.
command function ------- ----------------------------- cd change to specified directory mkdir make a new directory rmdir remove (delete) a directory
File permissions give other users the ability read, write, or execute a file. Permissions can be granted to another user in your group, or all others. Use the chmod command to change file permission for a file:chmod who+/-permission file
who means permission means --- ---------- ---------- ------- u you r read g your group w write o all others x executeExamples:
chmod go+rx xyz let all others read or execute the file xyz chmod go-rx xyz retract read/execute permission from group and others
Resources
NERDC produces a NERDC Unix
101 introduction and Quick
Reference Card for users of nersp Unix as well as other
documentation.
Select the link On-Line
Documents from the NERDC home page at http://www.nerdc.ufl.edu.
Call the UF Computing Help Desk for Assistance (352) 392-HELP
SUNCOM 622-HELP