linux 的一些命令

# watch - execute a program periodically, showing output fullscreen
watch -n 1 date # 每秒执行一次 date 命令
watch -n 1 "date +%T"

# netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
# -p Show the PID and name of the program to which each socket belongs.
# -a Show both listening and non-listening sockets. 
# -l Show only listening sockets. (These are omitted by default.)
# -n Show numerical addresses instead of trying to determine symbolic host, port or user names.
# --tcp|-t
# --udp|-u    
netstat -a -p | grep LISTEN

# 打印文件第3行
sed -n '3p' file

# 文件去空行
grep -v '^$' file > newfile

# 查找 process IDs
# pgrep
# -f The pattern is normally only matched against the process name.  When -f is set, the full command line is used.
pgrep -u root,www-data memcached
kill `pgrep memcached`
killall memcached

# find the process ID of a running program
# pidof
kill $(pidof memcached)

# 查看系统开机时间
who -b /var/log/wtmp
who -b

# 查看进程树
ps axuwwf

# 查看进程运行的时间
ps -eo pid,etime,cmd

# dmesg

Liunx

这篇文章: 有用 无用
创建 2012-05-20 22:07:50 / 更新 2016-11-28 21:27:30