man () {
/usr/bin/man $@ || (help $@ 2> /dev/null && help $@ | less)
}
有时候可能寻找某些命令的man而无果,这里将man包装成一个函数,首先调用man,不成功则调用help来查询帮助,当然不仅仅可以使用help,
还有比如whatis whereis apropos which等
将此函数放到.bashrc或者shell对应的rc配置文件中,然后重启shell或者source之
2让显示dd的进度
dd if=/dev/zero of=/tmp/foo&
watch -n 10 pkill -USR1 ^dd$
dd接收到SIGUSR1信号时会输出当前的读写进度,这样子加上watch就可以动态查看dd的进度了
3 安全使用rm,避免一个空格引起的血案^_^
#safe remove, mv the files to .Trash with unique name
#and log the acction
function rm()
{
trash="$HOME/.Trash"
log="/var/log/trash.log"
stamp=`date "+%Y-%m-%d %H:%M:%S"` #current time
while [ -f "$1" ]; do
#remove the possible ending /
file=`echo $1 |sed 's#\/$##' `
pure_filename=`echo $file |awk -F / '{print $NF}' |sed -e "s#^\.##" `
if [ `echo $pure_filename | grep "\." ` ]; then
new_file=` echo $pure_filename |sed -e "s/\([^.]*$\)/$RANDOM.\1/" `
else
new_file="$pure_filename.$RANDOM"
fi
trash_file="$trash/$new_file"
mv "$file" "$trash_file"
if [ -w $log ]; then
echo -e "[$stamp]\t$file\t=>\t[$trash_file]" |tee -a $log
else
echo -e "[$stamp]\t$file\t=>\t[$trash_file]"
fi
shift #increment the loop
done
}
4 在Linux上关闭或者重启Window
net rpc shutdown -I ipAddressOfWindowsPC -U username%password //关闭
net rpc shutdown -r : reboot the Windows machine //重启
net rpc abortshutdown : abort shutdown of the Windows machine //放弃关闭
需要安装samba-common包,并且username必须为administrator
几个获取有趣和高效CLI Tips的途径
1 多多围观Ubuntu中文社区,在每个帖子下边总有可爱的tips
2 commandlinefu.com是个非常好的,汇集了n多好点子的网站
3 多有心留意大家日常交流来获取
资料按顺序分别引自:here,here,here