(Updated Aug 23 2004)
** start to text interface
/etc/inittab
id:5:initdefault -> id:3:initdefault
** mount
/etc/fstab
mount /dev/sda1 /mnt/usb
lsmod
modproble usb-storage
dmesg
** x86 config
/etc/X11/XF86Config
/etc/X11/XF86Config-4
using ImPS/2 instead of PS/2 to support wheel mouse
** to check the kernal version
uname -r
** to check redhat version
cat /proc/version or
cat /etc/redhat-release
** empty root password
start using single mode
( grub PRESS e
kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ PRESS e
kernel /boot/vmlinuz-2.4.18-14 single ro root=LABEL=/ PRESS ENTER
PRESS b
vi /etc/shadow
modify the line starting with root to become
root::......
reboot, and now passwd is empty
** check system information
cat /proc/cpuinfo
cat /proc/interrupts
cat /proc/ioports
cat /proc/meminfo
cat /proc/partitions
cat /proc/pci
cat /proc/swaps
cat /proc/version
** automount windows partitions
vi /etc/fstab
/dev/hda5 /mnt/d vfat defaults,codepage=936,iocharset=cp936 0 0
** auto synchronize time
vi /etc/crontab
add line
00 0 1 * * root rdate -s time.nist.gov
* listing files
ls -a (all)
ls -l (long)
* viewing files
cat/more/less
* symbolic links
ln -s prog.1.1 prog (creat a link named prog that points to the actual file
named prog.1.1)
ln -sf /lib/libncurses.so.5.4 /lib/libncurses.so.5 (update the symbolic link
to point to the new library)
** to read pdf file
xpdf shoot.pdf
** to see the usage of harddisk
df -k
df -h
** to see the size of a directory
du -sh %dirname%
** unzip
tar jxvf example.tar.bz2
tar zxvf example.tar.gz
unzip example.zip
** compresssion utilities
gzip garbage.txt
gzip -l garbage.txt.gz (get information on a gzipped file)
gunzip garbage.txt.gz
tar cvf mt.tar mt (tar a directory mt)
tar xvf mt.tar (untar)
tar zcvf mt.tar.gz mt (tar and compress)
tar zxvf mt.tar.gz (extract and untar)
** search a file in a multi-level directory
find -name filename.ext
du -a | grep filename.ext
locate filename.ext
* redirection
ls /bin >> ~/binaries
du | sort -nr (sort the output of disk usage)
du | sort -nr | more (use a second pipe)
** changing owner, group and permissions
chown joe dir/
chmod +x header
chmod -x header
chmod u+x header (only assign execute permission to myself)
chmod ug+x header (assign execute permission to both myself and the file's
group)
chmod ug+rwx header (assign multiple types of permissions)
+-----User-----+-----Group-----+-----Other-----+
read|write|exec+read|write|exec+read|write|exec+
400 200 100 40 20 10
4 2 1
chmod 400 header (just give yourself read permission)
chmod 444 header (give everybody read permission)
chmod 555 header (give everybody read/exec permission)
chmod 755 header (rwxr-xr-x)
refer:
http://www.tldp.org/HOWTO/Net-HOWTO/
http://www.linuxheadquarters.com/howto/networking/networkconfig.shtml
* before configuration, stop network
ifdown eth0
or /etc/init.d/network stop
/etc/rc.d/init.d/network stop
* verify the network module is loaded by issuing
/sbin/lsmod
* activate the eth0 by issuing
ifup eth0
or
/etc/rc.d/init.d/network start
* dns server
/etc/resolv.conf
name server 151.201.0.39 # same as the DNS servers IP in windows ipconfig
* /etc/host.conf
order hosts, bind
multi on
* /etc/hosts
127.0.0.1 localhost loopback
192.168.0.1 this.host.name
* hostname :
/etc/sysconfig/network
** change IP address permanently
ifconfig eth0 %newip%
vi /etc/sysconfig/network-scripts/ifcfg-eth0 (change ip)
#shells
echo $SHELL (what my shell is)
chsh (change shell)
#useful keys and how to set them to work
stty -a (to check the list of the current terminal settings)
stty erase ^H
stty kill ^U
stty susp ^Z (setup the key functions)
#setting variables
export PATH=$PATH:/usr/sbin (bash-> add a path, but makes it the last
directory that is searched.)
set path = ( $PATH /usr/sbin ) (under csh/tcsh)
** set/unset environment variable
bash:
export var_name=var_value
unset var_name
chs:
setenv var_name var_value
unsetenv var_name
exit: CTRL+XC
help: CTRL+H
open file: CTRL+XF (or new file)
save file: CTRL+XS
save as: CTRL+XW
#Repaint screen
CTRL+l (lowcased L)
#Undo last edit(can be repeated)
CTRL+/(CTRL+SHIFT+MINUS)
#Redo last
#to abort any control or escape sequence
CTRL+G
#move cursor to line beginning
CTRL+A
#move cursor to line end
CTRL+E
#to mark block beginning
CTRL+@
#cutting the block
CTRL+W
#pasting the block(can also paste the clipboard from other program)
CTRL+Y
#copy the block
ESC+W
#delete from cursor to line end
CTRL+K
C-s search the document forward for string you name
C-r search the document backward for string you name
#remote cvs
#if using ssh (bash/)
# To set an environment variable in sh or ksh, use the syntax VAR=value;export
VAR,
# where VAR is the name of the environment variable and value is the value you
wish to assign.
# Do not put spaces on either side of the equals sign. The export command instructs
the shell
# to propagate the value of the variable to all programs that are run by the
shell.
# If an environment variable is reset, but not exported, the change will only
apply to the shell itself
[root@localhost root]# CVS_RSH=ssh
[root@localhost root]# export CVS_RSH
[root@localhost root]# echo $CVS_RSH
ssh
#if using csh
[root@localhost root]# setenv CVS_RSH ssh
#cvs checkout
cvs -d :ext:%username%@%server_domain%:%cvs_root_directory% checkout %modulename%
# cvs KEY LETTERS
P: the file has been updated. The P is shown if the file has been added to the
repository in the meantime or if
has been changed, but you have not made any changes to this file yourself.
U: You have changed this file in the meantime, but nobody else has.
M: You have changed this file in the meantime, and somebody else has checked
in a newer version. All the changes
have been merged successfully.
C: You have changed this file in the meantime, and somebody else has checked
in a newer version. During the merge
attempt, conflicts have arisen.
?: CVS has no information about this file - that is, this file is not under
CVS's control.
#upgrading software
ldd /usr/bin/X11/xterm (list the shared libraries on which a given executable
depends)
#using RPM
rpm -i SuperFrob-4.i386.rpm (install a new package)
rpm -U SuperFrob-4.i386.rpm (update a package that is already installed)
rpm -e SuperFrob-5 (uninstall)
rpm -q SuperFrob (find the version number of an installed package)
rpm -qa (get a list of all installed package)
rpm -qf /usr/bin/dotherpb (find out to which package a file belongs)
rpm -qi gcc (display information about the specified package)
rpm -qpl SuperFrob-5.i386.rpm (show the files that will be installed for the
specified package file)
** to eject cd tray
eject -r
recover linux boot
boot linux in recovery console
#grub-install /dev/hda
** debug core file
gdb <programe> <core>