General Red Hat Linux Information
Run Levels & some Common Commands
A Few Things to Remember
- When you su to Root, _your_ environment is exported (still active) so things like $PATH are unchanged.
- Use su - to get the environment to match the new user ID. This will send you to the new ID's home dir.
- You can use su -c "command_string_in_quotes" if you only want to run one command as root.
- If you stop the network with /etc/rc.d/init.d/network stop it also stops lo, the local loopback interface.
- If you run ps without any switches, it only shows processes running in _that_ shell. Use ps -ea for all ps's
- If you appear to lock the system while experimenting you can usually avoid a reboot by trying one of:
- ctr-alt-F1 will show the X server output, alt-F7 to return to X
- ctr-alt-F2 (F2 to F6) to a new console. Try to kill the problem process.
- if your home dir is on an NFS server, and it disappears, (from playing with pump) restart the network with "/etc/init.d/network stop" then ...start.
- try to ssh or telnet into the system if either service runs on that system.
- ctr-alt-backspace will kill X
Runlevels
These are the runlevels that you may want to change using init or telinit
Runlevels:
- 0 shutdown
- 1 single user mode (for system maintenance or recovery only)
- 2 multiuser mode (networking is enabed, but no NFS)
- 3 standard runlevel (includes file sharing and most other services)
- 4 user defined or empty
- 5 same as 3, but with DNS, X11, xdm
- 6 reboot
For example, to reboot the saystem use telinit 6
Each Runlevel activates the scripts in its respective rcX.d directory (/etc/rc.d/rc0.d, rc1.d, etc)
The runlevel scripts are actually links to scripts in /etc/rc.d/init.d which can be controlled with the chkconfig command.
Useful Commands
** Always read the man page or at least use --help _BEFORE_ executing any command. **
** most commands have switches that dramatically change the functionality. **
Disk/Filesystem Related Commands:
- dd -copy a file or image to another file or device. (use to copy a boot image to a floppy disk)
- df -shows filesystem use by partition -use df -i for inode useage
- du -shows disk usage of each FILE, recursively for directories
- dump -backup files or filesystems
- fdformat -low level format a floppy disk
- fdisk -like everyone else's, but more in depth
- fsck -check and repair a Linux file system
- mkbootdisk -mk stands for make, you figure it out. (standard modular kernels only)
- mkfs -build a Linux File System, usually on a hdd
- restore -restores data from dump archive
- taper -front end for dump and restore (can probably set to other utils)
File and Navigation (& Script) Related Commands:
- alias -creates a shortcut for a command
- awk -extract fields from data
- bg -sends a job to the background
- cat -create, combine or display contents of files
- cd -change directory. With no arguments it changes to your HOME directory
- chattr -change file or directory attributes
- chgrp -change file or directory group membership
- chmod -change file or directory privileges
- chown -change file or directory ownership
- cmp, comm, diff -compare contents of files
- cp -copy a file or directory
- exec -replaces the running process with a new one
- exit n -quits the shell with exit status n
- expand -convert tabs to spaces
- export -makes variables available to spawned shells
- fg n -brings job n to the foreground
- find -search for files within a specified directory hierarchy
- grep, egrep, fgrep -searches directory or file contents. -use to include or exclude strings
- head, tail -display beginning or end of a file. also monitor and display changes
- jobs -lists all jobs (background and suspended)
- less -buffers screen output and allows scrolling up or down
- ln -create either a hard or symbolic link to a file or directory
- locate -locate a file anywhere on the system (use with grep to filter results)
- lsattr -list file or directory attributes
- ls -list directory contents
- merge -incorporates changes from two separate working files into a third (original) file
- mkdir -make a directory
- more -displays output one screen at a time. But less is much more!
- mv -move a file or directory
- paste -combine two files line by line (file1_line1 + file2_line1 = file3_line1)
- pico -an easier, less powerful, text editor. A good choice to start with
- Piping, I/O and error redirection to control output
- a Pipe or
|
allows the output of one command to be sent as input to another
- redirect input, output or error messages with
<
or >
- a semicolun seperates commands, running them sequentially
- pwd -print working directory (aka: "where the heck am I?")
- rm -remove a file or directory
- rmdir -remove a directory
- sed -edit and substitute fields from data
- sort -sort lines within text files
- tar, compress, gzip, zcat -used for file compression and decompression
- tr -manipulates single or multiple characters
- unexpand -convert spaces to tabs
- vi -the best text editor. (Actually it is usually alliased to 'vim' "vi improved")
- wget -quick command to download files from web and ftp sites (binary mode)
- which -shows first occurrence of filename in users path. This is the one that will execute
Cursor & Shell Control Keys:
- ctl u -clear left from cursor (also works in most programs)
- ctl k -clear right from cursor (also works in most programs)
- ctl e -move cursor to end of text (also works in most programs)
- ctl s -put shell to sleep
- ctl q -wake the sleeping shell
- ctl p -previous command (like up arrow)
- ctl n -next command (like down arrow)
- ctl "any other character" -causes some other action (or not)
Network Related Commands:
- dig -send domain name query packets to name servers
- host -DNS lookup utility
- ifconfig -displays or manipulates the network interfaces
- ifdown -use to stop a singe active interface, as opposed to using /etc/ini.d/network stop
- ifup -use to activate a singe interface, as opposed to using /etc/ini.d/network start
- netconf -configure networking
- netconfig -set up networking
- netstat -lots of info re routing, etc.
- nslookup -get information from name servers (replaced by host or dig)
- pump -configure net interface using DHCP protocol
- tcpdump -dumps all tcp traffic to screen
- whois -retrieves info on domains by name, also see whois.arin.net for lookup via IP
System and Process Related Commands:
- chkconfig -lists and changes services started from init.d scripts
- dmesg -displays the contents of what scrolls by during boot (run level 2?)
- free -memory and system information
- kill -kill a process
- ps -shows running processes
- pstree -displays processes in tree form
- rpcinfo -report RPC information. To display all RPC services registered on the local machine use: rpcinfo -p
- tail -displays last part of file
- telinit -use to send signal to init, such as change run levels. Kind of a user interface to init
- top -displays status of most active processes
- updatedb -updated the data base used for "locate" and possibly others
- vigr -same as vipw but edits the group file
- vipw -a safer way to edit the password file. It locks the /etc/passwd, opens it in vi, and when done, unlocks it and updates any related files
Printing Related Commands:
- a2ps -convert ascii files for printing on a PostScript printer
- lpr -send a file to a printer
- mpage -print multiple pages per sheet
- ps2pdf -Convert PostScript files to PDF
Miscellaneous Commands:
- apropos -searches man page "Description" field for keyword
- crontab -automates commands by running a configured times. Read man pages for cron and crontab
- date -display or manipulate system date and time
- id -shows your UID and GID, handy to clearify when using su
- last -shows logon history
- mail -a mail utility
- man n manpage-name -will go to the man page referenced in other man pages. eg."see crontab(5)"
- man man -information on using the manual help pages. Try mam -K keyword to search all man pages
- rpm -qa |grep partial_package_name -this will show which version RPM app. is installed
- su -change your UID to a second user, by default change to Root
- time -time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. This could be used to calculate elapsed time between events
- useradd -add a new user to the system (root only)
- users -shows who is logged onto that host
- w -shows who is logged on and what they are doing
Note: If you still have not found what your after, try apropos.
original document created October 2000
updated May 2002