bash技巧收集

**替换** ``` ^^ # gerp root /etc/passwd bash: gerp: 未找到命令... 相似命令是: 'grep' # ^er^re grep root /etc/passwd root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin # grep baash /etc/passwd # ^a grep bash /etc/passwd root:x:0:0:root:/root:/bin/bash ccic:x:1001:1001:CCIC:/home/ccic:/bin/bash mysql:x:2010:2010::/home/mysql:/bin/bash ``` **引用文件名** ``` $ mv books.pdf Chapter-18-!#:1 mv books.pdf Chapter-18-books.pdf $ cp books.pdf{,.bak} $ mv test{.bak,.sh} ``` **命令行创建并编辑文件** ``` cat >test 111 222 333 ``` **显示文本块** ``` # dmidecode | awk /Processor/,/Manuf/ Processor Information Socket Designation: CPU 0 Type: Central Processor Family: Other Manufacturer: Bochs Processor Information Socket Designation: CPU 1 Type: Central Processor Family: Other Manufacturer: Bochs ``` **web服务器** ``` $ python -m SimpleHTTPServer $ python3 -m http.server ``` **显示网络连接** ``` lsof -Pni ``` **比较本地与远程文件差异** ``` ssh linuxsvr cat /etc/passwd | diff /etc/passwd - ``` **生成N位随机密码** ``` openssl rand -base64 48 | cut -c1-N gpw () { openssl rand -base64 48 | cut -c1-${1}; } gpw 10 ``` **改密码** ``` echo "root:9rDsXRplZw" | sudo chpasswd ```
上一篇:Web大前端之Jquery


下一篇:Linux中Vim使用及用户管理(三)