Study Group: Stupid UNIX Tricks
Friday 2/6/04 6-8PM
Leavey Library, Learning Room B (down the stairs, hang a left)
------------------------------------------------------------------------------
There are 25 OSX.3 (G4) workstations available. There is also USC wi-fi -
feel free to bring your own systems; OSX or Linux machines can of course
follow along locally.
Unix Basics
------------------------------------------------------------------------------
Those who fail to learn from Unix are doomed to repeat it
Concepts: http://www.usc.edu/isd/doc/os/unix/concepts/
* Worse is better, end-to-end
* UNIX is command-based
* Multi-user system
* Everything's a file
* Permissions
* Piping
* Links/Symlinks
Must-Know Commands
* ls, cd, pwd
* cp, mv, rm
* chmod
* echo, cat, more, less
* pico, nano
* tar, ln, alias
* man
* exit
Basic File Layout
* Filesystem Hierarchy Standard
http://www.pathname.com/fhs/
* Linux Standards Base: File System Hierarchy
http://www.linuxbase.org/spec/booksets/LSB-Core/LSB-Core/execenvfhs.html
Additional Reading:
* The Art of Unix Programming
http://www.catb.org/~esr/writings/taoup/
* UNIX Tutorial for Beginners
http://www.ee.surrey.ac.uk/Teaching/Unix/
Stupid UNIX Tricks
------------------------------------------------------------------------------
My config files:
bash
.bash_profile
.bashrc
.vimrc
X11
.Xdefaults
* How to find out how to do things
* -h, --help
* man, man -k (apropos)
* locate, whereis, find, find | grep
* http://www.google.com/linux
* Keywords
* howto
* tutorial
* ~guide
* The Linux Documentation Project
* USCLUG mailing list
* consult @ usc
* Things to immediately change with your USC account
* chsh to /usr/usc/bin/bash
General usefulness
* OS X
* X11
http://www.apple.com/macosx/features/x11/download/
* Fink
http://fink.sourceforge.net/
* MacOS X 10.2 for UNIX Users - General Mini-FAQ
http://cosmic.homeunix.net/osxfaq.html
Resources:
* macosxhints
http://www.macosxhints.com/
* OSXFAQ
http://www.osxfaq.com/
* Windows
* putty
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
* Cygwin
http://www.cygwin.com/
* Windows Services for UNIX 3.5
http://www.microsoft.com/windows/sfu/
* Bash Tricks
* Command Completion, History searching
* [tab]
* C-r
* history
http://www.gnu.org/software/bash/manual/bashref.html#SEC114
* Line Editing
http://www.gnu.org/software/bash/manual/bashref.html#SEC90
Resources:
* Working more productively with bash 2.x
http://www.caliban.org/bash/
* Bash Guide for Beginners (Mirror)
http://tille.soti.org/training/bash/
* Aliens Bash Tutorial [264KiB] - Good reference
* BASH Frequently-Asked Questions
http://www.faqs.org/faqs/unix-faq/shell/bash/
* Bash Reference Manual
http://www.gnu.org/software/bash/manual/bashref.html
* BASH Programming - Introduction HOW-TO
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
* Advanced Bash-Scripting Guide
http://www.tldp.org/LDP/abs/html/
* Moving files onto and off the system
* scp, sftp
* Local Clients
* Windows
* winscp
http://winscp.sourceforge.net/eng/
* Mac
* Fugu
http://rsug.itd.umich.edu/software/fugu/
* Transmit
http://www.panic.com/transmit/
* UNIX
* yafc
http://yafc.sourceforge.net/
* rsync
* backups using rsync+ssh how-to simplified
http://killyridols.net/rsyncssh.shtml
* Scheduled Events
* cron
* Newbie: Intro to cron
http://www.unixgeeks.org/security/newbie/unix/cron-1.html
* Cron Tutorial. Cron, the linux event scheduler
http://www.linuxforums.org/forum/viewtopic.php?t=4017
* at
* permissions (including sticky bits)
* advanced piping
* command chaining, simple scripting (using variables)
* nicing/backgrounding/killing processes (top, ps, etc)
* fg
* bg
* suspend
* nice
* renice
* understanding grep and regexes
* The Regex Coach - great Windows app for regex visualization
http://www.weitz.de/regex-coach/
* Using Regular Expressions
http://etext.lib.virginia.edu/helpsheets/regex.html
* A Tao of Regular Expressions
http://sitescooper.org/tao_regexps.html
* Learning to Use Regular Expressions
http://gnosis.cx/publish/programming/regular_expressions.html
* Vim Regular Expressions 101
http://larc.ee.nthu.edu.tw/~cthuang/vim/files/vim-regex/vim-regex.htm
* Rx Cookbook
http://aspn.activestate.com/ASPN/Cookbook/Rx
* more text processing (less, wc, diff, sed/awk and friends)
* vi basics (.vimrc)
* :q
* moded editing
Useful Vim tips
* Visual mode
* shifting indents (>, <)
* gqip, gqap
* macros
* :r! (r!date)
* :TOhtml
Resources:
* VIM Quick Reference Card
http://tnerual.eriogerg.free.fr/vim.html
* Vim Documentation
http://www.vim.org/htmldoc/
http://www.vim.org/htmldoc/help.html
http://www.vim.org/htmldoc/howto.html
* Vim Tips
http://www.vim.org/tips/
* Using Vi/Vim: A Brief Tutorial
http://www.people.fas.harvard.edu/~cduan/technical/vi/vi-1.html
* Professor Norman Matloff's Vim Web Page
http://heather.cs.ucdavis.edu/~matloff/Vim/NotesVim.NM.html
* fun w/ logins
* authorized keys in SSH
* SSH with Keys HOWTO
http://www.puddingonline.com/~dave/publications/SSH-with-Keys-HOWTO/
* screen
* Tutorial: Use GNU Screen (in UNIX)
http://cosmic.homeunix.net/blog/old/00000018.html
* Installing and Using GNU Screen
http://www.sun.com/bigadmin/features/articles/gnu_screen.html
* terminal fun (who, talk, write, etc)
Indispensibly Useful commands
---
ps, kill, vi
head, tail, watch
popd, pushd, dirs
wget, curl, lynx
xargs (rawr!!!)
* invaluable when using w/ find
* Using the xargs Command
http://www.unixreview.com/documents/s=8274/sam0306g/
* Week 49 - 'find' and 'xargs' (30 June 2003)
http://www.osxfaq.com/tips/unix-tricks/week49/friday.ws
* setguid'ing folders:
find . -type d -print0 | xargs -0 chmod g+s
* Things not to do at the command prompt:
* rm -rf <-- be very careful
* Five things not to do at the command line
http://www.squarefree.com/archives/000002.html
* Know Your Unix System Administrator: A Field Guide
http://packetstormsecurity.nl/unix-humor/know.ur.sysadmin.html
-- TYPICAL ROOT .cshrc FILE: --
MANIAC: Typical lines include:
alias rm 'rm -rf \!*'
alias hose kill -9 '`ps -augxww | grep \!* | awk \'{print $2}\'`'
alias kill 'kill -9 \!* ; kill -9 \!* ; kill -9 \!*'
alias renice 'echo Renice\? You must mean kill -9.; kill -9 \!*'
--------- extra ref
* Uzi's .bashrc
http://uzix.org/bashrc.html
* Dr Chip's Vim Page
http://users.erols.com/astronaut/vim/
* alexs neato vimrc
http://envy.posixnap.net/~alex/_vimrc
* Sample vimrc
http://www.stripey.com/vim/vimrc.html
* vimrc
http://pain.mizi.com/wikix/file/MyDotfilesVimrc/vimrc
* vimrc
http://jeanluc-picard.de/vim/vimrc.html
----------
Concerns, thoughts, drop me a line. Also, don't know how many people are going
to show up, I've extended invitations to some people who've expressed interest.