Sunday, October 17, 2010

Linux survival sheet (everyday usage)

count the disk usage
       du -a --max-depth=2 |sort -n >~/t
see the real(wall clock)/user(user space time)/sys(kernel space time) 
       time ./cmd
see what processes are using a file
       fuser
decide which files need to be executed at system booting
       rcconf
show hardware info
       lshw
       lspci
       x86info -a
show cpu/mem info
       cat /proc/cpuinfo
       cat /proc/meminfo
show hostname
       hostname
       uname -n
list all files under current directory containing 'fb.mid' in name
       du -a|grep fb.mid|cut -f2
list all with relative path
       du -a|cut -f2
list all with absolute path
       du -a `pwd`|cut -f2
get the top 20 recent modified files
       ls -lt| head -n 20
extract filename by column
       ls -l| awk '{print $9}'
create parent dir automatically
       mkdir -p /a/b/c
       cp --parents /a/b d
       (not -p)       
create soft link
       ln -s target linkname
easier browsing
       pushd .
       popd
'5 4 * * * updatedb' will exec updatedb every 4:05 am.
       su -;crontab -l
for restart after every reboot:
       @reboot nohup cmd >/dev/null
less frequent system monitoring
       top -d 30
online watching what others are doing
       watch w
send message to all logged on users as root
       wall
talking on console
       mesg y
       write root
being listed in /etc/host.conf on server side will speedup your login
check disk partitions
       fdisk -l /dev/sda
test disk read/write speed
       hdparm -tT /dev/sda1
after system crashes and DBUS fails to work
       eval `dbus-launch --sh-syntax --exit-with-session`
to reduce the file system overhead of updating access time
       mount -o relatime
match process
       pgrep 
       pkill 
       pidof
make a deb from source install (an alternative is dh_make)
       checkinstall -D make install
       checkinstall -D --strip=no --stripso=no make install
       (remove with dpkg -r `dpkg-deb -W <deb name>`)
For Firefox, it is
       checkinstall -D make install -f client.mk
show address mapping of a process
       pmap
various statistics
       iostat
       vmstat

No comments:

Post a Comment