不管你是在开发过程当中使用的是某个流行的Linux发行版,还是远程登录在管理着众多云平台的Linux机器,对大量工具熟练的掌握和使用都可以提升效率、更少出错、让你腾出更多的时间干别的事情。本指南就是列出提升系统管理/开发效率的各种手段,本文档会随着时间更新。
1.无意中按下什么按键以后,终端好像死掉了,在键盘上敲打什么都没有反应,如果在执行vi的时候遇到这种情况就更头疼,ctrl+c都无法让你退出
你可能不小心按到了ctrl+s,它是用来发送stop信号,告诉Linux临时停止屏幕显示,你可以按下ctrl+q发送start信号重新启动屏幕显示,总之遇到奇怪的现象试试ctrl+q,几乎没什么副作用。
2.显示系统相关信息:
$ hostnamectl
$ uname -a
3.快速回退上一级
alias ..2='cd ../../'
alias ..3='cd ../../../'
alias ..4='cd ../../../../'
alias ..5='cd ../../../../../'
alias ..6='cd ../../../../../../'
4.查看某个进程打开的文件描述符的详细内容:
sudo lsof -p $PID
5.跟踪网络系统调用:
strace -f -e trace=network -s 10000 dig sina.com @8.8.8.8
6.计算摘要信息:
计算字符串md5:
echo会自动添加一个换行符,为了防止添加换行符,需要加-n参数
echo -n "Man is distinguished, not only by his reason" | md5sum
echo -n "Man is distinguished, not only by his reason" | openssl dgst -md5
同样的计算sha1:
echo -n "Man is distinguished, not only by his reason" | sha1sum
echo -n "Man is distinguished, not only by his reason" | openssl dgst -sha1
计算文件摘要:(注意文件在用某些编辑器打开以后会在末尾添加一个换行符,可以通过xxd file来检查一下):
md5sum file
openssl dgst -md5 file
sha1sum file
openssl dgst -sha1 file
其他类型的摘要算法同理,openssl list-message-digest-commands可查看openssl支持哪些摘要算法。
7.Base64编解码:
base64一串字符串:
# echo会自动添加一个换行符,为了防止添加换行符,需要加-n参数
echo -n "Man is distinguished, not only by his reason" | base64
echo -n "Man is distinguished, not only by his reason" | openssl enc -base64
echo -n "Man is distinguished, not only by his reason" | openssl base64
base64一个文件:
base64 file
openssl enc -base64 -in file
base64解码:
echo "ZW5jb2RlIG1lCg==" | openssl enc -base64 -d
echo "ZW5jb2RlIG1lCg==" | base64 -d
8.摘要和Base64混合使用:
对一个字符串计算其sha-1,然后再对结果进行base64编码:
echo "Man is distinguished, not only by his reason" | sha1sum | xxd -r -p | base64
echo "Man is distinguished, not only by his reason" | openssl dgst -binary -sha1 | openssl base64
对一个文件内容计算其sha-1,然后再对结果进行base64编码:
sha1sum filename | xxd -r -p | base64
openssl dgst -binary -sha1 testfile | openssl base64
注意上面如果用 sha1sum filename | base64是不会得到正确的结果的
TO BE CONTINUED...
有时间再持续更新