page_title_others

TIPS

∗Cofirmed only CentOS5.X.

  • Off beep sound
    Command line
    $ vi ~./inputrc
     set bell-style none ← Add
    $ source .inputrc
    vi
    $ vi ~/.vimrc
     set vb t_vb= ← Add
    $ source .vimrc
    X Window
    $ vi ~/.bash_profile
     xset -b ← Add
    $ source .bash_profile
    ∗If not silent, logout once.
  • Change keyboard system from English to Japanese
    # vi /etc/sysconfig/keyboard
     KEYTABLE="us"
      ↓ Modify
     KEYTABLE="jp106"
    Reboot
  • Make large size file
    $ dd if=/dev/zero of=example bs=1M count=1000
  • Check information of connected devices
    $ dmesg | less
     search "sd"
  • Calculate the time of command execution
    $ time command
  • Out put stdout and stderr into same file
    $ command1 > command2 2>&1
  • Change umask
    $ vi ~/.bash_profile
     umask 022 ← Add
    ∗File : 666 - 022 = 644
    ∗Directory : 777 - 022 = 755
  • Compile and make execution file using GCC
    C program
    $ gcc -o example example.c
    C++ program(1)
    $ gcc -o example example.cpp -lstdc++
    C++ program(2)
    $ g++ -o example example.cpp
  • Create symbolic link to directory
    # ln -s /var/www/html/people/takase /home/takase/html
    # chown takase:takase /var/www/html/people/takase /home/takase/html
    ·Add files to /home/takase/html, refrect to /var/html/people/takase.
    ·ln -s [Destination] [Departure]
    ·Sabstane files are in Destination directory.
    ·When you execute ln command, /home/takase/html directory does not exists.
  • Check machine information
    CPU information
    $ less /proc/cpuinfo
    ∗if lm is in flags, CPU is 64bit.
    Memory information
    $ less /proc/meminfo
    OS information
    $ cat /etc/redhat-release
  • Erase strings on command line.
    Ctrl+u
  • Debug shell
    $ sh -x ./example.sh
  • find command
    Search all files which named hoge* in root directory(recursive)
    $ find / -name "hoge*"
  • Use \n and \t in echo command
    $ echo -e "Hello\tworld!\n"
  • Search strings including space or tab using grep command
    $ grep "Hello[[:space:]]world!" file
  • cut command
    ·Get field values from 1 to 5 separating ":"
    $ cut -d':' -f1,5
  • awk command
    ·Get field values 1 and 5 separating ":"
    $ awk -F':' '{ print $1,$5 }' file
  • sed command
    Replace(1)
    ·Replace hoge to fuga matching first
    $ sed -e "s/hoge/fuga/" file
    Replace(2)
    ·Replace hoge to fuga matching all
    $ sed -e "s/hoge/fuga/g" file
    Replace(3)
    ·Replace hoge to fuga, then replace piyo to bar
    $ sed -e "s/hoge/fuga/" -e "s/piyo/bar/" file
    Replace(4)
    ·Replace multiple spaces to one
    $ sed -e "s/  */ /g" file
    Delete(1)
    ·Delete line form 1 to 5
    $ sed "1,5d" file
    Delete(2)
    ·Delete line including hoge
    $ sed -e "/hoge/d" file
    Delete(3)
    ·Delete blank line
    $ sed -e "/^$/d" file
    ∗Not delete lint using replace command
  • Delete duplicate line
    $ sort file | uniq
  • Check login information
    $ finger
    $ id
    $ who
    $ last
    $ w
  • Check installed packages using yum command
    # yum list installed | grep exaple
  • Check listening ports
    $ netstat -tnlp
  • Compress/Extract tar.tgz file
    Compress
    $ tar zcvf file.tar.tgz target target
    Extract
    $ tar zxvf file.tar.tgz
  • Compress/Extract tar file
    Compress
    $ tar cvf file.tar target target
    Extract
    $ tar xvf file.tar
  • Install/Uninstall RPM packages
    Install
    # rpm -ivh example.rpm
    Uninstall
    # rpm example -e
    ∗Not include ".rpm".
  • Defference between TCP Wrapper and iptables
    TCP Wrapper
    ·Works the services controled by inetd.
    ·mediate between inetd and services.
    ·If accessed by trusted hosts, service starts.
    ·Setting by hosts.allow„ÄĀhosts.deny.
    ·Control in application level.
    iptables
    ·Works the services run by init.d.
    ·The services, which are not controlled by initd, are not able to TCP Wrapper, so packet filtering by iptables.
    ·iptables works in IP rayer of OSI Layers and Their Functions, so accesses are controled earlier step than TCP Wrapper.