('#' prompt denote root user, '$' prompt denote non-root user)
$ ls -al
$ ls -alt
$ ps aux
$ top
or
$ free -m
$ w
$ cal
or
$ cal 2013
$ ps -p $$
or
$ echo $SHELL
$ id
# pdbedit -L -v
$ PATH=$PATH:/usr/lib ; export PATH
$ more /etc/inittab
$ less /etc/inittab
$ cat /etc/inittab
$ du -ch | grep total
$ du -sh *
$ set -x
$ set -o vi
$ export https_proxy="https://xx.xx.xx.xx:yyyy/" (bash)
$ setenv https_proxy "https://xx.xx.xx.xx:yyyy/" (csh, tcsh)
$ unset https_proxy
$ env -u https_proxy
$ env -i bash
$ \ls -alF
$ Ctrl + Alt + E
$ CTRL+r
(reverse-i-search)`':
After you have typed what you are looking for, use the CTRL+r key combination to scroll backward through the history.
Ctrl + a
Ctrl + e
Alt + f
Alt + b
Ctrl + w
Esc + k
Ctrl + l
LS_COLORS='rs=0:di=01;33:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS
Legend
di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has 'x' set in permissions).
Effects
00 Default colour
01 Bold
04 Underlined
05 Flashing text
07 Reversetd
08 Concealed
Colours
30 Black
31 Red
32 Green
33 Orange
34 Blue
35 Purple
36 Cyan
37 Grey
Backgrounds
40 Black background
41 Red background
42 Green background
43 Orange background
44 Blue background
45 Purple background
46 Cyan background
47 Grey background
Extra colours
90 Dark grey
91 Light red
92 Light green
93 Yellow
94 Light blue
95 Light purple
96 Turquoise
97 White
100 Dark grey background
101 Light red background
102 Light green background
103 Yellow background
104 Light blue background
105 Light purple background
106 Turquoise background
107 White background
di=5;31;42
mean flashing red text with a green background
# adduser username
# passwd username
# userdel -r username
$ addgroup cvsgrp
$ adduser username cvsgrp
or
$ usermod -G cvsgrp username
# smbpasswd -a keanheong
# vim /var/lib/samba/private/passdb.tdb
vim /usr/local/etc/smb.conf (FreeBSD)
vim /etc/samba/smb.conf (CentOS)
[global]
unix extensions = No
wide links = Yes
ln -s / rootfs
# service smb restart
$ sudo /sbin/service smb restart
# pdbedit -L -v
Ctrl+Z to suspend it and fg 1 or fg 2 to bring it on the
foreground.
fc
nslookup www.google.com
date +%j
date -d "2011/07/13" +%j
date +%Y%m%d
date -d "-2 days"
date -d "2 days"
date +%Z
!ls
!vim
sudo !!
cmd that start with space did not goes into history
touch file-$(date -I)
$ find . -name "*jfb*" -print
$ find . -name "*jfb*" -type f
$ find . -type f -size +100M
$ find . -name "*jfb*" -type d
$ find . ! -perm /g+w
$ find . -size 0
$ find . ! -perm /g+w | xargs -I{} chmod g+w {}
$ find . ! -group mail
$ find . ! -group mail | xargs -I{} chgrp mail {}
$ find . -exec grep -q "libstd*" '{}' \; -print
$ grep -Hrns "libstd*" .
$ grep -Hrnws "libstd" .
$ grep -Hrns --include=\*.{c,h} "libstd*" .
or
$ grep -Hrns --include="*.{c,h}" "libstd*" .
$ grep -Hrns --exclude=\*.{a,o,out,lib,swp} "libstd*" .
or
$ grep -Hrns --exclude="*.{a,o,out,lib,swp}" "libstd*" .
$ grep -Hrns --exclude-dir="\.svn" "libstd*" .
add this line to ~/.bashrc or ~/.bash profile
export GREP_OPTIONS='--exclude-dir=.svn --color=auto --line-number --with-filename --recursive'
$ grep -Hrns "libstd*" `find . -name "*.c"`
or
$ find . -name "*.h" -exec grep -Hrns "libstd" {} \;
$ grep -Hrn -v "libstd*" .
$ find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
$ history | grep make
$ !230
$ !!
$ script
$ ...
$ exit
$ jobs
$ kill %25
$ mount | column -t
or
$ cat /etc/passwd | column -t -s:
$ getconf LONG_BIT
$ tar zcf libstdc.tar libstdc*
$ tar zcf archive.tar -T filelist.txt
or
$ tar zcf archive.tar `cat filelist.txt`
or
$ cat filelist.txt | xargs tar zcf archive.tar
$ tar zcf libstdc.tar --exclude './data/*
$ tar zcf libstdc.tar --exclude './data
$ tar ztvf archive.tar
$ less archive.tar
or
$ vim archive.tar
$ tar zcf ~/temp/libstdc.tar libstdc*
$ tar zxf libstdc.tar.gz
or
$ tar zxf libstdc.tgz
$ tar jxf libstdc.bz2
$ tar xvf libstdc.zip
$ tar zxf libstdc.tar -C ~/test/lib/
$ gpg -c libstdc.zip
$ gpg libstdc.zip.gpg
$ split -b2m libstdc.zip.gpg libstdc_
$ cat libstdc_?? > libstdc.zip.gpg
# dd if=/dev/sr0 of=/home/shared/SUSE.iso
# mkdir /mnt/suse_iso
# mount -o loop /home/shared/SUSE.iso /mnt/suse_iso
# ls -al /mnt/suse_iso
mount option SourceDevice TargetMountPoint
# mount -t ntfs /dev/hda /mnt/Data0
mount option SourceDevice TargetMountPoint
# fdisk -l
# fdisk /dev/sdc
m print help
a add partition
d delete partition
w write to disk and save
q quit without save
# mkfs -t ext2 /dev/sdc1
scp SourceFile user@host:directory/TargetFile
# scp libstdc.tar root@10.1.2.124:/lib/
scp user@host:directory/SourceFile TargetFile
# scp root@10.1.2.124:/lib/libstdc.tar /home/angkh/
sync option Source Target
# mount /dev/sdc1 /mnt/usbdrive
# rsync -ruv /home/shared/ /mnt/usbdrive/home/shared/
$ sudo less /etc/passwd
$ sudo less /etc/group
$ sudo vim /etc/ssh/sshd_config
AllowUsers bob@133.183.200.121 steve@133.183.200.132
Generate keypair at local PC
$ ssh-keygen -t rsa
This will generate
1) $HOME/.ssh/id_rsa Private Key
2) $HOME/.ssh/id_rsa.pub Public Key
Install (by append) your public key in the remote machine's authorized_keys:
cat ~/.ssh/id_rsa.pub | ssh username@xx.xx.xx.xx "cat >> ~/.ssh/authorized_keys"
$ make > log.txt 2>&1
$ make 2>&1 | tee log.txt
$ make >& log.txt
# vim /etc/network/interfaces
iface eth0 inet static
address 10.1.2.124
netmask 255.255.255.0
# dhclient eth1
# vim /etc/network/interfaces
iface eth1 inet dhcp
# iwconfig eth1 essid "Jones"
# iwconfig eth1 key xxxx-xxxx-xx
# vim /etc/network/interfaces
auto eth1
iface eth1 inet dhcp
pre-up iwconfig eth1 essid "Jones"
pre-up iwconfig eth1 key xxxx-xxxx-xx
dhclient eth1
# chown -R angkh:angkh decodeRGB/
# vim ~/.bashrc
export PS1="[\u@\h \w]\$ "
# vim ~/.bashrc
alias l="ls -alF --color"
$ source ~/.bashrc
$ sudo update-alternatives --config editor
# visudo
keanheong ALL=(ALL) NOPASSWD:ALL
CentOS
# vim /etc/sysconfig/network
HOSTNAME=CentOS_192_168_1_12.localdomain
FreeBSD
# vim /etc/rc.conf
hostname="FreeBSD_192_168_1_12"
# blkid /dev/sda1
/dev/sda1: LABEL="/boot" UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="ext3"
# vim /etc/fstab
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /boot ext3 defaults 1 2
# dd if=/dev/zero of=/dev/sdb bs=512 count=1
$ sudo apt-cache linux-kernel
$ sudo apt-get install build-essential
$ sudo yum groupinstall Development
$ sudo apt-get install linux-kernel-devel
$ chkconfig smbd
$ chkconfig sshd
$ chkconfig --list | grep 3:on
$ dd if=/dev/zero ibs=1k count=131072 | tr "\000" "\377" > 128M.rom
or
$ tr "\000" "\377" < /dev/zero | dd ibs=1k count=131072 of=128M.rom
131072+0 records in
262144+0 records out
134217728 bytes transferred in 3.705787 secs (36218415 bytes/sec)
$ hexdump -C 128M.rom
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
07fffff0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
08000000
$ dd if=original.rom of=128M.rom conv=notrunc
$ hexdump -C 128M.rom
00000000 00 09 00 00 00 00 00 00 60 00 88 e7 60 08 c0 0f |........`...`...|
00000010 15 70 00 5f 60 00 8b 77 60 08 c0 0f 15 70 00 5f |.p._`..w`....p._|
00000020 60 00 a4 87 60 08 c0 0f 15 70 00 5f 60 00 aa 17 |`...`....p._`...|
00000030 60 08 c0 0f 15 70 00 5f 60 04 8b 27 60 08 c0 0f |`....p._`..'`...|
00000040 15 70 00 5f 60 06 bc b7 60 08 c0 0f 15 70 00 5f |.p._`...`....p._|
*
07fffff0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
08000000
hexdump -v -e '7/1 "%5_ad:%-5_c" "\n"' test.txt
hexdump -v -e '8/2 "%4x," "\n"' test.bin > test.csv
hexdump -v -e '8/2 "%i," "\n"' test.bin > test.csv
hexdump -v -e '16/2 "%4u," "\n"' test.raw > test.csv
/1 "%03x"
2/1 " %03d"
/0 "\n"
#!/bin/bash
for files in $(ls)
do
echo $files
echo ${files%.*}
hexdump -v -e '16/2 "%4x," "\n"' $files > ${files%.*}.csv
done
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias gb='git branch'
alias gc='git checkout'
alias gd='git diff'
alias glp='git log --pretty=format:"%h | %ci | %an | %s"'
alias gl='git log -20'
alias gpn='git pull --no-commit'
alias gs='git status'
alias gsu='git status -uno'
alias cd1="cd .."
alias cd2="cd ../.."
alias cd3="cd ../../.."
alias cd4="cd ../../../.."
alias cd5="cd ../../../../.."