linux面试题
1, 常用命令
- ls/ll:列出文件list 
- cd:切换目录change directory 
- cp:复制copy 
- mv:移动move 
- rm:移除,删除remove 
- mkdir:创建文件夹make directory 
- rmdir:移除,删除文件夹remove directory 
- chown:更改所有者change owner 
- chmod:更改文件的权限模式change mode 
- find:查找 
- |:管道 
- grep:按行查找并匹配 
- tar:打包,压缩,解压 
- cat:打印文件内容 
- ps:查看进程process select 
- kill:杀死进程 
- passwd:修改密码password 
- pwd:显示工作目录print work directory 
- tee:显示并保存 
- reboot:重启 
- lsof/netstat: 查看端口 是否被占用 
 lsof -i:22
 netstat -tunlp|grep 22
- tail: 查看日志 
 实时查看:
 tail -f 日志名
 查看后200行日志内容
 tail -f -n 200 demo.log
- top: 查看cpu占用率 
- netstat命令 – 显示网络状态 
2, uwsgi和nginx
详解
uwsgi: web服务器(应用服务器),用于连接Web服务器和Web应用框架
uwsgi启动:
uwsgi –ini uwsgi8001.ini
uwsgi重启:
uwsgi –reload uwsgi8001.pid
uwsgi停止:
uwsgi –stop uwsgi8001.pid
nginx: 是一个高性能、轻量级的http和反向代理服务器
3, pm2 . nohup
pm2: 进程管理工具
pm2 ls
pm2 start
pm2 stop
pm2 log
pm2 start Tasker/schedule_task.py -x –interpreter python3 -o ./logs/node_task.log -e ./logs/node_task_error.log
nohup: 后台运行项目
保存日志:
nohup python3 -u Main.py > nohup.log &
不保存日志:
nohup python3.6 /opt/moss_robot/lib/dispatch_v5.3.2/robot_wait.py >/dev/null 2>&1 &
4, docker:
安装:apt-get/yum install docekr
查看服务状态:systemctl status docker
启动服务:systemctl start docker
拉取镜像:docker pull centos/ubuntu
进入镜像:docker run -it ubuntu /bin/bash
退出:exit
查看所有容器:docker ps -a
启动容器:docker start id
进入容器:docker exec -it id bash
重启:docker restart id
5,linux下如何设置,查看和注销环境变量
“” 设置环境变量
export LD_LIBRARY_PATH=/the/path/you/want/set
“” 查看设置
echo $LD_LIBRARY_PATH
“” 清除环境变量
unset LD_LIBRARY_PATH
6, 查看网卡使用的网络带宽情况
yum/apt install libpcap nethogs -y
#使用方法
nethogs
 # 网卡名称 DEV
查看指定网卡占用带宽的进程
nethogs 网卡名称