dpkg -c: list contents of deb package,dpkg -x: extract files from package,dpkg -L: list files installed from a package-namedpkg -s filename: search for a filename from installed packagesapt-file search filename: search which package contains a specific file/pathapt-get -o Dpkg::Options::="--force-confmiss" install --reinstall <package-name>
zip -r dir.zip dir [-x dir/node_modules\* dir/.git\*]unzip dir.ziptar czvf dir.tar.gz dir [--exclude node_modules --exclude .git]tar xzvf dit.tar.gz -C dirtar: omit-vto see error info, filename should follow-fdirectlylocate: find files by name,updatedbwhereis: locate the binary, source, and manual page files for a commandfind ./ \( -path ./node_modules -o -path ./.git -o -path ./.idea \) -a -prune -o -print | xargs wc -l | sort -n: -a means and, -o means orfind . -mtime +30 | xargs rm -rf: delete files older than 30 daysls -trconvmv -r -f cp936 -t utf8 --notest --nosmart *iconv -f UTF-16LE -t UTF-8 utf-16leEncodiedFile > outputrsync -lptzr --delete src_dir/ dst_dir: -l sysmlinks, -p perms, -t times, -z compress
sort -k3 -r -n -h: -k3 => third column, -r reverse, -n numeric sort, -h human numeric sorttr: translate or delete characterssed -i 's/ugly/beautiful/g' filename: edit file in place to replace ugly with beautifulstrings: pint the strings of printable characters in filesexpand: convert tabs to spacestee: read from standard input and write to standard output and filesgrep -r "word" /path/to/dir/*.c,find . -type f -exec grep -l "word" {} +,find /path/to/dir -type f -print0 | xargs grep -l "foo": recursively search all files for a string,find -print0can deal with spaces in file namesegrep -v 'exclude1|exclude2'find -L /etc/ssl/certs -type l -delete
fdisk -l: List the partition tables for the specified devices. If no devices are given, those mentioned in /proc/partitions (if that exsts) are useddf -h: report file system disk space usagedu -sh target_dir: estimate file space usagedu --max-depth 1 -h | sort -rn | head -n 5: top 5 big dir/filemount -t cifs -o username=USERNAME,password=PASSWORD //HOST/SHARE_NAME /mnt/MOUNT_POINT: mount smb share folderhdparm -t /dev/sda6: perform timings of device reads for benchmark and comparisonblockdev --report: print a report for the specified deviceblockdev --getra /dev/sda,blockdev --setra /dev/sda: get/set readahead, in sectorsblockdev --getbsz /dev/sda,blockdev --setbsz /dev/sda: get/set block size, in byteslsblk -o NAME,PHY-SeC,cat /sys/block/sda/queue/physical_block_size: get block device physical sector size
resolvconf -uroute: show / manipulate the IP routing tableroute add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.225.173: add static routearp: manipulate the system ARP cachearp -D test6; arp -d test6; arp -s test6 MAC_addrdig +short HOSTNAME
ip: show/manipulate routing, devices, policy routing and tunnelscurl ifconfig.me: figure out external ipip -4 route get 8.8.8.8: figure out which interface is used to comunicate with certain hosttraceroute -I HOSTnslookup: query Internet name servers interactivelydig: DNS lookup utilitymtr: a network diagnostic toolnetstat -s | grep -E '.*(queue|timeout).*'tcpdump -A -s 0 -n -i lo host localhost and port 7070ssh user@remotehost tcpdump -s 0 -n -U -w - -i any host ? | wireshark -k -i -ss -m src *cat /proc/net/sockstat:TCP mem about equal ss -m src *nmap -sP 192.168.1.*
iptables -t nat -A OUTPUT -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2iptables -t nat -D OUTPUT -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
service SCRIPT COMMAND: run a System V init script(/etc/init.d/) or an upstart job(/etc/init) (take precedence).All scripts should supportat least the start and stop command.upstart jobs: restart => stop => start, init scriptsupstart jobs: initctl list, init scriptsupdate-rc.d SCRIPT enable/disable,chkconfig: enable or disable system services
ssh -NfD [local_addr]:7070: forward localhost's 7070 port to remotehost, dynamicallyssh -NfL [local_addr]:7070:remote_addr:22 user@remotehost: forward localhost's 7070 port to remotehost's 22 port, default local_addr is loopbackssh -NfR [remote_addr:]7070:local_addr:22 user@remotehost: forward remotehost's 7070 port to localhost's 22 port, default remote_addr is loopback, if want it to be the others, turnGatewayPortson in/etc/ssh/ssd_config, thenreload sshssh-keygen -R hostname: remove all keys belong to hostname from a known_hosts filessh-copy-id [-i [identity_file]] username@remotehost: install your public key in a remote machine's authorized_keys
-
git commit --amend --author "name <email>": modify last commit -
git rebase -i master~3: interactive rebase -
git log:-p --color | --graph | --pretty=oneline -
git diff HEAD: diff staged and unstaged changed files -
git submodule,git add path/to/submodule, `git rm --cached path/to/submodule -
git clone -b branch_name -
git checkout -b branch_nae remote/branch_name,git checkout --trach remote/branch_name -
git remote prune origin,git remote update -
rewrite commit histroy
git filter-branch --commit-filter ' if [ "$GIT_COMMITTER_NAME" = "wrong_name" ]; then GIT_COMMITTER_NAME="inetfuture(Aaron Wang)"; GIT_AUTHOR_NAME="inetfuture(Aaron Wang)"; GIT_COMMITTER_EMAIL="inetfuture@gmail.com"; GIT_AUTHOR_EMAIL="inetfuture@gmail.com"; git commit-tree "$@"; else git commit-tree "$@"; fi' HEAD
set tabstop=4,set nospell2yy, pG or g: go to the end/start of the fileCtrl + g: show file information/ or ?: forward or backward search,n or N: next or previous10j: 10 lines forward,10k: 10 lines backwardo or O: insert a new line below or above this line
msmtp -S --host serverhost: check information about SMTP servernslookup -query=mx redhat.comtelnet POP3-server 110: commands: user, pass, stat, list, retr, dele(take effect after quit), quit
- openssl x509 -text -noout -in PEM_FILE_PATH
php --ini: show configuration file namesphp --interactivephp -m | grep ext_name: check extensionphp-config: get information about PHP configuration and compile optionspear config-set http_proxy http
rfkill: tool for enabling and disabling wireless deviceslshw -C networklspci / lsusb: list all PCI / usb devicesalsamixer: soundcard mixer for ALSA soundcard driver, with ncurses interface
iostat -xm 2iotopps aux --sort -rss
lsmod: show the status of modules in the linux kernelln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime: set time zone,date -Ruseradd testuser -m -s /bin/bashusermod username -Ga sudo,groups usernamelastlog: reports the most recent login of all users or of a given userhistory | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | headgnome-terminal --geometry 110x30+1000+1000 --hide-menubarupdate-alternatives --config editorx11vnc --create --forever