Commands

This document will cover the generic Unix commands that are largely the same on all flavors of Unix.

crontab         show cron jobs
        -l = list
        -e = edit
        -r = remove  (no confirmation, everything gone for the user!!)
        # file format: 
        # minute hour day-of-month month day-of-week0=sun cmdline 
        # 0-59   0-23 1-31         1-12  0-6              echo "Hello World!"


newgrp	groupname	# change the default group user will create file as 
			# only last for current session
			# Can prompt for password if group is password protected?


wget

-h		= brief help, no man pages needed.
-r 		= recursive
-l1  		= depth level, default to 5
--no-parent	= don't bother with ref to parrent dir (-np)
-A.gif		= download only .gif files

-c		= continue previous interrupted downlooad
-nc		= no clobber of existing files
-b 		= process job in background, returninng to prompt
--passive-ftp	= use passive ftp

-k		= change link ( convert non-relative llinks to relative)
-m		= mirror site  options, eg, download ffile only if newer.
-l=20		= retrieve to depth = 20

--http-user=USER	= web page with user/logiin req
--http-passwd=PASS
--convert-links		= convert the downloaded  html link to local files
-Pdownloaddir		= place downloaded file in  downloaddir instead of the www.server.com/ name.


eg download only *.gif files from server
wget -r -l1 --no-parent -A.gif http://www.server.com/dir/

eg2, ftp with username and password as username:password@site:
wget ftp://hniksic:mypassword@unix.server.com/mydir

eg3: download ibm patches, which is dir with set of links.
wget --glob=on --retr-symlinks --level=1 ftp://service.boulder.ibm.com/aix/fixes/pkgs/p3dia/* 

eg4: getting suse linux from ftp site:
wget -r -m  -np -c -l10 ftp://ftp.oregonstate.edu/pub/suse/suse/i386/8.2/

wget obeys robot rules. in file /robot.txt

If proxy is mandatory, set the proxy server thru env var http_proxy and ftp_proxy.  eg:
setenv http_proxy "http://proxy.nova.org:8080"
export ftp_proxy="http://proxy.nova.org:8080"
If auth is req, wget has parameters to submit these also.  



rsync
rsync -avul source /path/to/destination
            sync ./source to /path/to/destination
            source or destination could be NFS mounted location.
            only newer files in local dir will be copied to dest
            if dest has newer file, they will not be changed.
      -a    archive mode, preserve sym link, attributes, owner/perm, etc.
      -n    dry run, use w/ -v and will list files that will be cp'ed
            w/o actually doing it.
      -l    copy sym link as sym link (like tar)
      -L    copy file refered by the sym link
      -z    use compression during transfer (when used with remote host)
	--delete	delete files in dst that is not in source
			Use this to sync/backup user /home during migration
	--preogress	show progress (useful when not in -v?)

