watch "ls -larth"
sudo fuser -k 8000/tcp
ulimit -Sv 1000 # 1000 KBs = 1 MB ulimit -Sv unlimited # Remove limit
rename 's/\.bak$/.txt/' *.bak
readlink -f file.txt
tar tf file.tgz tar xf file.tgz filename
ls -lS
mtr google.com
find . -size 20c # By file size (20 bytes) find . -name "*.gz" -delete # Delete files find . -exec echo {} \; # One file by line ./file1 ./file2 ./file3 find . -exec echo {} \+ # All in the same line ./file1 ./file2 ./file3
yes yes hello
w
ls | nl
\t
這樣的字符)grep -P "\t"
tac file
檢測權限錯誤是頗有用的,例如在配置web服務器時。javascript
namei -l /path/to/file.txt
while inotifywait -e close_write document.tex do make done
cat file.txt | xclip -selection clipboard
detex file.tex | diction -bs
你可能須要安裝如下內容:sudo apt-get install diction texlive-extra-utils
。css
/usr/bin/time -v ls
cat file.txt | sort -R
cat file.txt | sort -R | head # Pick a random sambple # Even better (suggested by xearl in Hacker news): shuf file.txt
若是程序不須要任何交互:java
nohup ./script.sh &
若是你須要手動輸入一些內容,而後離開:web
./script.sh
<Type any input you want>
<Ctrl-Z> # send process to sleep jobs -l # find out the job id disown -h jobid # disown job bg # continue running in the background
固然,也能夠使用screen
或tmux
來完成此目的。正則表達式
timeout 10s ./script.sh
# Restart every 30 minutes while true; do timeout 30m ./script.sh; done
comm file1 file2
打印這三列:shell
file1
獨有。file2
獨有。file1
和行file2
中都有。使用選項-1
、-2
、-3
,能夠刪除這些列。ruby
split -l LINES -d file.txt output_prefix
若是一個程序消耗了太多的內存,交換分區就會被剩餘的內存填滿,當你回到正常的時候,一切都是緩慢的。只需從新啓動交換分區來修復它:bash
sudo swapoff -a sudo swapon -a
sudo fsck.ext4 -f -y /dev/sda1
sudo fsck.ext4 -v /dev/sda1
sudo mke2fs -n /dev/sda1
sudo e2fsck -n <first block number of previous list> /dev/sda1
fallocate -l 1G test.img
與join
,shuffle
,select
等命令相比,pdftk
是個更好用的命令:服務器
pdftk *.pdf cat output all.pdf # Join PDFs together pdftk A=in.pdf cat A5 output out.pdf # Extract page from PDF
還能夠使用cpdf
操做內容:dom
cpdf -draft in.pdf -o out.pdf # Remove images cpdf -blacktext in.pdf -o out.pdf # Convert all text to black color
# Write random data, encode it in base64 and monitor how fast it # is being sent to /dev/null cat /dev/urandom | base64 | pv -lbri2 > /dev/null # pv options: # -l, lines # -b, total counter # -r, show rate # -i2, refresh every 2 seconds
apt-file update apt-file search dir/file.h