6.13 Some administration commands

su

(=substitute user id) Assume the superuser (=root) identity (you will be prompted for the password). Type "exit" to return you to your previous login. Don't habitually work on your machine as root. The root account is for administration and the su command is to ease your access to the administration account when you require it. You can also use "su" to assume any other user identity, e.g. su barbara will make me "barbara" (password required unless I am the superuser).

alias ls="ls --color=tty"

Create an alias for the command "ls" to enhance its format with color. In this example, the alias is also called "ls" and the "color" option is only evoked when the output is done to a terminal (not to files). Put the alias into the file /etc/bashrc if you would like the alias to be always accessible to all users on the system. Aliases are a handy way to customize your system. Type "alias" alone to see the list of aliases for your account. Use unalias alias_name to remove an alias.

cat /var/log/httpd/access_log

Show who connected to your http (apache) server since the last time the log file was "rotated" (normally rotated once a day, when cron runs). The previous log file is access_log.1, the yet previous access_log.2, etc.

cat /var/log/secure

(as root) Inspect the important system log. It is really a good idea to do it from time to time if you use Internet access.

ftpwho

(as root) Determine who is currently connected to your ftp server.

printtool

(as root in X-terminal) Configuration tool for your printer(s). Settings go to the file /etc/printcap and (strangely) /var/spool/lpd.

setup

(as root) Configure mouse, soundcard, keyboard, X-windows, and system services. There are many distibution-specific configuration utilities,setup is the default on RedHat. Mandrake 7.0 offers very nice DrakConf .

linuxconf

(as root, either in text mode or in the X terminal). You can access and change hundreds of network setting from here. Very powerful--don't change too many things at the same time, and be careful with changing entries you don't understand. ReadHats network configuration utility netconf is a subset of linuxconf, therefore it is simpler and sometimes easier to use.

mouseconf

(as root). Simple tool to configure your mouse (after the initial installation). Mandrake includes also an alternative mousedrake.

kudzu

(as root). Automatically determines and configures your hardware. If having mysterious problems with your mouse (or other serial hardware), you may want to disable kudzu, so it does not run on the system startup (kudzu messed up my system so I could not have my mouse working). You can run it manually when you need it.

timeconfig

(as root) Set the timezone for your system. My computer hardware clock (BIOS setup) keeps time in UTC (Coordinated Universal Time, which was once called GMT or the Greenwich Mean Time). This way, I avoid any possible problems associated with switching timezones due to the daylight savings time, transferring files across the globe through the network, or a physical travel. It is customary to keep time on a server computers in UTC to avoid time ever going "backwards" (which could cause problems). Timestamps on files are always kept in UTC and displayed in the local time using the time zone information. For example, many applications (e.g., compilers, databases) depend on being able to distinguish a newer file from an older one by comparing their timestamps. It is important to keep the timezone correct. The only reason why I could select to keep BIOS time in the local time is to avoid problems when when dual booting from the same computer, and when the other operating system (MS Windows?) does not know how to handle UTC. Then, I let my Linux server know about this by checking the box "Hardware clock set to GMT", so that Linux can back-calculate the UTC which it needs.

setclock

(as root). Set your computer hardware clock from the current Linux system time. Use the command "date" first to set up the Linux system time. E.g., I could change the date and time to 2000-12-31 23:57 using this command:

date 123123572000

and then write the time to the hardware clock using:

setclock


dateconfig&

(in X-terminal, as root else you will be asked for the root password). An excellent GUI utility to set my operating system and hardware clock and timezone, and tell my BIOS to keep time in UTC. I don't need the previous two commands.


xvidtune

(in X-terminal). Adjust the settings for your monitor display for all resolutions so as to eliminate black bands, shift the display right/left/up/down, etc. (First use the knobs on your monitor to fit your text mode correctly on the screen). Then use xvidtune to adjust the monitor frequencies for each resolution so it fits well in your screen. To make the changes permanent, display the frequencies on the screen and then transfer them to the setup file /etc/X11/XF86Config. On newer monitors, you may really prefer to adjust your monitor using the built-in monitor settings--xvidtune is for older monitors which do not have the capability to remember their settings.

kvideogen

(in X-terminal). Generate "modelines" for customized resolutions of your screen. After you generated the setup text (the "modelines"), you can copy-paste it to the X-windows setup file /etc/X11/XF86Config (or /etc/X11/XF86Config-4 if you use X-server version 4.xx). See also the keyboard shortcut <Ctrl><Alt><+>

