Você está na página 1de 7

1.0 What is a [UNIX System] Administrator?

1. One who administers; one who manages, carries on, or


directs the affairs of any establishment or institution.

1.1 Some Common System Administration Tasks.

* Performing backups

* Adding and removing users

* Adding and removing hardware

* Restoring files from backups that users have


accidentally deleted

* Installing new software

* Answering users' questions

* Monitoring system activity, disc use and log files

* Figuring out why a program has stopped working since


yesterday, even though the user didn't change anything;
honest!

* Monitoring system security

* Adding new systems to the network

* Talking with vendors to determine if a problem is


yours or theirs, and getting them to fix it when it is
their problem

* Figuring out why "the network" (or "Pine", or "the


computer") is so slow

* Trying to free up disc space

* Rebooting the system after a crash (usually happens


when you are at home or have to catch a bus)

* Writing scripts to automate as many of the above


tasks as possible
2.4 Types of Unix users.

* root (a.k.a. "super user"--guard this account!)

* everybody else

2.5 Becoming root

* Log in as root from the system console (avoid)

* Use "/bin/su -" command from your regular account


(better method)

2.6 Things to be aware of when using root account

* $HOME is / (Watch what you delete!)

* Change the password frequently and use "good"


passwords (more on this later)

* Never leave the terminal unattended, even for "just a


minute"

* Limit who has the root password to as few people as


possible

* Never execute any regular user's program as root

* Never let anyone else run a command as root, even if


you are watching them

* You risk having your password stolen by "sniffers" if


you use programs like "telnet", "ftp", access email
remotely.

creating Files

There are many ways of creating a file. Type cat >


Mary_Jones.letter and then type out a few lines of text.
You will use this file in later examples. The cat command
is used here to write from the keyboard into a file
Mary_Jones.letter. At the end of the last line, press Enter
one more time and then press Ctrl-D. Now, if you type ls
again, you will see the file Mary_Jones.letter listed with
any other files. Type cat Mary_Jones.letter without the >.
You will see that the command cat writes the contents of a
file to the screen, allowing you to view your letter. It
should match exactly what you typed in.

1.1 File systems

• Disk drives are usually read in blocks of 1024 bytes


(two sectors). From the point of view of anyone
accessing the device, blocks are stored
consecutively--there is no need to think about
cylinders or heads--so that any program can read the
disk as though it were a linear tape.

• Now a complex directory structure with many files of


arbitrary size needs to be stored in this contiguous
partition. This poses the problem of what to do with a
file that gets deleted and leaves a data ``hole'' in
the partition, or a file that has to be split into
parts because there is no single contiguous space big
enough to hold it. Files also have to be indexed in
such a way that they can be found quickly (consider
that there can easily be 10,000 files on a system).
UNIX's symbolic/hard links and devices files also have
to be stored.

• To cope with this complexity, operating systems have a


format for storing files called the file system ( fs).
Like MS-DOS with its FAT file system or Windows with
its FAT32 file system, LINUX has a file system called
the 2nd extended file system, or ext2.

1.2 creating a file system

1.2.1
/etc/mkfs /dev/fd0h1440 2400:600

2400 stands for the numbers of 512KB blocks that may be


present on the disk. For a 1.44 MB disk the number of
blocks can be calculated as,
tracks/side * Number of sides * sectors/track *
bytes/sector/512

= 80*2*15*512/512 =2400

600 following the colon indicates the number of inodes that


we want to create in the file system. Usually this number
is one fourth of the number of blocks.

1.2.2 mke2fs

To create a file system on a blank partition, use the


command mkfs (or one of its variants). To create a LINUX
ext2 file system on the first partition of the primary
master run:

mkfs -t ext2 -c /dev/hda1

or, alternatively

mke2fs -c /dev/hda1

The -c option means to check for bad blocks by reading


through the entire disk first.

1.3 Formatting floppies and removable drives

fdformat /dev/fd0h1440 // LINUX

format /dev/rfd0135ds18 //SCO UNIX

rfd stands for raw floppy disk


0 for floppy in drive a
135 tracks per inch
ds double sided
18 sector per track

fdformat /dev/fd0H1440 // LINUX


1.0 File System Repair: fsck

fsck stands for file system check. fsck scans the file
system, reporting and fixing errors. Errors would normally
occur only if the kernel halted before the file system was
umounted. In this case, it may have been in the middle of a
write operation which left the file system in an incoherent
state. This usually happens because of a power failure. The
file system is then said to be unclean.

fsck is used as follows:

fsck [-V] [-a] [-t <fstype>] <device>

-V means to produce verbose output. -a means to check the


file system noninteractively--meaning to not ask the user
before trying to make any repairs.

Here is what you would normally do with LINUX if you don't


know a whole lot about the ext2 file system:

fsck -a -t ext2 /dev/hda1

although you can omit the -t option because LINUX


autodetects the file system. Note that you should not run
fsck on a mounted file system. In exceptional circumstances
it is permissible to run fsck on a file system that has
been mounted read-only.

1.2 packing and unpacking using tar

1.2.1 packing

# tar -cvf all.tar /root/rajneesh

1.2.2 Restoring files

# tar -xvf all.tar

1.2.3 Listing the files in an archive

# tar -tf all.tar

1.2.4 comparing the Files of an archive with disk files


# tar -dvf all.tar

1.2.4 adding Files to an archive

# tar -rvf all.tar /root/abc

1.2.4 updating Files in an archive

# tar -uvf all.tar /root/abc

1.2.4 deleting Files from an archive

# tar -delete -f all.tar /root/abc

1.2.4 concatenating tar archive

# tar -Af all.tar abc.tar

1.2.4 compressing files

# tar -zcvf all.tar.gz /root/test/*

1.2.4 to view compressing files

# tar -ztvf all.tar.gz

1.2.5 storing files on external devices

# tar -cvpf /dev/fd0 /home/root

1.3 Backing up to floppies

You can use tar to back up to any device. Consider periodic


backups to an ordinary IDE drive instead of a tape. Here we
back up to the secondary slave:

tar -cvzf /dev/hdd /bin /boot /dev /etc /home /lib


/sbin /usr /var

tar can also back up across multiple floppy disks:


tar -cvMf /dev/fd0 /home/simon

1.4 Tape backups

tar traditionally backs up onto tape drives. The commands

mt -f /dev/st0 rewind
tar -cvf /dev/st0 /home

rewind scsi tape 0 and archive the /home directory onto it.
You should not try to use compression with tape drives
because they are error prone, and a single error could make
the entire archive unrecoverable. The mt command stands for
magnetic tape and controls generic SCSI tape devices. See
also mt(1).

1.5 cpio command

(i) copy out mode


adding the files in the current directory to abc

find . -print | cpio -oF /root/abc

F option to specify the name of the file


(ii) copy in mode
cpio -i < /root/abc

(iii) copy pass mode

-p copy pass mode

Você também pode gostar