System Administration Utilities
System Administration Utilities
This section briefly describes a few of the many utilities that can help you perform system administration tasks. Some of these utilities are incorporated as part of the Main menu, and some are useful to users other than the system administrator.
Red Hat Configuration Tools
Most of the Red Hat configuration tools are named system-config-*. Many of these tools bring up a graphical display when called from a GUI and a textual display when called from a non-GUI command line. In general, these tools, which are listed in Table 11-2, are simple to use and require little explanation beyond what the tool presents. Some have Help selections on their toolbar; most do not have man pages.
Command Line Utilities
Changes the login shell for a user. When you call chsh without an argument, you change your own login shell. Superuser can change the shell for any user by calling chsh with that user's username as an argument. When changing a login shell with chsh, you must specify an installed shell that is listed in the file /etc/shells; other entries are rejected. Also, you must give the pathname to the shell exactly as it appears in /etc/shells. The chsh list-shells command displays the list of available shells. In the following example, Superuser changes Sam's shell to tcsh:
# chsh sam Changing shell for sam. New shell [/bin/bash]: /bin/tcsh Shell changed.
Clears the screen. You can also use CONTROL-L from the bash shell to clear the screen. The value of the environment variable TERM (page 984) is used to determine how to clear the screen.
Displays recent system log messages (page 535).
Displays or creates a volume label on an ext2 or ext3 disk partition. An e2label command has the following format:
e2label device [newlabel]
where device is the name of the device (/dev/hda2, /dev/sdb1, /dev/fd0, and so on) you want to work with. When you include the optional newlabel parameter, e2label changes the label on device to newlabel. Without this parameter, e2label displays the label. You can also create a volume label with the L option of tune2fs (page 471).
Finds new and changed hardware and configures it. This utility determines which hardware is new by probing all devices on internal and external buses and comparing the results to the /etc/sysconfig/hwconf database. In the default configuration, the /etc/rc.d/init.d/kudzu script runs and calls kudzu as the machine enters runlevels 3 and 5. When it finds new or changed hardware, kudzu gives you a chance to configure it and permits you to deconfigure any hardware that you have removed.
Creates a new filesystem on a device. This utility is a front end for many utilities, each of which builds a different type of filesystem. By default, mkfs builds an ext2 filesystem and works on either a hard disk partition or a floppy diskette. Although it can take many options and arguments, you can use mkfs simply as
# mkfs device
where device is the name of the device (/dev/hda2, /dev/sdb1, /dev/fd0, and so on) you want to make a filesystem on. Use the t option to specify a type of filesystem. The following command creates an ext3 filesystem on device:
# mkfs -t ext3 device
Sends packets to a remote system. This utility determines whether you can reach a remote system through the network and determines how much time it takes to exchange messages with the remote system. Refer to "ping: Tests a Network Connection" on page 365.
reset (link to tset)
Resets terminal characteristics. The value of the environment variable TERM (page 984) determines how to reset the screen. The screen is cleared, the kill and interrupt characters are set to their default values, and character echo is turned on. From a graphical terminal emulator, this command also changes the size of the window to its default. The reset utility is useful to restore your screen to a sane state after it has been corrupted. It is similar to an stty sane command.
Gets and sets serial port information. Superuser can use this utility to configure a serial port. The following command sets the input address of /dev/ttys0 to 0x100, the interrupt (IRQ) to 5, and the baud rate to 115,000 baud:
# setserial /dev/ttys0 port 0x100 irq 5 spd_vhi
You can also check the configuration of a serial port with setserial:
# setserial /dev/ttys0 /dev/ttyS0, UART: 16550A, Port: 0x0100, IRQ: 5, Flags: spd_vhi
Displays information about a file or filesystem. The f (filesystem) option followed by the device name or mount point of a filesystem displays information about the filesystem including the maximum length of filenames (Namelen in the following example). See the stat man page for more information.
$ stat -f /dev/hda File: "/dev/hda" ID: 0 Namelen: 255 Type: tmpfs Block size: 4096 Fundamental block size: 4096 Blocks: Total: 121237 Free: 121206 Available: 121206 Inodes: Total: 121237 Free: 120932
A shell builtin that specifies a mask the system uses to set up access permissions when you create a file. A umask command has the following format:
where mask is a three-digit octal number or a symbolic value such as you would use with chmod (page 182). The mask specifies the permissions that are not allowed. When mask is an octal number, the digits correspond to the permissions for the owner of the file, members of the group the file is associated with, and everyone else. Because mask specifies the permissions that are not allowed, the system subtracts each of the three digits from 7 when you create a file. The result is three octal numbers that specify the access permissions for the file (the numbers you would use with chmod). A mask that you specify using symbolic values specifies the permissions that are allowed.
Most utilities and applications do not attempt to create files with execute permissions, regardless of the value of mask; they assume you do not want an executable file. As a result, when a utility or application (such as touch) creates a file, the system subtracts each of the three digits in mask from 6. An exception is mkdir, which assumes that you want the execute (access in the case of a directory) bit set.
The following commands set the file-creation permissions mask and display the mask and its effect when you create a file and a directory. The mask of 022, when subtracted from 777, gives permissions of 644 (rwrr) for a file and 755 (rwxr-xr-x) for a directory.
$ umask 022 $ umask 0022 $ touch afile $ mkdir adirectory $ ls -ld afile adirectory drwxr-xr-x 2 sam sam 4096 May 2 23:57 adirectory -rw-r--r-- 1 sam sam 0 May 2 23:57 afile
The next example sets the same mask using symbolic values. The S option displays the mask symbolically:
$ umask u=rwx,g=rx,o=rx $ umask 0022 $ umask -S u=rwx,g=rx,o=rx
Displays information about the system. Without any arguments, this utility displays the name of the operating system (Linux). With a a (all) option, it displays the operating system name, hostname, version number and release date of the operating system, and type of hardware you are using:
# uname a Linux pbnj 2.6.15-1.1871_FC5 #1 Mon Jan 23 15:53:52 EST 2006 i686 athlon i386 GNU/Linux