SVGATextMode 80x25x9

SVGATextMode 80x29x9

(as root) Change the text resolution in the text terminal. In the above example (second line) I changed the text screen to 80 columns x 29 lines with characters 9 pixels high. The first line defines a resolution that always works, so that if the second command did not work on my system, I can press <ArrowUP> twice and <Enter> to regain control over my screen. The possible modes depend on your video card and your monitor synchronization frequencies--I needed to edit (as root) the file /etc/TextConfig and (un)comment the proper lines to let SVGATextMode know what my system supports.

SuperProbe

(as root). A utility to determine the type of the video card and the amount of its memory.

cat /var/log/XFree86.0.log

A log file for X that can be useful to determine what is wrong with your X setup. The "0" in the filename stands for "display 0"--modify the filename accordingly if you need log for displays "1", "2", etc.

lspci

Show info on your motherboard and what cards are inserted into the pci extension slots. My older computer has ISA slots (or EISA) slots, no pci.

lsdev

Display info about your hardware (DMA, IRQ, IO ports).

lsof|more

List files opened on your system.

kernelcfg

(as root in X terminal). GUI to to add/remove kernel modules. Module is like a device driver--a piece of Linux kernel that provides support for a particular piece of hardware or functionality. You can do the same from the command line using the command insmod.

lsmod

(= list modules). List currently loaded kernel modules. A module is like a device driver--it provides operating system kernel support for a particular piece of hardware or feature.

modprobe -l |more

List all the modules available for your kernel. The available modules are determined by how your Linux kernel was compiled. Almost every possible module/feature can be compiled on Linux as either "hard wired" (perhaps a bit faster, but non-removable), "module" (maybe a bit slower, but loaded/removable on demand), or "no" (no support for this feature at all). The modules which your kernel supports (with which it was compiled) are all as files under the directory /lib/modules (and the subdirectories) so browsing it may give you a clue if you are lost. If your kernel does not support a module you require, you may need to re-compile your kernel with this module enabled (this is rare because the "stock" RedHat or Mandrake Linux kernels come with almost all common and non-experimental modules pre-compiled. Still, if you have a bleeding edge hardware ... ).

modprobe sb

Load the soundblaster (sb) module. Use the previous command to find other kernel modules there are to load.

insmod parport

insmod ppa

(as root) Insert modules into the kernel (a module is roughly an equivalent of a DOS device driver). Normally, I use "modprobe" (see the previous command) to insert modules. This example shows how to insert the modules for support the external parallel-port 100-MB zip drive (it appears to be a problem to get the external zip drive to work in any other way under RH6.0 and 6.1). For the 250-MB external zip, I use the imm module instead of ppa.

rmmod module_name

(as root, not essential). Remove the module module_name from the kernel.

depmod -a

(as root) Build the module dependency table for the kernel. Not essential unless you modified /etc/modules and don't wish to reboot.

setserial /dev/ttyS0 port 0x03f8 irq 4

(as root) Set a serial port to a non-standard setting. The example here shows the standard setting for the first serial port (ttyS0). The standard PC settings for the second serial port (ttyS1) are: address of i/o port 0x02f8, irq 3. The third serial port (ttyS2): 0x03e8, irq 4. The forth serial port (ttyS3): 0x02e8, irq 3. Add your setting to /etc/rc.d/rc.local if you want it to be set at the boot time. See man setserial for good a overview. In old versions of Linux you can also find alternative names for serial ports (cua0 to cua3 which you may use instead of ttyS0 to ttyS3) but these cua* names are now obsolete.

tunelp

(as root, rarely needed) Tune up your parallel ports.

/sbin/chkconfig --level 123456 kudzu off

(as root)A tool to check/enable/disable system services which will automatically start under different runlevels. Typically, I just use RedHat ntsysv utility if I need to enable/disable a service in the current runlevel, but chkconfig does give me an extra flexibility. An alternative tool is tksysv (X-based). The example above shows how to disable kudzu service so it does not start up at any runlevel (it messes up mouse on one of my computers). To list all the services started/stopped under all runlevels, I use:

chkconfig --list | more

To check the current status of services, I may use:

service --status-all

To start a service right now, I may use something like (starts an ftp server):

service wu-ftpd start

To re-start samba networking (e.g., after I changed its configuration), I may use:

service smb restart


symlinks -r -cds /

