Unix for Newbies
Getting help on unix: man
! !
Get full description of command
List command mentioning keyword in title
Some Tips To Make Your UNIX Life More Reasonable
0. Walk away from the machine.
If you¡¯re not making progress, don¡¯t waste time banging your head (literally or
figuratively) against the machine. Save your files, print the buggy output, or
create a backup and walk away. Find someone to talk to about something else. Your
mind will work on the problem while you go get a snack and take a break.
1. Read man pages.
Realize that you don¡¯t know everything. Take the time to learn how man pages are
structured and what they can teach you. You find answers to many questions on the
internet, but you learn even more by finding and reading the man pages. Better,
you learn elegant solutions to questions you didn¡¯t think to ask.
2. Learn the emacs keystrokes.
It will save you time when you work on a machine whose mouse or arrow keys aren¡¯t
working, and the keystrokes often work in other editors. Many cursor
manipulations from emacs are based on history from the bash shell:
Logging in and out of a system: logout! ! ! ! exit! ! ! !
ssh
Terminate session
Terminate current
Login securely as
¡°shell¡±
username to remote host
File Manipulation:
emacs
mv
rm
cp
scp host:
Edit a text file (See the emacs cheatsheet)
Move or rename
Delete file(s) from filesystem
Copy
Secure batch file transfers between machines
Securely transfer files between machines
Display or catenate file contents to screen
Display file page by page (but: use less)
Display file page by page (use this one)
Display the first few lines of a file
cat
more
less
head
tail
grep
Directory manipulation: cd
ls! ! ! pwd! ! ! mkdir
! ! ! ! ! ! !
! ! ! ! !
! ! ! !
Printing and Mail: firefox
Shells have survived the test of time by helping their users do powerful and
complex tasks. You want to learn more about ¡®aliases¡¯ and ¡®shell scripts¡¯.
Brownie points for learning about: find, tar, gawk, perl, rsync
4. Stay organized.
Create directories to organize your files within the home directory. Organize by
some sane method and delete temporary files that pile up and confuse matters.
5. Make backups, use version control
We all screw up sometime, usually at 3am the night before the deadline. Use
version control systems (cvs, svn, git, mercurial…) to keep a revision history
you can roll back to. In a pinch, just copy the file and save it when you¡¯re
making large changes. Your sleeping habits will thank you.
6. Work with others.
Working with others (usually in a lab) lets you get help when you need it and
learn about how others are doing the work. When the whole lab is suffering
through the same project, it makes your night that much easier. And it makes home
a more pleasant place to return to.
7. Practice.
Practice more than you think you need. You know why.
8. Write.
Good writing is hard, and many computer scientists don¡¯t write enough to write
well. Start with comments on your code, work on documentation for large projects,
and learn how to write prose with ease.
9. Tell others what you¡¯re working on.
You learn how much you know (and how much you don¡¯t) when you try and explain
your work to others. Working on computer science is only good so far as you can
share it with others.
gdb
Run executable under debugging control
Resurrect coredump with executable as model
! ! ! ! !
Display the last few lines of a
Search for pattern within file
reach commands from file
Goto Directory (change focus to
List files in current directory
Print working directory (where am I?)
Make a new subdirectory (in this one) with Name
Remove an (empty) subdirectory
Open browser (under X11) at url
Open a ¡°.pdf¡± file in acrobat reader
Open a ¡°.ps¡± file with the ghostscript reader
Text-only (fast!) browser
! ! ! ! !
! !
! !
3. Learn
^P = previous command
^N = next command
^R = search for command from the past by typing a few letters
^A = go to the beginning of the command line
^E = go to the end of the command line
^B = go back one character
^F = go forward one character
^D = delete this character
= delete previous character
about your environment.
Information about Users and Systems:
w! ! ! ! top! ! ! ! ps! ! ! ! whoami! ! ! ! finger
Key Websites:
Who¡¯s on the system
What the top cpu processes
List processes on this system
Who is logged in at this window
Get details on user
List last time users used this machine
Print stats on machine
file>!
! ! ! ! !
C Compilation and Debugging:
gcc
gcc -o
gcc -g -c
gcc -o
gcc -Wall -o
gcc -std-gnu99 -o
http://www.cs.washington.edu! ! ! http://homes.cs.washington.edu/~
/cse/web/homes/
Compile C program into ¡°a.out¡± executable
Compile C program into executable
Compile C program into debuggable file
Link object files (f and g) into single exec
Compile and link file with all warnings enabled
CS homepage
Where your web files live
file
files in
Content borrowed and updated (with permission)
from Duane A. Bailey¡¯s guidelines from 2007.