Linux 关于系统的一些命令

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

# 查看进程树
ps axuwwf

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

# 系统日志的查看

tail -f /var/log/{kern.log,dmesg,syslog}


dmesg -c # clear kernel ring buffer message to '/var/log/dmesg' file

dmesg -wH # since kernel 3.5.0 

watch -n 1 "dmesg | tail -n $((LINES - 6))"

# 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

# 查找 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)

# diff
diff -u -d


这篇文章: 有用 无用
创建 2016-11-28 21:28:34 / 更新 2017-02-03 18:38:02