Skip to content

Instantly share code, notes, and snippets.

@Albert-W
Last active February 20, 2020 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Albert-W/c53ea331d9c1d6df0b01fe0141276b35 to your computer and use it in GitHub Desktop.
Save Albert-W/c53ea331d9c1d6df0b01fe0141276b35 to your computer and use it in GitHub Desktop.
Linux信息命令
系统信息
系统版本 lsb_release -a
cat /etc/issue
cat /etc/redhat-release
cat /etc/centos-release
内核/操作系统/CPU信息 uname -a
uname -s # 查看内核名称
包含GCC的版本信息 cat /proc/version
gcc --version
计算机名 hostname
环境变量 env
查看系统位数 file /bin/ls
getconf LONG_BIT
显示当前shell echo $SHELL
系统运行时间、用户数、负载 uptime
系统负载磁盘信息 cat /proc/loadavg 前三个值分别代表系统5分钟、10分钟、15分钟前的平均负载
第四个值的分子是正在运行的进程数,分母为总进程数
第五个值是最近运行的进程id
硬件信息
查看设备io端口 cat /proc/ioports
查看中断 cat /proc/interrupts
内存使用量和交换区使用量 free -h
swap分区的信息 cat /proc/swaps
查看所有交换分区 swapon -s
每5秒查看内存信息 vmstat 5
内存信息 cat /proc/meminfo
查看内存总量 grep MemTotal /proc/meminfo
查看空闲内存量 grep MemFree /proc/meminfo
各分区使用情况 df -h
挂接的分区状态 mount column -t
CPU信息 cat /proc/cpuinfo
lscpu
CPU型号 cat /proc/cpuinfo grep name
CPU频率 cat /proc/cpuinfo grep MHz
物理CPU个数 cat /proc/cpuinfo grep "physical id"
逻辑CPU个数 cat /proc/cpuinfo grep "processor"
CPU是几核 cat /proc/cpuinfo grep "cores"
网络信息
所有网络接口的属性,mtu ifconfig
路由表数字显示 route -n
查看防火墙设置 sudo iptables -L
网卡信息文件 cat /etc/network/interfaces(16.4)
/etc/netplan/ (18.4)
cat /etc/sysconfig/network-scripts/ifcfg-eth0
查看DNS服务器 cat /etc/resolv.conf
显示所有打开的端口 lsof -i
查看端口信息 netstat -ano (-lno)
netstat -antp
t tcp
u udp
a all connected.
l lisening
n numeric
p program
o timers
s statistics
查看端口wsl nmap localhost
进程信息
查看当前进程 ps
查看所有进程 ps -ef
ps aux
找到所有httpd ps aux grep httpd
查看进程树 pstree
查看进程占用的目录 pwdx PID
实时显示进程状态 top
形象化查看系统状态 htop
列出所有系统服务 chkconfig –list
列出所有启动的系统服务程序 chkconfig –list grep on
用户与组
活动用户 w
当前用户信息 id
用户登录日志 last 二进制文件,不可人为修改
用户所在组信息 groups
系统所有用户 cut -d: -f1 /etc/passwd
所有用户详细 cat /etc/passwd
查看uid等用户信息 lslogins
系统所有组 cut -d: -f1 /etc/group
当前用户的计划任务 crontab -l
文件命令
当前路径 pwd
查看目录 ll
查看别名 alias
指定目录的大小 du -sh ~/miniconda3/
命令相关
显示最近的30条指令 history tail -30
显示builtin commands help part of the shell itself
Display information about builtin commands. help cd
Display information about command type. type grep
查找命令 whereis grep
shows the full path of (shell) commands. which grep
type -p grep
read from info file. info python info yum
find file from database sudo updatedb
locate
updatedb 无
locate 无
从当前目录中找到A文件 find A
软件信息
软件包后缀 *.deb *.rpm
软件源配置文件 /etc/apt/sources.list /etc/yum.conf
查看已安装的软件 apt list --installed
dpkg -l
yum list installed
rpm -qa
获取某软件包的信息 apt-cache show package yum search package
获取某个已安装软件包的信息 dpkg --status package yum info package
rpm -qi package
搜索某个文件是由哪个软件包安装的 dpkg -S /file/name
dpkg --search /file/name
rpm -qf /file/name
搜索所有提供某个文件的软件包 apt-file search /file/name yum provides /file/name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment