Sunday, April 03, 2011

Basic linux commands

List down my basic linux commands as my reference

  • cd  folder      
  • cd ..
  • cd ../..
  • pwd       -->show path
  • man xx  -->manual of command xx (eg: man rm)
  • cp          --> copy
  • rm -rf    -->force to remove (-f), including directory (-r)
  • rm -i      -->remove with prompt
  • mv x1 x2 -->rename or move file into a directory
  • uname -a -->check linux version & machine info (print system information)
  • du -ah .  -->check total used disk space
  • df -ah .   -->check disk usage, can know total used & available free disk space
  • top         --> to check processes that are running 
  • jobs
  • ps           --&gt show running process
  • grep xx    --> to grep xx from a file or process
  • kill -9  PID --> kill the process with PID number, which can get from top
  • ln -s xx1 xx2  -->soft link command 
  • usermount    --> A graphical tool to mount, unmount and format filesystems
  • cd /mnt/      -->mount directory
  • cd /media/  --> media mounted directory eg usb
  • pushd
  • popd

  • vi
  • vim
  • nedit
  • emacs
  • tkdiff    (make comparison between two files)

 Tar command
  • man tar
  • tar -xvf    file.tar
  • tar -xvfz  file.tar.gz
  • tar -xvfj   file tar.bz2
  • tar -cvf    create.tar   folder/

  • su           -->super user (root)
  • sudo  xx --> 
  • ldd      -->check dynamic link  (eg #ldd /usr/bin/vim)
  • rpm -ivh xxx.rpm
  • yum install  xxx 
  • yum search xxx

  • /sbin/ifconfig     -->showing network
  • /sbin/iwconfig   -->showing wireless network
  • /sbin/iwlist       --> list of wireless network 
  • ping
To restart network:
type # /etc/init.d/network restart

To start Linux network service:
# /etc/init.d/network start

To stop Linux network service: [type whole path]
# /etc/init.d/network stop

#/sbin/service network restart

setup hosts

vi /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.               localhost.localdomain localhost               circuit.localdomain circuit

alternative way

vi /etc/sysconfig/network

HOSTNAME="circuit "

.bashrc   or .cshrc

add this
  •  export PATH=$PATH:/sbin:/usr/sbin         #will include /sbin/ command like ifconfig

Install program path
It is better to save into this path because all user can use them
  • /usr/local/bin/

Boot file
  • store in /boot/grub
 Auto Mount file
  • /etc/fstab
 LABEL=/                 /                       ext3    defaults        1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda7         swap                    swap    defaults        0 0
/dev/sda8               /app                    ext3    defaults        0 0
/dev/sda3               /mnt/win_c              ntfs-3g auto    0 0
/dev/sda5               /mnt/win_f              ntfs-3g auto    0 0

 secure copy
  • scp -r directory_tobe_copy username@my_local_pc_IP:.  ( "." to home )
  • scp -r directory_tobe_copy username@my_local_pc_IP:/app/.  ( copy to /app/ ) 
  • scp -r directory_tobe_copy my_local_pc_IP:/app/.  ( same username & copy to /app/ )
  • ssh username@remote_pc_IP  (diff username)
  • ssh remote_pc_IP       (same username)

download realvnc from webpage
untar it to install

enable gnome in vnc

cd .vnc
vi xstartup

add the following change in the last line

#twm &  (commend out the twm by)
exec gnome-session &   (add this)