根据端口杀进程
1 2
| lsof -i:8080 kill -9 42624
|
grep 筛选参数
1 2
| ps -aux | grep mysql ls -l bin | grep mysql
|
后台运行
1
| nohup command > myout.file 2>&1 &
|
查看shell bash
切换shell环境
alias
1
| alias runphp="php -t restful/ -S localhost:8000"
|
查看进程的程序路径
显示最后登录的终端
改变文件夹权限
1
| sudo chown -R $(whoami) testapp
|
查找包含”xxx”文件名的文件
1 2
| find ~ -iname "xxxx" find / -name 'scrapyd-deploy' //全局搜索文件
|
软链接 ln
1 2 3 4 5 6 7
| sudo ln -s /opt/node-v6.9.5-linux-x64/bin/cnpm /usr/local/bin/cnpm //生成软连接 ln -s /mnt/d/code . //正确的删除方式(删除软链接,但不删除实际数据) rm -rf ./test_chk_ln //错误的删除方式,(这样就会把原来test_chk下的内容删除) rm -rf ./test_chk_ln/
|
tar.gz压缩解压说明
1 2 3 4 5 6 7 8
| //解压: tar zxvf filename.tar.gz //压缩: tar zcvf filename.tar.gz dirname //z:通过gzip支持压缩或解压缩。还有其他的压缩或解压缩方式,比如j表示bzip2的方式。 //x:解压缩。c是压缩。 //v:在压缩或解压缩过程中显示正在处理的文件名 //f:f后面必须跟上要处理的文件名。
|
将文件夹压缩到zip中,并排除指定文件夹
1
| zip -r 12306.zip 12306/ -x 12306/venv/* -x 12306/ticket/* -x "cloud_backweb/download/wordfile/*"
|
给二进制赋值执行权限
获取指定文件夹的大小
查看当前目录下各文件大小
查找进程中包含“xxxx”的多个pid
1 2
| ps -ef|grep "xxxx"|grep -v grep|cut -c 9-15 ps -ef | grep "xxxx" | grep -v grep | awk '{print $2}'
|
查找包含“xxx”的进程并杀死
1 2
| ps -ef|grep "xxx"|grep -v grep|cut -c 9-15|xargs kill -9
|
apt-get 相关命令
1 2
| apt-get remove xxx //会删除软件包而保留软件的配置文件 apt-get purge xxx //会同时清除软件包和软件的配置文件
|
zsh
1 2 3
| export PATH=$HOME/bin:/usr/local/bin:$PATH:/home/htongtongx/.local/bin export GOBIN=/home/linuxbrew/.linuxbrew/bin/ export PATH=$PATH:$GOPATH/bin
|
在ubuntu14.04下python3.4升级3.6
when update python3.4 to python3.6 on ubuntu 14.04. The following solved me:
1
| wget https://bootstrap.pypa.io/ez_setup.py -O - | python3
|
linux配置文件加载顺序
1 2 3 4 5
| /etc/profile /etc/environment ~/.bash_profile ~/.bashrc /etc/bashrc
|
查看 history 最后 5 条命令:
1 2 3 4 5 6
| 10068 hexo new "history of linux" 10069 export HISTTIMEFORMAT='%F %T ' 10070 history 10071 history | more 10072 history | tail 5
|
执行 history 第 10072 条命令:
参考:
History(历史)命令用法 15 例
Linux history 命令小结
centos下安装nginx
1 2 3
| rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum install -y nginx /usr/sbin/nginx -s reload
|
查看进程并kill掉
1 2
| ps -ef | grep nginx kill -9 xxxx
|
centos下安装supervisor
1 2 3 4 5 6 7 8 9
| yum install epel-release yum install -y supervisor systemctl enable supervisord # 开机自启动 systemctl start supervisord # 启动supervisord服务 systemctl status supervisord # 查看supervisord服务状态 ps -ef|grep supervisord # 查看是否存在supervisord进程 supervisorctl status 查看进程状态 supervisorctl reload 重启supervisord supervisorctl start|stop|restart 启动关闭重启进程
|