Runlevel Description Directory: INIT and Run Levels
Runlevel Description Directory: INIT and Run Levels
Use chkconfig (-add, -del, -list) to view/add/change/remove services from various runlevels. Syntax is ckhconfig –level #
service on|off.
Services
Services can be maintained by using their corresponding script in /etc/rc.d/init.d directory; possible arguments are
start, stop, restart, reload, status, or * (shows all available options).
To view all services and their current status use service –status-all
Environment Variables
Variable Description
DISPLAY Redirects X Windows output to another computer.
HISTFILE The filename where past commands are stored.
HISTFILESIZE The number of past commands HISTFILE stores.
HOME The absolute path of the user's home directory.
LANG The language the operating system uses.
PAGER Used by the man command to specify the program in which to display man pages.
The directory prefixes used to search for programs and files. Use a colon to separate entries in
PATH
the PATH variable.
SHELL The user's login shell.
Script Files
File Description
This file executes immediately after a user logs in. It is a systemwide initialization file that is
/etc/profile
used primarily to set environment variables.
This file executes after /etc/profile. It is also a systemwide file that is often executed by
/etc/bashrc
individual users' .bashrc file. It is most commonly used for aliases and functions.
~/.bash_profile After /etc/profile executes, the system searches for these files in the user's home directory.
or These are optional files in which users can create settings specific to their systems.
~/.bash_login ~/.bash_login only executes in the absence of ~/.bash_profile. ~/.profile only executes in the
or absence of the other two. (The ~/ is a bash home directory variable. It eliminates your need to
~/.profile know where a user's home directory is.)
~/.bashrc This file executes when bash runs. It is often used to include /etc/bashrc in its scripts.
This script file relates to the init process. Scripts in this file execute after all the entries in the
/etc/rc.d/rc.local
/etc/inittab file have executed.
Backup/Restores
TAR – the tar command can be used to create uncompressed backups (uses gzip or bz2 via flags for compression); it may
also be used to uncompress previously created tar files, a.k.a. tarballs. Examples below:
tar –cvzf /etcbkup.tar.gz /etc – compress (gzip), backup the /etc directory to /etcbkup.tar.gz in verbose mode
tar –cjf /confbk.tar.bz2 /etc – compress (bz2), backup the /etc directory to /confbk.tar.bz2 in quite mode
The –C flag can be used to include the directory path structure in the tar: tar -cjvf report.tar.bz2 -C /mkt/reports. The
tar command also saves/restores permissions.
CPIO – pipes output from commands like ls and find to create a backup;
ls /etc/c* | cpio –ovd > /dev/rfd0 – the ls command is piped to the cpio command which is redirected to the
device mounted on rfd0 (floppy 0). Flag –o (create), -v (verbose), -d (restore to saved directory path), -i (extract).