Linux运维常用命令
来源:互联网 发布:奇葩男士网络剧 编辑:程序博客网 时间:2024/06/05 09:18
参考:
https://wiki.tankywoo.com/linux/linux_tips.html
https://wiki.tankywoo.com/linux/linux_network_config.html
w
display who is logged in and what they are doing
The w utility prints a summary of the current activity on the system, including what each user is doing. The first line dis-
plays the current time of day, how long the system has been running, the number of users logged into the system, and the load
averages. The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes.
The fields output are the user’s login name, the name of the terminal the user is on, the host from which the user is logged in,
the time the user logged on, the time since the user last typed anything, and the name and arguments of the current process.
top/htop
查看进程和CPU状态
It is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines
其他
man ps
可以看到各个进程状态的解释,查看进程状态是否有D
,表示在等待IO。
while true; do date; ps auxf | awk '{if($8=="S") print $0;}'; sleep 1; done
或者
for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 1; done
其实工具都只是表层, 最底层的还是读取/proc下的文件, 具体在每个工具的man手册都有介绍。
还有一个比较强大的工具dstat, 集合了vmstat, iostat, ifstat等工具的功能, 并且输出是颜色高亮
CPU使用最高的三个进程(Linux)
ps -auxf | sort -nr -k 3 | head -3
查看本机最常用的10条命令
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
统计当前目录下(包括子目录)以.py结尾文件的个数及总代码行数
文件个数
find . -name "*.py" | wc -l
单个文件代码行数及总行数
find . -name "*.py" | xargs wc -l
输出错误重定向(不想看到错误输出到屏幕)
ls 1>/dev/null 2>/dev/nullls >/dev/null 2>&1
显示没个远程IP与本地的连接数
netstat -antu | awk '$5 ~ /[0-9]:/{split($5, a, ":"); ips[a[1]]++} END {for (ip in ips) print ips[ip], ip | "sort -k1 -nr"}'
替换上条命令的关键字并执行
# 将上一条命令的pint换成traceroute^ping^traceroute^
搜索最近一条符合关键字的命令
比如上面执行过命令是ping wutianqi.com, 想再执行, 可以
# p是关键字, 也可以 pi, pin, ping都行!p
网络配置相关
直接用ifconfig配置
设置网卡eth0的IP地址和子网掩码sudo ifconfig eth0 192.168.2.106 netmask 255.255.255.0设置网关sudo route add default gw 192.168.2.254配置DNSsudo vim /etc/resolv.conf
ubuntu 网络配置文件
sudo vim /etc/network/interfacesDHCP连接auto eth0iface eth0 inet dhcp手动配置静态ipauto eth0iface eth0 inet staticaddress 192.169.2.106gateway 192.168.2.254netmask 255.255.255.0#network ?.?.?.?#broadcast ?.?.?.?# dns设置# 我印象中重启后resolv.conf的内容会删除# 所以DNS服务器的配置也是在/etc/network/interfaces下dns-nameservers 8.8.8.8dns-search xxx.xxx.xxx...# 添加一条静态路由up route add -net 192.0.0.0/8 gw 192.0.0.1 dev eth0
- linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- Linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- linux运维常用命令
- linux 运维常用命令
- linux运维常用命令
- linux运维常用命令
- Linux运维常用命令
- LINUX运维常用命令
- LINUX运维常用命令
- Linux运维常用命令
- 222
- js获取数组元素个数和对象成员数
- 必须收藏的 | SEO工具使用方法
- 学习笔记1:大数据开发基础上
- SparkRDD的概念和定义
- Linux运维常用命令
- STL源码解析Array
- thinphp IS_POST对网站安全有帮助吗
- Django自动添加当前日期时间到数据库
- RDD学习笔记
- Debian8开源显卡驱动安装
- 51Nod-1042-数字0~9的数量
- C语言程序设计谭浩强版 八
- [leetcode] 238. Product of Array Except Self