rsync -avuL /f /cygdrive/p/backup_of_master_data_DrvF
            cmd used at home in win2003 to backup all data to removeble ide drv.
            does not support funky chinese mp3 filename :(


rsync -avl -e ssh  --rsync-path=/usr/local/bin/rsync remote-svr:/dir/* ./local/storage
	use ssh as transfer protocol with remote machine
	allow specification of where rsync is located on remote host
	either source or destination machine could be a server: kind of entry


screen
screen
work as usual

ctrl-a,d  = detach
crtl-a,x  = lock keyboard
ctrl-a,?  = help
screen -r = resume
screen -w = list screens
screen -d -r  reatach remote and retach here
ctrl-a,c  = create new window ( or enter screen  w/in an existing screen window)
ctrl-a,n  = switch to next window
ctrl-a,p  = switch to prev window 
ctrl-a,w  = show list of window
ctrl-a,'
ctrl-a,"  = prompt for window name or number to switch to
ctrl-a,0  = switch to window number 0 (to 9, enter - for blank window)
ctrl-a, A = prompt for a title name for current window
ctrl-a, N = show number and title of current window
ctrl-a, k = kill current window
ctrl-a, S = create split window mode
ctrl-a, ^I= move focust to next split window (^I=TAB).
ctrl-a, [ = history, allow scroll back, but really for cutting text into buffer.  
            Enter marks begin pt, move around.  Enter again marks end pt.


ctrl-a,a  = send ctrl-a to the terminal
ctrl-a,tab= switch input focus to next region
ctrl-a,ctrl-b= send a break

RCS
co -l  check out file (with lock) from rcs sys
co -r  check out revision  or the latest verstion, will prompt to overwrite co -l files (at least then when you do ci, it will say file not changed and effectively reversed to original content)
ci     put file back into rcs  
ci -u  (the -u leave a read only copy of the file, as if run co immediately after ci, always use it:))

rlog 	display rcs edit log 
rcsdiff 	display diff b/w current file content and its previous version
rcsdiff -r1.1	display diff b/w current file and version 1.1 of the file
rcs -u 	forces an unlock a file locked by some other user.
rcs -aUID FILE	add access for user UID to the FILE (but didn't work, maybe file need to be group writable).




TBD




cd - (cd to previous dir)

!$   (last param of previous command)

netstat
memstat



actually, don't think can just pipe to at.  so this won't send mail at later time... check danny's mail8r script... make it work in n10 only is fine...
use at for email reminder: mail -s 'subject' tho01 | at 10:00am 
type message, ctrl-d to end
note: dizzy support -s 'subject' , 
grads, sdb1, does not support -s, just have subject: in message section
n10 does not support -s option at all




sh -x 	 is the regular way of executing a bourne shell script
		invoked like this will show each command as they are carried out

tail -f  monitor file as it grows
sdiff  -s = do not print identical lines

scp remote-host:remote-path local-host:local-path
	secure copy b/w 2 comp on the network




edit-assign vi = edit $HOME/.hpdrc-assign/assignment file
rishen hours    = report prj of past 2wk hours 

assigning  = edit assignment file of other users
edit-rcs vi  = edit assignment files of past employees, must be in the dir and use assignment as the filename 

#/home/rvc-d1/mgutie01/rsi/envi/bin/envi to run demo ver of envi
#/disk/73/agonza24/envi_3.0/bin/envi  for new version of envi on sdb1
envi run as aliased command now

/usr/local/bin/pine

gimp        image editor in solaris
sdtimage	image viewer in solaris CDE default setup, in /usr/dt/bin

last        see who last logged on to the sys (a long log)
acroread    launch acrobat reader for .pdf file
xpsview     adobe ps viewer that comes with irix 6.5
ghostview   view .ps file
gs          view .ps file, command mode
ghost       my script to launch gs in alex linux box
ps2pdf      convert from ps to pdf file

pushd .     push current dir into stack  (aliased to pu)
popd        pop the pushed dir (ie change back to old dir; alias po)
pushd \!*   jump b/w last pushed dir (aliased to xd)

tar -zxvf file {-C dir}   untar and uncompress
tar -zcvf file  *         tar and compress current dir, files still remain



kill -9 -1 kill every single process i own w/in the server.
fold -w80    wrap long line to max 80 column

fmt -w{72}   wrap long line to less than 72, keeping word together
frontier


mail user < filename
mailx -s "subject" tho@brio.com < filename (solaris)
      -v	# verbose, give SMTP session dump, good for debugging.

to log out of sgi session remotely:
/usr/bin/X11/endsession -f -display n10:0

sendpage -q -p  ""


lpr  -P 	 print file
lp   -d  
lpq  -P             show lpr queue 
lprm -P [JobNum]    mustang (delete) print job 
                                 if no JobNum, remove 1st submitted job
# in solaris, will print two page per sheet, double sided.
# mp is an ascii to ps prettyfier 
# -l landscape, print two sheet per page
# -o format ascii
# mp is in /bin, /usr/bin, /usrlocal/bin , cs is /usr/openwin/bin/mp
mp -l -o -s "subject/title" < infile | lp  -o nobanner -d chicago-duplex

/etc/printers.conf contain list of installed printer 

tar  -zxvf  [-C ]      untar (and ungzip with z option)
gzip -d                  ungzip .gz file
uncompress                uncompress .Z file


/depot/ermapper/ermapper


df -k              free hd space
df -k .            free hd spcace on current hd only
cat -vte			-vte = display all tab as ^I, eof marked by $   

ypcat passwd	show /etc/passwd file from dns server
yppasswd	change password on all system


smbclient "\\hills\tho01"      connect to nt drive

f45desm    form designer for oracle/unix in Motif
r25desm    report designer, but does not seem to work

/disk/1/app/oracle/product/732/bin/browser20em    oracle databrowser

snapshot     screen/capture program for unix, diff version for sun & sgi

run a program on remote computer w/o firt logging in
  -d  [param]
eg:   n103 nxterm 
      grads netscape -d n10:0 &


find options
-user 		: find all files owned by user
-exec  {} \;	: {} represent the matched entry (full path)
			  cmd will be executed with {} as arg
			  \; is required to end exec section

eg

finding files: (not 'correct' usage, but works :)
find . | grep 'filename'
or
find . -name FILENAME -print

find . -user root  -exec chown weblogic:weblogic {} \;
	run in weblogic dir, replace all files owned by root to weblogic
	(remember to change back to root the startWebLogic.sh back to root)

find . -perm -o+w -exec ls -l {} \;
	long listing of all files whose permission is world writable

find . ! -user tho01 -print
	list all files whose owner is not tho01

other cmd: ls -l, so to see full listing of file instead of just path, but any entry that is a dir will return rather long listing...  (can use  type=file only to skip dir):

find . -type f -ctime -5 -exec ls -l {} \;		# files modified less than 5 days ago.

grep pattern 	-A 3 	# show the maching line and 2 more lines After it
		-B 3	# show the maching line and 2 more lines Before it


xargs    	# grab a list of lines with single entry and turn it into a multi item single line list.  eg:
		# ls -1  | xargs echo       			# will be equiv of echo *
		# find /nfshome -name .rhosts | xargs chmod 600 

--

/usr/bin/logger -p daemon.notice "test msg by tin"
		append message to syslog, at level indicated by -p.



[Doc URL: http://www.cs.fiu.edu/~tho01/psg/general_unix.html]
(cc) Tin Ho. See main page for copyright info.


"LYS on the outside, LKS in the inside"
"AUHAUH on the outside, LAPPLAPP in the inside"