Linux操作系统实用技巧精彩汇集
http://tech.ddvip.com 2007年08月31日 社区交流
内容摘要:因为用Linux的时间越来越长,所需要做的事也越来越多,效率成了我必需突破的瓶颈。在此总结一下这段时间用过的一些好的Linux技巧。以后时常补充这样自己要用的时候就很方便了。
lsof -g gid 显示归属 gid 的进程情况
lsof +d /usr/local/ 显示目录下被进程开启的文件
lsof +D /usr/local/ 同上,但是会搜索目录下的目录,时间较长
lsof -d 4 显示使用 fd 为4 的进程
lsof -i [i] 用以显示符合条件的进程情况
语法: lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 --> IPv4 or IPv6
protocol --> TCP or UDP
hostname --> Internet host name
hostaddr --> IPv4 位置
service --> /etc/service中的 service name (可以不止一个)
port --> 端口号(可以不止一个)
例子: TCP:25 - TCP and port 25
@1.2.3.4 - Internet IPv4 host address 1.2.3.4
tcp@ohaha.ks.edu.tw:ftp - TCP protocol host:ohaha.ks.edu.tw service name:ftp
lsof -n 不将 IP转换为 hostname,预设是不加上-n参数
例子: lsof -i tcp@ohaha.ks.edu.tw:ftp -n
lsof -p 12 看进程号为 12的进程打开了哪些文件
2、grep 不显示本身进程
#ps -aux|grep httpd|grep -v grep
grep -v grep可以取消显示你所执行的 grep 本身这个进程,-v 参数是不显示所列出的进程名
3、查看本机IP
ifconfig |grep "inet" |cut -c 0-36|sed -e 's/[a-zA-Z: ]//g'
hostname –i
4、查看有多少活动的Httpd进程
#!/bin/sh
while (true)
do
pstree |grep "*[httpd]$"|sed 's/.*-([0-9][0-9]*)*[httpd]$/1/'
sleep 3
done
同样可以引用到其它的进程
5、设置 com1口,让超级终端通过 com1口进行登录
责编:豆豆技术应用
- Linux/Unix 新闻
- Linux/Unix 入门
- Linux/Unix 命令
- Linux/Unix 安装
- Linux 嵌入式系统
- Linux/Unix 编程
- Linux/Unix 管理
- Linux/Unix 桌面
- Linux/Unix 内核
- Linux/Unix 软件
- SCO Unix
- NetBSD
- OpenBSD
- Redhat/Fedora Linux
- 手机
- Linux/Unix find 搜索命令
- Linux/Unix vi 命令
- Linux/Unix kde 桌面环境
- Linux/Unix GNOME 桌面环境
- Linux/Unix Make 命令
- Linux/Unix crontab 命令
- Linux/Unix ext3 文件系统
- Linux/Unix 文件系统详解
- Linux/Unix ADSL 拨号设置
- Linux/Unix GRUB 配置及应用
- Linux/Unix nfs配置
- Linux/Unix 硬件信息查看及管理
- Linux/Unix 优化
- Linux/Unix 交换分区Swap管理及应用
- Linux/Unix 用户管理
- Linux/Unix Ramdisk
- Linux/Unix 密码恢复管理
- Linux/Unix 文件删除恢复
- Linux/Unix fdisk分区
- Linux/Unix lvs负载均衡管理
- Linux/Unix root用户
- Linux/Unix 集群
- Linux/Unix 日志
- 更多Linux/Unix专题……