Linux


CPU

摘录 /proc/cpuinfo 部分内容如下

processor	: 0                                      # 逻辑处理器标识
physical id	: 0                                      # 物理处理器标识
core id		: 0                                      # 处理器内核标识
cpu cores	: 4                                      # 单个物理处理器里的内核数
apicid		: 0                                      # 中断处理器标识

可以使用以下语句来查询服务器的cpu数

grep physical /proc/cpuinfo | sort | uniq | wc -l      # CPU 数量
grep cores /proc/cpuinfo | head -1 | awk '{print $4}'  # 单颗 CPU 的内核数

Device

获取tty1的输出

cat /dev/vcs1
tty = teletypewriter
pts = Pseudo tty slave
ptmx = Pseudo tty master multiplex
http://www.lanana.org/docs/device-list/devices-2.6+.txt
http://lamp.linux.gov.cn/Linux/device_files.html

GPG

gpg --kerserver subkeys.pgp.net --recv 7EDF681F
gpg --verify linux-3.8.2-1-i686.pkg.tar.xz.sig

ifconfig

Link

see kernel source net/core/dev.c

cat /proc/net/dev
cat /proc/net/snmp

lsof

lsof /var/log/messages
lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
lsof -i [tcp]:ssh,ftp
lsof -i [tcp][@0.0.0.0]:22,21
lsof -c cmdline
lsof -p pid
lsof -g gid
lsof +d directory
lsof +D directory  # recursively
lsof -d txt,mem    # specifies a list of file descriptors
lsof -d ^txt,^mem  # exclude a list of file descriptors
lsof -r            # repeat mode
lsof -u root
lsof -u ^root
lsof -iTCP -sTCP:LISTEN

TCP

CLOSED, IDLE, BOUND, LISTEN, ESTABLISHED, SYN_SENT, SYN_RCDV, ESTABLISHED,
CLOSE_WAIT, FIN_WAIT1, CLOSING, LAST_ACK, FIN_WAIT_2, TIME_WAIT.

UDP

Unbound, Idle.

sar

sar -n DEV 1 5

tcpdump

tcpdump -vv -i eth0 -c 100 -s 1500 -w sniffer.pack tcp port 80
tcpdump -n -X -i eth0 host 192.168.1.2

无线配置 WIFI

iwconfig wlan0 essid "zhong"
iwconfig wlan0 key s:12345678
ifconfig wlan0 up
dhcpcd wlan0

wpa_supplicant

wpa_passphrase zhong >> /etc/wpa_supplicant.conf
wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant.conf -B
ifconfig wlan0 up
dhcpcd wlan0

SELinux

cat /etc/sysconfig/selinux
getenforce
setenforce
sestatus

screen

screen 是一个用于在多个进程之间, 通常是多个交互式shell之间, 复用一个物理终端的全屏窗口管理器.

# 创建会话, 如带cmd, cmd结束后 screen会话自动结束
screen [cmd [args]]
screen -S session_name [cmd [args]]
screen -mdS session_name [cmd [args]]

# 显示可用会话
screen -ls
# 删除异常结束的会话并显示当前可用会话
screen -wipe

# 恢复会话
screen -r [pid|session_name]

# 共享会话
screen -x [pid|session_name]

# 离开会话
CTRL+a, d 同时按下CTRL键和a键, 松开再按d键, 从一个screen会话离开
# 结束会话
exit