All our machines are on a subnet of 192.168.5.x. The gateway machine,
which is named capone, has two network cards. Do an ifconfig to see how
it's set up (this may not be in your path... try whereis ifconfig or
locate ifconfig first). This also protects our local machines, and allows
us to have really cheesy root passwords without worrying about someone
cracking into them.
In case you don't know already, eXecute permission on a directory means
you can change to it. chmod can be used with letters (a+x for all (who)
can execute (what)), or numbers. Give it a 3 digit octal number, where the
first number signifies the owner, the second the group, and the third
everyone else. Each number is 0-7, depending on whether you want r,w,
and/or x. To get a number, start with 0. Add 4 for read permission, 2 for
write, and 1 for execute. Thurs, rwx is 7, r-x is 5, and r-- is 4. Try and
see if --x (1) makes sense... can you execute a file you can't read?
With regard to redirecting stdout and stderr, this is often helpful to
pause long displays from make, where stuff often gets written to stderr,
and thus cannot be paginated with less (or more, or most, alternative
pagers). Also, if you want a command to be silent, try sending it to
/dev/null (the big bit in the sky, aka, bit heaven/hell). command 2>&1 >
/dev/null will be completely silent, whereas command > /dev/null will only
silence the messages printed to stdout.
When redirecting, note the following.
|Symbol ||If output exists||If output
||||Output to a file (must
|>||Overwrite a file||Create a
|>>||Append to a file||Create a
Searching with Grep
grep is an interesting tool. It's one of the most useful tools... it
searches for a given string. Couple of examples:
grep test * # searches for the string "test" in all files in the current
grep test -r * # searches for the string "test" in all files in the
current directory and below (recursive)
grep 'te.t' * # matches test, tent, and anything with te, a character,
then another t. Look up regular expressions to learn more
grep test < filename # searches in "filename" Note that for one file, you
have to redirect it in.
ls -l | grep test # searches for files with test in the name (could be
done using find, as well).
grep -i # case insensitive
grep -v # searches for files (lines) NOT containing the given string.
Disk partitioning in linux works a bit differently than in windows. In
linux, you partition each drive into multiple partitions, which are then
mounted at various points. Each physical hard drive has an entry in
/dev/, which is either hdXX for IDE drivers, or sdXX for SCSI's. The first
X is a letter from a - something, depending on where it is connected to
the motherboard. The primary master is a, the primary slave is b, the
secondary master is c, etc. The second X is the partition number. For
example, the 3rd partition on the primary slave drive is hdb3.
Mounting, and Common Directories
One file system must contain the root filesystem, aka, be mounted as
slash. On many of our machines, that's hda2. (To see the mount points,
type mount, or type df). Then, other partitions can be mounted at various
points. For example, on most of these machines, hda1 is mounted on /boot.
Note that there needs to be a directory called /boot on / in order to
mount something there.
Common directories to put on their own partition are /boot, /usr, /home,
/var, and /tmp. Boot often gets it's own, tiny, partition, to aid it
keeping booting compatible (many older boards could only boot from the
first 1024 clusters). /usr is where the majority of executables reside,
and needs a good chunk of space. /home is where most home directories are
kept, and should be saved during system upgrades, and backed up
frequently. /var is often seperated to prevent runaway logs (or mail
spools, in /var/mail or /var/spool/mail from filling the entire system).
Finally, a lot of people keep /tmp seperate, both to limit temp file
size, and for security reasons. That reasoning goes as follows. Users have
to be able to write to /tmp, but an admin might be wary of a user
compiling a malicious program and leaving it in /tmp to be run by an
unsuspecting victem. They will therefore mark /tmp as noexec, meaning
nothing can be executed from within /tmp.
lost+found exists in the root directory of every partition. To see how a
hard drive is partitioned, look at the output of df.
[TA Homepage | Course Homepage | Email Me | Contact Info]