PAGEFLOP
FORWARD
SELECTOR
SELAGAIN
WRONGSEL
YOUR SELECTION IS NOT IN THE 0 - #SELIMIT RANGE Please try again
AANVANG
Copyright CourseWare Technologies Inc., 1985-88
Lesson - 7
ADVANCED SYSTEM ADMINISTRATION COMMANDS
MENU
Administrative Commands|Topics to Learn|7-0|13,56
# Topic
--- -------
1 - Introduction
2 - General Information Commands
3 - Moving Directories and Files
4 - Removing Strange or Invisible Files
5 - File System Information Commands
6 - System Administration Directories
7 - System Administration Files
8 - System Configuration Commands
9 - Communication Commands
10 - Lesson Review
0 - Return to the Main Menu
P1
Administrative Commands|Introduction|7-1.1|11,54
The purpose of this lesson is to summarize
many commands that are scattered throughout this
tutorial and to introduce several new ones that
should help you administer your system more
effectively.
This lesson is a guide rather than a manual.
Nevertheless, the authors hope that the material
will help you solidify your understanding of UNIX
system administration.
P2
Administrative Commands|General Information Commands|7-2.1|9,57
You are already familiar with several general
system information commands such as:
df - reports the number of free disk blocks on
a file system
du - reports the number of blocks used by the
files in the current directory and its
subdirectories
P3
Administrative Commands|General Information Commands|7-2.2|4,54
To find out who is doing what on the system,
use the command:
/etc/whodo
who
P4
Administrative Commands|General Information Commands|7-2.3|5,54
To find out who is on the system, the time of last
reboot, the last change in system clock and the date
in the /etc/utmp file, use:
who -btas
P5
Administrative Commands|Moving Directories and Files|7-3.1|4,54
Often you will run into a situation where you
want to change the system directory structure, i.e.,
you want to move entire directories from one place to
another.
P6
Administrative Commands|Moving Directories and Files|7-3.2|11,54
Unfortunately, many programs require absolute
pathnames rather than relative ones. The command
that can solve this problem is link. It will give
the same file another name, in addition to the
existing one. So you can use this command to point
to the directories that you moved into a new directory
on the same file system.
To link file 10sa to 10sa1 use:
link 10sa 10sa1
P7
Administrative Commands|Moving Directories and Files|7-3.3|14,54
The command opposite to link that allows you
to remove the filename that points to another file
or directory is:
unlink
unlink is useful for unlinking device files
as well as directories that were linked earlier to
compensate for the fixed pathnames in the program on
your system.
Both link and unlink are restricted to superuser.
P8
Administrative Commands|Moving Directories and Files|7-3.4|12,54
A powerful command to move entire UNIX directories
and all the underlying files and directories is:
/etc/mvdir
mvdir is similar to the mv command; however, as you
will see on your terminal screen it applies not to
ordinary files, but to entire directories as well.
However, mvdir can be used only WITHIN a file
system.
P9
Administrative Commands|Removing Strange Files|7-4.1|6,50
Often because of typographical errors while
in the editor or while copying files, users create
files that have invisible characters or some
strange control sequences in their names. This
makes the files difficult to remove or rename
because you don't know the invisible characters.
P10
Administrative Commands|Removing Strange Files|7-4.2|14,54
If you can use the wild card characters * or ? to
list the name of a problem file with the ls command,
then you use the same wild cards to remove the file
with the rm command. If, for example, you have a file
called abc with invisible characters in the first and
last two positions, you can try to list the file with:
ls ?abc*
If that lists ONLY the problem file, then you can
remove it with:
rm ?abc*
P11
Administrative Commands|Removing Strange Files|7-4.3|10,54
If you cannot uniquely name a problem file, you
could try using the -i (for interactive) option with
the rm command. This option will ask whether to
delete each file. If you issue the command:
rm -i *
you would be asked, one at a time, if you want each
file in the directory removed. You would answer n
for all but the problem file(s).
P12
Administrative Commands|Removing Strange Files|7-4.4|12,54
Trying to find the right wild card string for removing
files may not work unless you want to delete the entire
directory. In a case like this, you may wish to find
the inode for the file and then delete the inode.
The command that will generate the pathnames for
files on a specified file system and their corresponding
inode numbers is ncheck. To determine the inodes for
files on /dev/gb0c for example, the command would be:
ncheck /dev/gb0c
P13
Administrative Commands|Removing Strange Files|7-4.5|8,54
Once you determine the inode number of a strange
or invisible file with ncheck, the command to delete
the inode and thus the file itself is clri. For
example, to delete the file with inode 237 on the
device /dev/u, the command would be:
clri /dev/u 237
P14
Administrative Commands|File System Information Commands|7-5.1|8,54
The command to elevate oneself to superuser
status is su. The system will prompt you for a
password. If you respond correctly, you can work
with superuser privileges!
Make sure to set up a password for superuser
if your system has more than one user.
P15
Administrative Commands|File System Information Commands|7-5.2|9,54
The command to change the root directory for a
command is chroot. The syntax is:
/usr/etc/chroot newroot command
The command is executed relative to the new root,
that is, the meaning of the initial slashes in the
pathname is changed to newroot as is the initial
working directory.
P16
Administrative Commands|File System Information Commands|7-5.3|12,54
From the current directory, whose pathname
relative to the new root is /a, the command to copy
all files onto device /dev/rfdc0 would be:
chroot /a find . | cpio -oB > /dev/rfdc0
Remember, the command used for clearing bad
inodes from a file system is clri. To clear the
inode 356 from the file system /dev/rfbk0 use:
clri /dev/rfbk0 356
P17
Administrative Commands|File System Information Commands|7-5.4|2,54
The command to flush out all I/O buffers to the
disk, i.e., to complete all the pending I/O, is sync.
Administrative Commands|File System Information Commands|7-5.4|10,54
The command to flush out all I/O buffers to the
disk, i.e., to complete all the pending I/O, is sync.
To install a command into a specified or a default
directory, i.e., where an older version of the command
exists, use the install command. To install newtar
in the default directory use:
install newtar
P18
Administrative Commands|File System Information Commands|7-5.5|15,54
To determine the special file device name
associated with the specified files or directories
of a mounted file system use the command devnm.
To find out the device on which the root file
system / is mounted use:
/etc/devnm /
You must use full pathnames to specify the file
or directory, e.g.:
devnm /usr/lib/uucp
Administrative Commands|File System Information Commands|7-5.5|4,54
To determine the special file device name
associated with the specified files or directories
of a mounted file system use the command mount
with no arguments.
P19
Administrative Commands|File System Information Commands|7-5.6|14,56
The /etc/setmnt command creates an entry in
the /etc/mnttab table used by the mount and umount
commands as well as other file system handling and
information commands. For example, if the root file
system / was mounted on /dev/rdd0a, the command
devnm /
would produce /dev/rdd0a. Piping this result into
setmnt would produce an entry for the root file system
and the device on which it is mounted in the /etc/mnttab
file:
devnm / | setmnt
Administrative Commands|File System Information Commands|7-5.6|3,56
The /etc/mount -p command prints the list of
mounted file systems in a format suitable for use
in the /etc/fstab file.
P20
Administrative Commands|File System Information Commands|7-5.7|5,48
The command to make a file system on a device
is /etc/mkfs. To make a file system of 15000
blocks on the device /dev/udd11 use the command:
/etc/mkfs /dev/udd11 15000
Administrative Commands|File System Information Commands|7-5.7|11,54
The command to make a file system on a device is
/etc/mkfs. To make a file system of 15000 blocks on the
device /dev/udd11 use the command:
/etc/mkfs /dev/udd11 15000
The file system debugger is /etc/fsdb. To debug
the inode 386 on a file system use:
fsdb 386i
P21
Administrative Commands|File System Information Commands|7-5.8|6,54
The command to make a directory entry and a
corresponding inode for a special file is /etc/mknod.
To create a block special file for the device udk0 with
a major device number of 0 and a minor device number
of 2 use:
/etc/mknod /dev/udk0 b 0 2
P22
Administrative Commands|File System Information Commands|7-5.9|12,54
The system activity reports may be obtained from
the sar command family, i.e.:
* /usr/lib/sa/sadc,
* /usr/lib/sa/sa1, and
* /usr/lib/sa/sa2.
The uucp activity reports can be obtained by
using the uustat and uulog commands, e.g.,
uustat and uulog -scti
Administrative Commands|File System Information Commands|7-5.9|13,58
The system activity reports may be obtained from
the following files and commands:
Type of information stored in file: program used
------------------- --------------- ------------
Connect-time /usr/adm/wtmp /etc/ac
Process-time /usr/adm/acct /etc/sa
The uucp activity reports can be obtained by
using the uustat and uulog commands, e.g.,
uustat and uulog -scti
P23
Administrative Commands|File System Information Commands|7-5.10|12,54
The command /etc/bdblk is used to check and update
bad block information. Your must be in single-
user mode to execute this command. To check bad
blocks on device /dev/rgb0d use:
bdblk -w /dev/rgb0d
The command /etc/ff lists file names and file
statistics for a file system, e.g.:
ff /dev/rfbk0
Administrative Commands|File System Information Commands|7-5.10|6,54
The command /etc/badtrk is used to check and
update bad block information. You must be in single-
user mode to execute this command. To check bad
blocks on device /dev/rgb0d use:
badtrk -f /dev/rgb0d
P24
Administrative Commands|File System Information Commands|7-5.11|6,54
The command /etc/fuser will print process information
for processes that are using a specified file or a file
system. To list process ID's and login names of processes
using the file /a/admin use:
fuser -u /a/admin
P25
Administrative Commands|File System Information Commands|7-5.12|8,54
The command for copying an existing file system
into another appropriately sized file system for
optimum access time is dcopy. Note that the file
system should be dismounted. Using the default
attributes in copying from the /dev/rfbk0 file system
to /dev/rfbk3 the command would be:
dcopy -d /dev/rfbk0 /dev/rfbk3
P26
Administrative Commands|Administration Directories|7-6.1|11,54
Throughout much of the discussion you have noticed
that the system administration directories are:
* /etc,
* /usr/adm,
* /usr/spool, and
* /usr/sys/conf.
See the following terminal screen for a detailed
diagram.
P27
Administrative Commands|System Administration Files|7-7.1|15,54
There are several system administration files
that you should be aware of.
For terminal/serial line configuration, the file
of importance is:
/etc/inittab
For terminal/serial line configuration, the files
of importance are:
* /etc/inittab
* /etc/ttys and
* /etc/ttytype.
Most system configuration files are either in
the /etc or /usr/sys/conf directory. The files
of importance are:
/etc/master and /etc/sys-name
/usr/sys/conf/master and /usr/sys/conf/sys-name
/usr/sys/conf/GENERIC and /usr/sys/conf/your-name
P28
Administrative Commands|System Administration Files|7-7.2|15,54
For system accounting, the important files are
in the /usr/adm/ directory, i.e.:
* /usr/adm/acct/nite,
* /usr/adm/acct/sum,
* /usr/adm/acct/fiscal, and
* /usr/adm/pacct.
* /usr/adm/acct,
* /usr/adm/saveacct,
* /usr/adm/usracct, and
* /usr/adm/wtmp.
For communications, the important files are in
the following directories:
* /usr/lib/uucp,
* /usr/spool/uucp, and
* /usr/spool/uucppublic.
P29
Administrative Commands|System Administration Files|7-7.3|9,54
The files that describe the active file systems
and the file systems to be checked are:
/etc/mnttab
/etc/mttab and /etc/checklist
/etc/mtab and /etc/fstab
The multi-user state initialization command file
is /etc/rc, and the multi-user to single-user transition
file (i.e., the shutdown file) is /etc/shutdown.
P30
Administrative Commands|System Configuration Commands|7-8.1|12,54
The command /etc/sysdef prints the current system
configuration. The information produced, as you will see,
is basically a copy of your system configuration
file:
/etc/sys-name
You can obtain a lower level system configuration
report simply by typing:
cat /etc/master
Administrative Commands|System Configuration Commands|7-8.1|12,54
The command /etc/sysdef prints the current
system configuration. The information produced,
as you will see, is basically a copy of your system
configuration file:
/usr/sys/conf/xenixconf
You can obtain a lower level system
configuration report simply by typing:
cat /usr/sys/conf/master
Administrative Commands|System Configuration Commands|7-8.1|4,54
You can have a look at your system configuration
report simply by typing:
cat /usr/sys/conf/your-master-file
P31
Administrative Commands|Communication Commands|7-9.1|13,54
The command for sending mail to other users on
your system is:
mail
The command for remote logins to other machines is:
cu
cu can also be used for low-speed text file
transfers; however, without error checking.
P32
Administrative Commands|Communication Commands|7-9.2|7,54
The most solid standard UNIX file transferring
facility is:
uucp
uucp is used for file sending and receiving.
P33
Administrative Commands|Communication Commands|7-9.3|10,54
/usr/lib/uucp/uucico is used by uucp and can
be used independently for calling and for doing
the actual file transfer between the systems.
uuto is used for copying files between systems.
uux is used for executing commands on a remote
system.