lecture
in color
su: `switch user'
% su Password: #makes you
root!
#)
/bin/sh or /bin/bash)
rm -rf .*
* matches non-dot files (misses .cshrc)
.* matches . and ..
rm -rf .* not only removes your directory, but
all siblings of it in the directory above it!
rm -rf .??* # match anything starting with . with >= 3 chars.
cp -r /home/couch /home/grouch
/home/couch
to /home/grouch.
messes up all protections and timestamps!
(cd /home/couch; tar cf - .) | (cd /home/grouch; tar xfBp -)
tar cf - .: put all contents of current directory
on standard output.
c: create archive
f -: write to standard output.
tar xfBp -: retrieve contents from standard input,
x: extract
f -: from standard input
B: which is a pipe
p: preserve owner and mode
#' is not a reminder of power, but of
responsibility.
root is a matter of building trust.
root.
root.
cp /etc/inetd.conf /etc/inetd.conf.orig
chown it to yourself, be yourself, compile it.
chown files, fix,
chown back.
vi
preserves the link, emacs breaks it.
/etc/hosts -> /etc/inet/hosts
emacs /etc/hosts, these are different files.
emacs)
file~'s.
vi is available on every UNIX system.
emacs is not typically available on new systems.
ed, the only editor that'll
work in single user mode on a damaged system.
| normal user | root user |
|---|---|
login | su |
/bin/csh and relatives | /bin/sh
and relatives |
| directories | filesystems |
| programs | daemons |
root can restructure how you see directories.
raw device --------> device containing -----------> 'mapped' filesystem
newfs, mkfs filesystem mount
UFS (Solaris), ext2 (linux)
NFS (Sun), AFS (CMU), Samba (Linux/NT)
df - show `mounted filesystems'.
[couch@lin01 ~]$ df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda1 2522048 1388580 1005352 58% /
/dev/sda2 5779532 23380 5462568 0% /var/local
conmoto:/export/27/loc/ap/linux-x86-libc6
52127512 37298448 14307792 72% /local
conmoto:/export/27/loc
52127512 37298448 14307792 72% /loc
conmoto:/export/14/p/1/comp150net
35244336 21586384 13305512 62% /p/1/comp150net
-k option on some systems in order to produce
reasonable output:
blackhole{couch}87: df
/proc (/proc ): 0 blocks 921 files
/ (/dev/dsk/c0t3d0s0 ): 111508 blocks 39265 files
/usr (/dev/dsk/c0t3d0s6 ): 521280 blocks 346298 files
/dev/fd (fd ): 0 blocks 0 files
/var (/dev/dsk/c0t3d0s1 ): 52200 blocks 19890 files
/tmp (swap ): 145912 blocks 10452 files
/cf (conmoto:/export/0/cf):33121572 blocks 3394458 files
/loc (conmoto:/export/27/loc):29658122 blocks 5158058 files
/u/f (conmoto:/export/1/u/f):37855660 blocks 3809948 files
/var/mail (yogi:/export/mail ):25129160 blocks 1709248 files
/local (conmoto:/export/27/loc/SLINK):29658122 blocks 5158058 files
blackhole{couch}88: df -k
Filesystem kbytes used avail capacity Mounted on
/proc 0 0 0 0% /proc
/dev/dsk/c0t3d0s0 83319 27565 47423 37% /
/dev/dsk/c0t3d0s6 746982 486342 200882 71% /usr
fd 0 0 0 0% /dev/fd
/dev/dsk/c0t3d0s1 41407 15307 21960 42% /var
swap 73228 284 72944 1% /tmp
conmoto:/export/0/cf 34751145 18190359 16213275 53% /cf
conmoto:/export/27/loc
52127508 37298447 14307786 73% /loc
conmoto:/export/1/u/f
34751145 15824616 18579018 46% /u/f
yogi:/export/mail 13472260 907564 11880328 8% /var/mail
conmoto:/export/27/loc/SLINK
52127508 37298447 14307786 73% /local
blackhole{couch}89:
/dev/dsk/c0t3d0s6 - a disk device
c0 - controller 0
t6 - target 6
d0 - disk 0
s6 - subchannel 6
df/dev/something
/dev/sda1 2522048 1388580 1005352 58% /
hostname:/directory/path
conmoto:/export/27/loc
52127512 37298448 14307792 72% /loc
says that /loc here is /export/27/loc on the server |conmoto|.
conmoto.
allegro:/some/thing is a mount point for blackhole:/export/1
and andante:/t/some/thing is a mount point for blackhole:/export/1/thing then which directories correspond to one another (are aliases for one another) on andante and allegro?
mount - make a filesystem appear
/sbin/mount /dev/dsk/c0t3d0s1 /mntmakes the contents of
/dev/dsk/c0t3d0s1 become known as /mnt
/mnt - a standard mount point for testing filesystems.
umount - make a filesystem disappear.
/sbin/umount /mntundoes what the previous command did.
df said 100% full.
du said it was 0% full (relative to the number of blocks available).
df can see under mount points; du cannot!
/etc/vfstab lists mount commands to do at boot:
#device device mount FS fsck mount mount #to mount to fsck point type pass at boot options /dev/dsk/c0t3d0s3 - - swap - no - /dev/dsk/c0t3d0s0 /dev/rdsk/c0t3d0s0 / ufs 1 no - /dev/dsk/c0t3d0s6 /dev/rdsk/c0t3d0s6 /usr ufs 1 no - /dev/dsk/c0t3d0s1 /dev/rdsk/c0t3d0s1 /var ufs 1 no - ^ ^ ^ ^ ^^^ when to check it. ^ ^ ^ ^^^ type of filesystem. ^ ^ ^^^^ where to make this appear. ^ ^^^^^^^^^^^^^^^^^^ corresponding 'raw' (character) device ^^^^^^^^^^^^^^^^^ block device
/dev/dsk)
/dev/rdsk)
/etc/fstab
[couch@lin01 ~]$ more /etc/fstab # device mount type options dump /dev/sda1 / ext2 defaults 1 1 /dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0 /dev/sda2 /var/local ext2 defaults 1 2 /dev/fd0 /mnt/floppy auto noauto,owner 0 0 none /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 /dev/sda3 swap swap defaults 0 0 conmoto:/export/27/loc/ap/linux-x86-libc6 /local nfs hard,rsize=8192,wsize=8192 0 0 conmoto:/export/27/loc /loc nfs hard,rsize=8192,wsize=8192 0 0 conmoto:/export/14/p/1/comp150net /p/1/comp150net nfs hard,rsize=8192,wsize=8192 0 0 [couch@lin01 ~]$
ro - 'read-only'
noauto - don't mount this at boot
cd to a particular directory.
/etc/auto_* and NIS+ maps
auto_*.org_dir
niscat auto_master.org_dir defines submaps.
blackhole{couch}73: niscat auto_master.org_dir
/nfs auto_nfs
/u auto_u
/- auto_direct
/home auto_home
niscat auto_direct.org_dir defines `direct mounts'
blackhole{couch}74: niscat auto_direct.org_dir
/var/mail -vers=3,-actimeo=0 yogi:/export/mail
/local conmoto:/export/27/loc/SLINK
/r conmoto:/export/0/r
/p conmoto:/export/14/p
/cf conmoto:/export/0/cf
/g conmoto:/export/0/g
/loc conmoto:/export/27/loc
/s conmoto:/export/28/s
/patches conmoto:/export/0/patches
blackhole{couch}75:
niscat auto_u.org_dir mounts things in /u:
blackhole{couch}75: niscat auto_u.org_dir
j conmoto:/export/1/u/j
f conmoto:/export/1/u/f
O conmoto:/export/28/u/O
s conmoto:/export/28/u/s
m conmoto:/export/28/u/m
t conmoto:/export/1/u/t
o conmoto:/export/28/u/o
blackhole{couch}76:
niscat auto_loc.org_dir mounts things in /loc
blackhole{couch}76: niscat auto_loc.org_dir
constraint conmoto:/export/0/loc/&
SLINK conmoto:/export/0/loc/&
TT_DB conmoto:/export/0/loc/&
X11 conmoto:/export/0/loc/&
adm conmoto:/export/0/loc/&
aladdin conmoto:/export/0/loc/&
alone conmoto:/export/0/loc/&
case conmoto:/export/0/loc/&
dbms conmoto:/export/0/loc/&
emacs-18.59 conmoto:/export/0/loc/&
games conmoto:/export/0/loc/&
gnu conmoto:/export/0/loc/&
graphics conmoto:/export/0/loc/&
interleaf conmoto:/export/0/loc/&
lang conmoto:/export/0/loc/&
mail conmoto:/export/0/loc/&
net conmoto:/export/0/loc/&
libs conmoto:/export/0/loc/&
pkg conmoto:/export/0/loc/&
publish conmoto:/export/0/loc/&
shells conmoto:/export/0/loc/&
slink conmoto:/export/0/loc/&
utils conmoto:/export/0/loc/&
xclients conmoto:/export/0/loc/&
ee26 conmoto:/export/0/loc/&
encryption conmoto:/export/0/loc/&
fax conmoto:/export/0/loc/&
from conmoto:/export/0/loc/&
g conmoto:/export/0/loc/&
tree conmoto:/export/0/loc/&
out conmoto:/export/0/loc/&
ncd conmoto:/export/0/loc/&
parallel conmoto:/export/0/loc/&
tftpboot conmoto:/export/0/loc/&
bsd-4.3 conmoto:/export/0/loc/&
cad conmoto:/export/0/loc/&
ce conmoto:/export/0/loc/&
ee128 conmoto:/export/0/loc/&
eesof-6.0 conmoto:/export/0/loc/&
espresso conmoto:/export/0/loc/&
idl conmoto:/export/0/loc/&
motif-1.2 conmoto:/export/0/loc/&
motif-examples conmoto:/export/0/loc/&
motif-uimx conmoto:/export/0/loc/&
sofa conmoto:/export/0/loc/&
packages conmoto:/export/0/loc/&
acct conmoto:/export/0/loc/&
editors conmoto:/export/0/loc/&
kerberos conmoto:/export/0/loc/&
kirby conmoto:/export/0/loc/&
lang2 conmoto:/export/0/loc/&
sound conmoto:/export/0/loc/&
vis conmoto:/export/0/loc/&
www conmoto:/export/0/loc/&
mentor conmoto:/export/0/loc/&
adm-MOVED conmoto:/export/0/loc/&
att conmoto:/export/0/loc/&
avanti conmoto:/export/0/loc/&
ansoft conmoto:/export/0/loc/&
chinese conmoto:/export/0/loc/&
apache conmoto:/export/0/loc/&
ap conmoto:/export/0/loc/&
postgres conmoto:/export/0/loc/&
graphics2 conmoto:/export/0/loc/&
jserv conmoto:/export/0/loc/&
3com conmoto:/export/0/loc/&
java conmoto:/export/0/loc/&
geom conmoto:/export/0/loc/&
sgi0 conmoto:/export/0/loc/&
gut conmoto:/export/0/loc/&
cadence conmoto:/export/0/loc/&
gnu2 conmoto:/export/0/loc/&
fs conmoto:/export/0/loc/&
rep conmoto:/export/0/loc/&
blackhole{couch}77:
geom conmoto:/export/0/loc/&means that
conmoto:/export/0/loc/geom maps to /loc/geom
format command:
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c0t2d0 <MICROP-1598-15MD1052405-AS24 cyl 1911 alt 2 hd 15 sec 71>
/iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@2,0
1. c0t3d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
/iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@3,0
Specify disk (enter its number): 0
selecting c0t2d0
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format> part
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd> - execute <cmd>, then return
quit
partition> print
Current partition table (original):
Total disk cylinders available: 1911 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 61 32.24MB (62/0/0) 66030
1 swap wu 62 - 185 64.48MB (124/0/0) 132060
2 backup wu 0 - 1910 993.76MB (1911/0/0) 2035215
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 usr wm 186 - 1910 897.03MB (1725/0/0) 1837125
7 unassigned wm 0 0 (0/0/0) 0
partition> 3
Part Tag Flag Cylinders Size Blocks
3 unassigned wm 0 0 (0/0/0) 0
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 186
Enter partition size[0b, 0c, 0.00mb, 0.00gb]: 200c
partition> print
Current partition table (unnamed):
Total disk cylinders available: 1911 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 61 32.24MB (62/0/0) 66030
1 swap wu 62 - 185 64.48MB (124/0/0) 132060
2 backup wu 0 - 1910 993.76MB (1911/0/0) 2035215
3 unassigned wm 186 - 385 104.00MB (200/0/0) 213000
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 usr wm 186 - 1910 897.03MB (1725/0/0) 1837125
7 unassigned wm 0 0 (0/0/0) 0
partition> 4
Part Tag Flag Cylinders Size Blocks
4 unassigned wm 0 0 (0/0/0) 0
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 386
Enter partition size[0b, 0c, 0.00mb, 0.00gb]: 1525c
partition> print
Current partition table (unnamed):
Total disk cylinders available: 1911 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 61 32.24MB (62/0/0) 66030
1 swap wu 62 - 185 64.48MB (124/0/0) 132060
2 backup wu 0 - 1910 993.76MB (1911/0/0) 2035215
3 unassigned wm 186 - 385 104.00MB (200/0/0) 213000
4 unassigned wm 386 - 1910 793.03MB (1525/0/0) 1624125
5 unassigned wm 0 0 (0/0/0) 0
6 usr wm 186 - 1910 897.03MB (1725/0/0) 1837125
7 unassigned wm 0 0 (0/0/0) 0
partition> label
Ready to label disk, continue? y
partition> quit
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format> quit
#
newfs command:
# newfs /dev/rdsk/c0t2d0s3
newfs: construct a new file system /dev/rdsk/c0t2d0s3: (y/n)? y
/dev/rdsk/c0t2d0s3: 213000 sectors in 200 cylinders of 15 tracks, 71 sectors
104.0MB in 13 cyl groups (16 c/g, 8.32MB/g, 4032 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 17152, 34272, 51392, 68512, 85632, 102752, 119872, 136992, 154112, 171232,
188352, 205472,
mount command:
# df -k Filesystem kbytes used avail capacity Mounted on /proc 0 0 0 0% /proc /dev/dsk/c0t3d0s0 83319 27346 47642 37% / /dev/dsk/c0t3d0s6 746982 475574 211650 70% /usr fd 0 0 0 0% /dev/fd /dev/dsk/c0t3d0s1 41407 19979 17288 54% /var swap 99900 284 99616 1% /tmp # mount /dev/dsk/c0t2d0s3 /mnt # df -k Filesystem kbytes used avail capacity Mounted on /proc 0 0 0 0% /proc /dev/dsk/c0t3d0s0 83319 27346 47642 37% / /dev/dsk/c0t3d0s6 746982 475574 211650 70% /usr fd 0 0 0 0% /dev/fd /dev/dsk/c0t3d0s1 41407 19979 17288 54% /var swap 99896 284 99612 1% /tmp /dev/dsk/c0t2d0s3 99723 9 89742 1% /mnt #
/dev/dsk/c0t2d0s3: the partition to mount.
/mnt: the mount point at which
to make it visible within the filesystem.
df -k: lists mounted filesystems.
# cd /mnt # ls lost+found # touch foo # ls foo lost+found # cd .. # umount /mnt umount: /mnt busy (I cd'd OUT of this in another shell) # umount /mnt # ls /mnt #
cd'd.
Must cd out and try again.
/etc/dfs/dfstab:
# Place share(1M) commands here for automatic execution # on entering init state 3. # # Issue the command '/etc/init.d/nfs.server start' to run the NFS # daemon processes and the share commands, after adding the very # first entry to this file. # # share [-F fstype] [ -o options] [-d "<text>"] <pathname> [resource] # .e.g, # share -F nfs -o rw=engineering -d "home dirs" /export/home2 share -F nfs -o rw=largo /export/1
/etc/exports
/export/mail @roots(rw,no_root_squash) @sun(rw) @sgi(rw) @linux(rw) /export/comp150c @sun(rw) @sgi(rw) @linux(rw)
@sun, @roots, @linux: netgroups of stations
(can also use hostname).
# mount blackhole:/export/1 /mnt # ls /mnt foo lost+found # df -k /mnt Filesystem kbytes used avail capacity Mounted on blackhole:/export/1 99720 8 89736 1% /mnt #
blackhole: NFS server.
largo: NFS client.
/export/1: remote directory.
/mnt: local mount point.
sync: make disk agree with memory.
fsck: check a disk for errors in structure.
# fsck /dev/rdsk/c0t2d0s3 ** /dev/rdsk/c0t2d0s3 ** Last Mounted on /export/1 ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups 3 files, 9 used, 99714 free (18 frags, 12462 blocks, 0.0% fragmentation)
update.
sync means to make the disk image agree with memory.
It tells update to 'flush its buffers' to disk.
fsck needed?
fsck cleans up after such partial losses,
checking that every block on the disk is in an appropriate state.
newfs sets up a super-block and several backups, so that
ln -s target_path linkname
% ln -s /g/150/motd motd % ls -l motd lrwxrwxrwx 1 couch faculty 11 Feb 3 14:16 motd -> /g/150/motd % ln -s ../../var/adm admin % ls -l admin lrwxrwxrwx 1 couch faculty 13 Feb 3 14:16 admin -> ../../var/adm
ln target_path linkname
% ls -l junk.c -rw-r--r-- 1 couch faculty 228 Jan 31 16:00 junk.c % ln junk.c junk.cc % ls -l junk.c junk.cc -rw-r--r-- 2 couch faculty 228 Jan 31 16:00 junk.c -rw-r--r-- 2 couch faculty 228 Jan 31 16:00 junk.cc
mkdir /foo; cd /foo mkdir bar; cd bar mkdir cat; cd cat ln /foo/bar dog
lecture
in color