1 、找出ifconfig“网卡名”命令结果中本机的IPv4地址

  1. centos6
  2. ifconfig eth0 | head -n2 |tail -n1 |tr -s " " : |cut -d: -f4
  3. centos7
  4. ifconfig ens33 |grep netmask |tr -s ' ' |cut -d " " -f3

2 、查出分区空间使用率的最大百分比值

  1. df | grep /dev/sd |tr -s ' ' % | cut -d% -f5 | sort -nr | head -n1

3 、查出用户UID最大值的用户名、UID及shell 类型

  1. cut -d: -f1,3,7 /etc/passwd | sort -t: -k2 -nr | head -n1

4 、查出/tmp的权限,以数字方式显示

  1. stat /tmp | grep Uid | tr -s " " / | cut -d/ -f2 | cut -d"(" -f2

5 、统计当前连接本机的每个远程主机IP的连接数,并按从大

到小排序

  1. netstat -tun | grep ESTAB | tr -s " " : | cut -d: -f6 | sort -nr | uniq -c

6、 ss -nt 查询并发连接的远程IP

  1. ss -nt | tr -s " " : | grep ESTAB | cut -d: -f6

7、 判断主版本号

  1. grep -o "[[:digit:]]\+" /etc/centos-release | head -n1

8、 取函数名

  1. grep -o "^[[:alnum:]_]\+[[:space:]]*()" /etc/init.d/functions

9、 生成指定位数的随机口令

  1. cat /dev/urandom |tr -dc '[:alnum:]_' |head -c20
  2. tr -dc '[:alnum:]_' < /dev/urandom |head -c20
  3. openssl rand -base64 30 |head -c20