--- title: Linux常用命令 date: 2018-03-26 21:14:36 description: "记录一些Linux服务器常用的命令" categories: [技术总结] tags: [Linux, Shell, CentOS, Ubuntu] --- ## Linux 常用命令 ### 存储相关 ```bash # 查看系统中文件的使用情况 df -h # 查看当前目录大小 du -sh # 查看当前目录下磁盘占用情况,递归层数为1,按大小排序 du -h --time --max-depth=1 | sort -hr # 查找所有带wine的文件和文件夹 find / -name *wine* # 查看文件开头50行的内容 head -n 50 filePath # 查看文件结尾50行的内容 tail -n 50 filePath ``` ### 进程相关 ```bash # 删除进程 kill -s 9 PID # 查看端口被占用情况 netstat -tunlp|grep 22 # 查看java进程 ps -ef|grep java # 进入进程所在目录 cd /proc/PID # 查看进程的内存映像信息 pmap -d 1 # 查看内存占用最多的10个进程 ps -aux | sort -k4nr | head -10 ``` ### 系统参数 ```bash # 查看系统内核版本号及系统名称 uname -a # CentOS查看是32位还是64位 getconf LONG_BIT # 看cpu参数 cat /proc/cpuinfo lscpu # 查看网速 iftop # CentOS修改主机名 hostnamectl set-hostname ``` ### curl ```bash # 获取网页信息 curl www.baidu.com # curl测试接口时间 curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" http://www.baidu.com ```