Ubuntu下的一些命令
nmap
- 扫描所有的局域网IP
1
| nmap -v -sP 10.1.18.0/24
|
display service(显示服务)**
1 2 3 4
| sudo service lightdm stop
sudo service lightdm start
|
use ‘curl’ send a post request
1 2 3 4 5
| curl -d "opr=pwdLogin&userName=171050050&pwd=0050131579&rememberPwd=1" "http://2.2.2.2/ac_portal/login.php"
cat /etc/resolv.conf
|
获取文件中的部分
获取user-item.lst文件的5-10行,复制到test文件中
1
| sed -n '5,10p' user-item.lst > test
|
获取user-item.lst文件的前100行,复制到test文件中
1
| head -100 user-item.lst > test
|
获取user-item.lst文件的后100行,复制到test文件中
1
| tail -20 user-item.lst > test
|
Configuring remote access with systemd unit file
open an override file for docker.service in a text editor.
1
| $ sudo systemctl edit docker.service
|
Add or modify the following lines, substituting your own values.
1 2 3
| [Service] ExecStart= ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375
|
Save the file.
Reload the systemctl configuration.
1
| $ sudo systemctl daemon-reload
|
Restart Docker.
1
| $ sudo systemctl restart docker.service
|
systemd 设置开机自动启动
1 2
| sudo systemctl enable docker sudo systemctl disable docker
|
watch间隔1秒刷新
1 2
| watch -n 1 -d nvidia-smi watch -n 1 -d 'ps aux | grep mysql'
|
添加和删除变量
1 2 3 4
| export http_proxy=127.0.0.1:1080
unset http_proxy
|
更换编译器
1 2 3
| sudo apt install gcc-6 g++-6 sudo ln -s /usr/bin/gcc-6 /usr/local/bin/gcc sudo ln -s /usr/bin/g++-6 /usr/local/bin/g++
|
查看和杀死被锁进程
1 2
| sudo lsof /var/lib/dpkg/lock-frontend sudo kill -9 10963
|
创建文件
查看端口
1
| sudo netstat -npltu | grep 21
|
解压zip
- -O 以指定的字符集显示和解压文件
- -d 到指定的目录
1
| unzip -O CP936 day01.zip -d ./day01/
|
解压rar
查看应用的进程树
1
| pstree -ap|grep gunicorn
|
设置快捷方式
可以理解为从 sites-available/ 目录下发送了一个配置文件的快捷方式到 sites-enabled/ 目录。
1
| sudo ln -s /etc/nginx/sites-available/demo.zmrenwu.com /etc/nginx/sites-enabled/demo.zmrenwu.com
|
开启gunicom
1
| gunicorn --bind unix:/tmp/myweb.socket VItest.wsgi:application
|
Git 的操作
重置想要上传到github的文件
获取当前git项目的状态
添加所有的未添加的文件到github上
commit, 并添加本次commit的说明
上传到原始的master分支
1
| git push -u origin master
|
创建一个叫做”feature_x”的分支,并切换过去:
1
| git checkout -b feature_x
|
切换回主分支:
把新建的分支删掉:
要更新你的本地仓库至最新改动:
要合并其他分支到你的当前分支(例如 master)
在合并改动之前,你可以使用如下命令预览差异
1
| git diff <source_branch> <target_branch>
|
删除软件(如:ngin)
- –purge 包括配置文件
1
| sudo apt-get --purge remove nginx
|
罗列出相关的软件(比如:与nginx相关的软件)
- –purge 包括配置文件
1
| dpkg --get-selections|grep nginx
|
kill (比如:nginx进程)
1
| sudo kill -9 7875 7876 7877 7879
|
全局查找(比如:nginx相关的文件)
1
| sudo find / -name nginx*
|
将 alias lg =’lazygit’ 写入.zshrc中,可以通过使用lg代替lazygit
1
| echo “alias lg ='lazygit'”>>〜/.zshrc
|