(as root) Check and fix the symbolic links on my system. Start from / and progress through all the subdirectories (option -r="recurse") and change absolute/messy links to relative, delete dangling links, and shorten lengthy links (options -cds). If my filesystem spreads over different hard drive partitions, I need to re-run this command for each of them (e.g., symlinks -r -cds /usr).

cd /usr/src/linux-2.4.7-10

make xconfig

(as root in X terminal). A nice GUI front-end for configuration of the kernel options in preparation for compilation of your customized kernel. (The directory name in the example contains the version of my Linux kernel so you may need to modify the directory name if your Linux kernel version is different than 2.4.7-10 used in this example. You need the "Tk" interpreter to run “make xconfig”, and the kernel source code installed.) The alternatives to "make xconfig" are: "make config" (runs a scripts that asks you questions in the text mode) and "make menuconfig" (runs a text-based menu-driven configuration utility).

Try: less /usr/share/doc/HOWTO/Kernel-HOWTO for more information.

After configurating the options for the new kernel with "make xconfig", I may proceed with compilation of the new kernel by issuing the following commands:

The last command will take some time to complete (maybe 10 min or 2 h, depending on your hardware). It produces the file arch/386/boot/bzImage, which is your new Linux kernel. Next:

Now you have the new modules installed in /lib/modules/KernelName.

Don't rename the module directory if you want to run multiple kernels--the kernel must be able to find its "matching" modules. If I want to change the kernel name, I have to edit the main kernel makefile (e.g., /usr/src/linux-2.2.14/Makefile) and change the lines right at the top. Mine (default RH7.2) are:

VERSION = 2

PATCHLEVEL = 4

SUBLEVEL = 7

EXTRAVERSION = -10custom

The kernel name for the currently running kernel can be displayed using uname -r . Mine (default RH7.2) is "2.4.7-10custom".

The configuration for my "original" RedHat kernel is in the file /boot/config-2.4.18-14 (RedHat 8.0), while some additional "custom" kernel configurations are in the directory /usr/src/linux-x.x.x/configs. I can load any of those from a dialog box in available from "make xconfig".

Now I can install the new kernel. The installation involves copying the new kernel (while renaming it) into the /boot directory:

cp arch/386/boot/bzImage /boot/vmlinuz-2.4.7-10custom

cp System.map /boot/System.map-2.4.7-10custom

and making changes to /etc/lilo.conf or /boot/grub/grub.conf so I can select at the boot time which kernel (the old or the new) to boot. It is strongly advised that you preserve the old kernel as a boot option (in case the new kernel refuses to boot).

If you use initrd (initial ram disk) for two-stage booting, you may also need to create an image with modules used by the kernel during startup:

mkinitrd /boot/initrd-2.4.7-10custom.img 2.4.7-custom

See this for details on kernel patching. Quick reference:

cd /usr/src/linux-2.4.7-10

patch -E -p1 < /home/download/the_patch_to_apply

It may also be helpful to read: /usr/doc/HOWTO/Kernel-HOWTO and perhaps man depmod. Configuration, compilation and installation of a new kernel is quite simple but it CAN lead to problems. Compilation of a kernel is also a good way to test your hardware, because it involves considerable amount of computing. If your hardware is "flaky", you may receive the "signal 11" error (then read the /usr/doc/FAQ/txt/GCC-SIG11-FAQ).

ldconfig

(as root) Re-create the bindings and the cache for the loader of dynamic libraries ("ld"). You may want to run ldconfig after an installation of new dynamically linked libraries on your system. (It is also re-run every time you boot the computer, so if you reboot you don't have to run it manually.)

mknod /dev/fd0 b 2 0

(=make node, as root) Manually create a device file. This example shows how to create a device file associated with your first floppy drive and could be useful if you happened to accidentally erase it. The options are: b=block mode device, c=character mode device, p=FIFO device, u=unbuffered character mode device. The two integers specify the major and the minor device number. I normally wouldn't know the parameters which mknod requires. So to make devices, I first read man MAKEDEV to figure the name of the device and then run the script /dev/MAKEDEV which knows about Linux devices by their names--see the next command. If the mentioned manual page does not help, I may refer to the ultimate documentation included with the kernel source code:

less /usr/src/linux/Documentation/devices.txt


cd /dev

./MAKEDEV audio

(as root). Restore the "audio" device that I just somehow screwed up. Also see the previous command.



UNIXguide.net
Suggest a Site