UNIX Commands


Contents


To get into UNIX on HP workstation

Using either the center or the right mouse button to click on the grey area (desktop) behind your graphics window. Choose system utilities. You can use either an "xterm" or "hpterm" window. You should see a "$" or "#" character depending on which types of window you are using. You are now at the UNIX prompt. You can begin typing commands.


Directory tree

/users/[a-z]/[username]: User data
/users/[a-z]/[username]/arch: Archived user data
/release: Released files
/stdvendor: Standard and Vendor parts
/grip: Grip programs
/training: Training exercises
/hotbk/users/[a-z]/[username]: Hot-backup of several days of user data
/edf: EDF zone models, EDF layout files and pattern files
/utils: UNIX and UGII utility programs


Wild characters and other special characters

* zero to many characters
? single character
~(tilde) directory of, e.g., cd ~kimc changes directory to /users/k/kimc
. (dot) current directory
..(double dots) parent directory
| (vertical bar) pipe command


Directory commands

cd /directory: changes current direcoty to directory
cd: takes you to your "home" directory
cd ..(double dots): takes you to parent directory
cd -: takes you back to the directory before the last cd command
cd ~username: change directory to username
cd ../..: go up two directories

pwd: tells you what present working directory(pwd) you are currently in

ls: short listing of pwd
lsf: short listing of files and directories in pwd. The directories in pwd are marked with "/".
ll or ls -l: long listing of pwd which show permission for files and directories
ls -a: short listing of pwd including invisible "dot" files
ll -d directory: displays permissions for a directory
ll -t: sort by time modified (latest first) before sorting alphabetically
ll a*: long listing of all files beginning with "a"
ll *a*: ong listing of all files with "a" in their names
ll ?a*: long listing of all files whose name has "a" on second position
ls [edf]*: short listing of all files beginning with "e", "d", or "f"
ls [a-g]*: short listing of all beginning with "a" thru "g"
ll [0-9]*: long listing of all files beginning with a number


Copy files

You must have write permission of the destination directory you are trying to copy a file to.

cp file1 file2: copy file1 to file2 in pwd. If there is file2 already in pwd, it will be overwritten
cp -i file1 file2: prompts user before overwriting file2
cp ../file1 .: copy file1 in the parent directory to pwd without changing name
cp ~kimc/file1 .: copy file1 in /users/k/kimc directory to pwd without changing name
cp ~kimc/file1 ~username: copy file1 in /users/k/kimc to username directory with same name
cp ~kimc/1f*.prt .: copy all files in /users/k/kimc directory whose name start with 1f and end with .prt into pwd. If two or more files are copied, the destination must be a directory.


Print files

lp file1: prints file1 to the default printer
lp -dlw5a47 file1: prints file1 to lw5a47
lpstat printer: shows status of a printer


Move or rename files

mv file1 file2: renames file1 to file2 in pwd
mv file1 dest_directory: moves file1 to dest_directory with same name
mv file1 dest_directory/file2: moves file1 to dest_directory and renames it to file2

/users/k/kimc/rname: script file written by Jim Lawson to replace old text string in multiple files with the new text string


Remove (delete) files

Warning: rm removes file(s) without asking for confirmation. Use rm -i instead of rm or list file(s) before actually removing them especially when using wild characters.

rm file1: removes file1
rm -f: force remove file or directory without prompting for confirmation
rm -i: requests confirmation before removing each entry
rm -r or rm -R: removes everything in a subdirectory and the directory itself. Be very careful.


Working with files

chmod: changes permissions for file or directory
chmod 600 file: changes permission to read/write for owner
chmod 660 file: change permission to read/write for owner and group
chmod 644 file: change permission to read/write for owner and read for group and other (default)
head file1: displays first 10 lines (default) of a file1
more file1: to view the content of a file1
tail file1: displays last 10 lines (default) of a file1
tail -n file1: displays last n lines of a file1
vi file1: create or edit a file1.


Miscellaneous

grep word: to find all occurrences of word in piped input
date: displays time and date
cal: displays current month
cal 96: displays 1996 calendar
clear: clears the screen
echo: displays variable
echo $PATH: displays the content of a variable PATH
env: obtains the current environment

To find a file run CAD Utilities under pull down menu.


Examples

ll | grep word: lists all files containing word in pwd
ll | grep 'Oct 17': lists all files modified in Oct 17, single quotes needed due to embedded space(s) in search string
ll | lp: lists pwd and pipe the output to the default printer
ll -t | grep macro | lp -dlw5a47: sorts by time (latest first), then grabs files containin macro and prints to lw5a47