Linux root user's manual

Change to root user

su - run a shell with substitute user and group IDs
$ su - root
Password : ********
#

Shutdownn

# halt
or
# shutdown -h now

Reboot

# reboot
or
# shutdown -r now

Make Group

Edit /etc/group
staff:x:500:
trainee:x:501:

Make General user. (This user can use telnet)

useradd [UserName] -g [GroupId]
# useradd hoge -g staff
# passwd hoge

Mount CD-ROM Drive

  • Mount
    # mount /mnt/cdrom
    
  • Unmount
    # umount /mnt/cdrom
    # eject
    

    Mount file system

  • Mount ISO file by command
    # mount suse-10.0-dvd.iso /mnt/suse -o loop
    
  • Mount SMB (windows file sharing) by command
    # mount -t smbfs -o username=administrator,password=123 //srv1/share /mnt/srv1/
    
  • Mount file systems automatically, edit /etc/fstab
    /somewhere/suse-10.0-dvd.iso /mnt/suse iso9660 ro,loop 0 0
    //srv1/share /mnt/srv1/ smbfs username=administrator,password=123 0 0
    
  • cron - daemon to execute scheduled commands (Vixie Cron)

    # crontab -u root -e
    
    Edit like this
    0 4 * * * /root/bin/test
    
    Colums
    1 minute
    2 hour
    3 month
    4 year
    5 day of week(0:Sunday, 1:Monday, ...7:Saturday)

    rpm - Red Hat Package Manager

  • Install
    # rpm -ivh package.rpm
    
  • Install from source
    # rpm --rebuild package.src.rpm
    
  • Update
    # rpm -Uvh package.rpm 
    
  • Uninstall
    # rpm -e package
    
  • Installed packages list
    # rpm -qa | less
    
  • See the pachage's information
    # rpm -qi apache
    
  • See the pachage's file list
    # rpm -ql apache
    
  • Query the package which contains the file
    # rpm -qf /etc/passwd
    setup-2.5.12-1
    
  • See dependancies to install the pachage
    # rpm -q --requires apache
    # rpm -qR apache
    
  • RPM packages's download site
    http://rufus.w3.org/linux/RPM/

    df - summarize free disk space

    # df
    Filesystem         1024-blocks  Used Available Capacity Mounted on
    /dev/hda7             256592  201147    42193     83%   /
    /dev/hda8             256592   74744   168596     31%   /home
    /dev/hda5            1732961  476993  1166408     29%   /usr
    /dev/hda6            1732961  430138  1213263     26%   /var
    

    bashrc - Login script

  • /etc/bashrc
    # /etc/bashrc
    # System wide functions and aliases
    # Environment stuff goes in /etc/profile
    
    alias llmo="ls -lt | less"
    ................
    

    tar - tape file archiver

  • Backup to a tape device
    # tar cvf /dev/rst0 /usr
    
  • List the contents of an archive
    # tar tvf /tmp/etcbackup.tar
    
  • Create a new archive
    # tar cvf /tmp/etcbackup.tar /etc
    
  • Extract files from an archive
    # tar xvf /tmp/etc/backup.tar
    
  • Create a new archive with compression
    # tar zcvf log.tar.gz log
    
  • Extract files from a compressed archive
    # tar zxvf log.tar.gz
    

    compress - compress and expand data

  • Compress
    # ls -lt test.tgz
    -rw-r--r--   1 root     root       604160 Aug 26 05:31 test.tgz
    # compress test.tgz
    # ls -lt test.tgz*
    -rw-r--r--   1 root     root        56373 Aug 26 05:31 test.tgz.Z
    #
    
  • Expand
    # ls -lt test.tgz*
    -rw-r--r--   1 root     root        56373 Aug 26 05:31 test.tgz.Z
    # uncompress test.tgz.Z
    # ls -lt test.tgz
    -rw-r--r--   1 root     root       604160 Aug 26 05:31 test.tgz
    

    du - summarize disk usage

  • /root/.bashrc
    ...
    alias dsk='du -ks * .* | sort -n'
    ...
    
    # cd /home
    # dsk
    du: ../proc/4620/fd/4: No such file or directory
    1       samba
    12      lost+found
    386     hoge
    1068    ftp
    1541    httpd
    3009    .
    342510  ..
    # cd /
    # dsk
    du: proc/4622/fd/4: No such file or directory
    du: ./proc/4622/fd/4: No such file or directory
    du: ../proc/4622/fd/4: No such file or directory
    0       proc
    3       mnt
    12      lost+found
    39      dev
    635     boot
    654     root
    1156    tmp
    2245    sbin
    2274    etc
    3009    home
    3871    bin
    8919    var
    12333   lib
    307359  usr
    342510  .
    342510  ..
    

    e2fsck - check a Linux second extended file system

    e2fsck is used to check a Linux second extended file system.

  • If you get these messages while booting your Linux box, use e2fsck command
    ...
    /dev/sdb1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
    	(i.e., without -a or -p options)
    ----------------------------------
    
    
    *** An error occurred during the file system check.
    *** Dropption you to a shell; the system will reboot
    *** when you leave the shell.
    Givi root password for maintenance
    (or type Control-D for normal startup): Password
    
    # /sbin/e2fsck /dev/sdb1
    

    Back
    Google
    Web www.grape-info.com