Unix Tips

.cshrc:

add these line at the end of this file in your home directory…

set filec # to make the filenames have tab completion.

entenv PRINTER apm3414a
# to set the default printer to the line printer in
# Sunpal. Then you can just type 
lpr filename to print rather 
# than
 lpr -PAapm3414a filename

# change prompt to show the current working directory as the prompt
set prompt = "`pwd`% "
alias cd 'cd \!*;set prompt = "`pwd`% "'

.login:

add these line at the end of this file in your home directory…
alias cd.. cd .. #aliases cd to allow cd.. to change to parent directory
alias ls ls -p # print a slash after directory names in c shell
alias dir ls # make dir and ls both print the directory
quota -v #print out remaining space useage in your account
bash # start bash command shell, make this be LAST because anything
     # after this command will not run until bash exits

Aliases

how you do this depends what shell you are running
csh: alias newname oldname
bash: alias newname='oldname'(to cancel any of the aliases temporarily, use unalias newname)

Program&

running a program from a terminal window so the program will not quit if you close the terminal window: add an & to the end of the program name for example, xemacs& or xemacs test.java &

Finding A Program

which program_name = gives the path to a program name
locate file_name = searches for a file on the hard disk

bash shell tips:

to start bash type bash. to quit type exit.

.bashrc

edit (or create) the .bashrc file with:
PS1='\W>' # changes the command prompt to show the current directory
alias ls='ls -p' # show a "/" at the end of directory names in LS
alias cd..='cd ..' # allow dos style directory changes
alias logout='exit' # allows logout to exit bash and then type
                    # logout again to kill a telnet connection

why run bash?

-“tab” filename completion
-“up arrow” recent command list *especially this reason*
-backspace and delete BOTH type a backspace (no more ^H) when you hit backspace instead of delete by force of habit

Grep

usage: grep -options searchstring filemask
what does grep do? searches for text in a file.
-i = case insensitive
-n = show line numbers
example:
jwinblad>grep -n cd .login
24:alias cd.. cd ..
ucsd/acs grep reference

Help/Man

man flename -> gives help on a program or topic

Ls

useage example: ls -pF ~/../public-a = show hidden files (filenames starting with a dot)
-A = show hidden files but not the current directory and parent directory
-F = indicate the filetype with symbols (directories, executables, links, etc)
-g = -l without showing file ownership
-l = long format (shows more file details)
-m = comma seperate items instead of tab alignment
-p = adds / to the end of directory names
-t = sort by time
-R = include subdirectories
-s = show size of files
-x = sort files horizontally rather than vertically

ls options are case sensitive

chmod:

method 1: sum the permissions
4=read 2=write / 1=execute
order: user, group, other
eg. chmod 755 index.html will set permissions to “- rwx r-x r-xmethod2: add/remove by name
u = user / g  = group / o = other / a = all 3 groups
+ = add permission /  = take away permission
r = read / w = write / = execute
eg. chmod ug+rw index.html will change permissions to “- rw? rw? ???” (?’s are not affected)

groups
groups = displays the groups you are in
chgrp <groupname> <file-or-directory> = changes the group for a file

tar

basic usage: tar cvf [output file] [files to archive]
COMPRESS:
tar -cvf backup.tar *.java *.cup will compress all the .java and .cup files in the current directory
UNCOMPRESS:
tar -xvf filename.tar ~uncompresses the files in filename.tar to the current directory

processes

ps -fu jwinblad ~displays all processes running by user jwinblad
kill -9 pid-number ~kills a process with pid# of pid-number