HOWTOlabs  
 Services     Software     Commentary     Design     Astral Musings   
Linux
Command Reference

man -k [key word]       find manual for command related to a keyword
export VAR=value        'set' a command shell environment variable
                        ~/.profile     user shell commands/variables
                        /etc/profile   global system shell commands/variables
grep -i foo foo.txt     report string foo matches in file foo.txt
set REQUEST_METHOD POST	Example of how to set an environment variable
			... use set to view state
talk willco@inow.com	live chat session, ctrl C to quit
.forward		place this file containing a forward
			address in home directory. chmod 644?

mail
  q		quits and deletes read messages
  pre *		will unread all messages such that quit does not delete them
  w n [file]	saves message body only
  s n [file]	saves entire message 
  x		quits with no message deletion

useradd -u UID -d /home/username -c "User Name" username -m
passwd [opt user]		change password, defaults to current user
passwd -l username		lock out user
passwd -S username		report user password status
smbpasswd user:user		update SMB (MS Windows file sharing) passwd
adduser username		will ask for full user name
gpasswd -a rickatech public	add user to existing group
usermod -a -G public henauker	add user to existing group
groupadd -g GID groupname

pwd			show current file path
rm -R [path/file]       will summariliy delete dir and its children
rm -fr ...              recursive and skips user prompts
cp -a old new           preserve file properties i possible 
chmod 760 [file/dir]	rwx, rw, -
chown [user].[group]
chmod g+s [dir]		new child dir's will inherit parent group
			Users and Groups
grep -i foo foo.txt	report string foo matches in file foo.txt
ps			list your active processes
ps ax			list all active processes
ps aux			list all active processes and show what user they are running under
ps axjf			tree list all active processes
kill [p#]		kill active process by number
kill -n 9 [p#]		kill hung process by number (SIGKILL)
gzip [file1]		compress to file.gz
gunzip [file1.gz]	uncompress to file1
tar cvf [archive] *	create archive file of all files in current directory
tar xvf [src]		extract files from archive
zip -r foo.zip set/*
bzip2 -d foo.bz2
uuencode [src] [name] > [dest]
uudecode [file]
du			recursive directory showing block use
ln [org] [lnk]		make a hard file link
ln -s [org] [lnk]	make symbolic link
foo &			runs foo as background task
tr '\r' '\n' < in > out Macintosh -> UNIX
tr -d "\r" < in > out   MSDOS-> UNIX
history -c		wipe shell history (best performed right before exit)

vi
  /			locate text forward
  ?			locate text reverse
  ma			mark block start
  mb			mark block end
  :'a,'bd		delete block
  yy                    copy line
  P                     insert line below
  G                     move to last line
  :0                    move to first line
  :set nowrap           don't wrap long line, set wrap to enable
  :set ic               ignore case for locate text
  :set noic             use case for locate text
  :sp [file]		split screen, specify different file
			ctrl W to switch between split screens

find [path] -name [file]
find -iname "*.c" -exec grep -i "foobar" -H -n {} \;

df			show disk space usage
diff -b [f1] [f2]       show non-white space differences between files
tail -f [file]		watch file being appended, ^C to end
watch ls -l		2 second refresh of ls command
uname -a		report system information
lsmod			list kernel modules currently active

Helpful DNS diagnostic commands (typically part of bind-utils package) ...
whois zaptech.org
dig jabber.zaptech.org
dig jabber.zaptech.org any
dig @ns1.sparkworx.com jabber.zaptech.org

su -			invoke root shell w/root environment
date -u			output UTC time instead of local time
a2ps -Plp192.168.11.21 foo.c
scp RPMS/apache-1.3.20-16.i386.rpm fredness@tester.local:/home/fredness
killall httpd
nohup ./httpd &		from terminal session, invoke command in background (creates nohup.out)

ci foobar.txt		RCS commit
co -l foobar.txt	RCS checkout
rlog foobar.txt		RCS show commit log
rcsdiff foorbar.txt	RCS diff current vs last commit
rcsdiff foorbar.txt 1.1 1.2

w			show who's logged in
netstat -l              what is listening
netstat -a              what is listening and sending
netstat -tp             show process id of tcp connections

cat /proc/ide/svwks     machine technical attributes
hdparm -i               hard disk technical attributes

.htaccess		this file declares server side include
			and MIME type extensions served

# IP6 ping, require specificying interface
  ping6 -I eth0 -c fe80::20c:29ff:fe13:c50f

# show all filenames, for each name if present also cat the file
  find . -name "*" -exec sh -c "echo file:{} && cat {}" \;

# show files older than 60 days
  find . -atime +60 -exec sh -c "ls -l {};" \;

# fancy ftp handling, may not be part of most distros base install
  ncftpget -d stdout -u username -p passwd -R ftp://somesite.com/public_html

# test pulling slave data from a DNS master
  dig axfr @pentium.lan.zaptech.org zaptech.com

# recursive ftp download using username with a '@'
  wget -r ftp://leighster%40sprintmail.com:password@ftp-www.earthlink.net

# wget, another recursive example
  wget ftp://bubble/httpdocs/* -r --user bubble --password pop

# copy a file, then use sed to find/replace string, e.g. '<' -> '&lt;'
  cp foo baz; sed -i -e 's/</\&lt;/g' baz

# Find all files with name Root, search and replace text
  find -name Root -exec sh -c "sed -s s/happy-neuron.com/63.131.132.56/g {} > sed; mv sed {}" \;

Elsewhere Links [ edit ]

zap technologies
tablet | printable