SHELL的指令非常多,非常杂。越是多越是杂越有总结归纳的必要。
  以下是我自己总结的SHELL指令体系架构图:
SHELL体系知识II

1.shell指令总览
  1.1.用户和组
  1.2.变量
  1.3.资源
  1.4.服务
  1.5.文件和目录

2.用户和组
  2.1.查看
    2.1.1./etc/passwd
      2.1.1.1.示例:view /etc/passwd
     2.1.2./etc/group
      2.1.2.1.示例:view /etc/group
  2.2.设置
    2.2.1.用户
      2.2.1.1.useradd
        2.2.1.1.1.示例
        (1)useradd –u 1002 zh
        (2)useradd –m zhanghuan
      2.2.1.2.userdel
        2.2.1.2.1.示例:userdel -r zh
      2.2.1.3.usermod
        2.2.1.3.1.示例
        (1)usermod -G zh db2inst1
        (2)usermod -u 1111 zh
      2.2.1.4.passwd
        2.2.1.4.1.示例:passwd zh
    2.2.2.组
      2.2.2.1.groupadd
        2.2.2.1.1.示例
        (1)groupadd zhtest
        (2)groupadd -g 1009 testzh
      2.2.2.2.groupdel
        2.2.2.2.1.示例:groupdel testddd
      2.2.2.3.groupmod
        2.2.2.3.1.示例
        (1)groupmod -g 1010 testzh
        (2)groupmod -n testddd testzh

3.变量
  3.1.系统保留环境变量
    3.1.1.${HOSTNAME}
    3.1.2.${USER}/${LOGNAME}
    3.1.3.${PWD}
    3.1.4.${PS1}
    3.1.5.${PATH}
    3.1.6.${HOME}
  3.2.查看
    3.2.1.env
    3.2.2.set
    3.2.3.hostname
  3.3.设置
    3.3.1.export
      3.3.1.1.示例:export VAR_ZH=123
    3.3.2.read
      3.3.2.1.示例:read iInit
    3.3.3.readonly
      3.3.3.1.示例:readonly iInit
    3.3.4.unset
      3.3.4.1.示例:unset iInit

4.资源
  4.1.文件系统
    4.1.1.查看
      4.1.1.1.df
        4.1.1.1.1.示例
(1)df -m
(2)df -h
(3)df -T
(4)df -t tmpfs
(5)df -ia
    4.1.2.设置
      4.1.2.1.mount
        4.1.2.1.1.示例:mount -t iso9660 -o loop /usr/local/src/rhel-server-7.1-x86_64-dvd.iso /media/cdrom
      4.1.2.2.umount
        4.1.2.2.1.示例:umount /dev/shm
  4.2.内存和CPU
    4.2.1.查看
      4.2.1.1.top
        4.2.1.1.1.示例
(1)top
(2)top -p pid
      4.2.1.2.vmstat
        4.2.1.2.1.示例
(1)vmstat
(2)vmstat 10 3
      4.2.1.3.free
        4.2.1.3.1.示例:free
    4.2.2.设置
      4.2.2.1.ulimit
        4.2.2.1.1.示例
(1)ulimit -a
(2)ulimit -t unlimited–cup时间
(3)ulimit -m unlimited–最大内存
(4)ulimit -s unlimited–堆栈大小
(5)ulimit -v unlimited–虚拟内存
  4.3.网络
    4.3.1.查看
      4.3.1.1.netstat
        4.3.1.1.1.示例
(1)netstat -an
(2)netstat -anp(redhat)
(3)netstat -Aan(AIX)
    4.3.1.2.lsof
        4.3.1.2.1.示例
(1)lsof -p 75801
(2)lsof -i:8009
(3)lsof -u tomcat
(4)lsof /home/tomcat/apache-tomcat-7.0.59/lib/log4j-taglib-2.8.2.jar
      4.3.1.3.rmsock
        4.3.1.3.1.示例
(1)rmsock f1000e0005a00bb8 tcpcb
(2)rmsock f1000e0005a00bb8 inpcb
      4.3.1.4.ifconfig
        4.3.1.4.1.示例
(1)ifconfig -a
(2)ifconfig lo down
(3)ifconfig lo up
      4.3.1.5.route
4.3.1.5.1.示例:route -n
      4.3.1.6.ping
        

标题

4.3.1.5.1.示例:
(1)ping 192.168.1.137
(2)ping -c 10 192.168.1.137

5.服务
5.1.进程
5.1.1.查看
5.1.1.1.ps
5.1.1.1.1.示例
(1)ps -ef
(2)ps -f -t pts/1
(3)ps -f -u tomcat
5.1.1.2.ipcs
5.1.1.2.1.示例
(1)ipcs -m
(2)ipcs -q
(3)iipcs -s
5.1.2.设置
5.1.2.1.kill
5.1.2.1.1.示例
(1)kill -l
(2)kill -9 2422
5.1.2.2.ipcrm
5.1.2.1.1.示例
(1)ipcrm -m 104876
(2)ipcrm -s 204876
(3)ipcrm -q 304876
5.1.2.3.nohup &
5.1.2.3.1.示例:nohup my_date.sh &
5.2.功能
5.2.1.查看
5.2.1.1.service
5.2.1.1.1.示例
(1)service --status-all
(2)service network status
(3)service network stop/start/restart
5.2.2.设置
5.2.2.1.rpm
5.2.2.1.1.示例
(1)rpm -qa
(2)rpm -ql ftp
(3)rpm -ivh samba-3.0.10-1.4E.i386.rpm
5.2.2.2.yum
5.2.2.2.1.示例
(1)yum -list
(2)yum clean all
(3)yum makecache
(4)yum -install samba-3.0.10-1.4E.i386.rpm
(5)yum -remove samba-3.0.10-1.4E.i386.rpm
5.2.2.2.2.软件包仓库
(1)mount -t iso9660 -o loop /usr/local/src/rhel-server-7.1-x86_64-dvd.iso /media/cdrom
(2)cd /etc/yum.repos.d
(3)view rehl-media.repo
[rhel-media]
name=Red_Hat_7
baseurl=file:///media/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///media/cdrom/RPM-GPG-KEY-redhat-release
(4)yum clean all
(5)yum makecache
5.2.3.特殊服务
5.2.3.1.date
5.2.3.1.1.示例
(1)date
(2)date -s “11:22:33 20190509”
(3)date +%Y%m%d%H%M%S
(4)date -d “3 days”
5.2.3.2.crontab
5.2.3.2.1.示例
(1)crontab -l(59 23 31 1 1 my_sh.sh)
(2)crontab -e
(3)crontab -r

6.目录和文件
6.1.目录
6.1.1.查看
6.1.1.1.pwd
6.1.1.1.1.示例
(1)pwd
6.1.2.设置
6.1.2.1.cd
6.1.2.1.1.示例
(1)cd …/…/
(2)cd test
6.1.2.2.mkdir
6.1.2.2.1.示例
(1)mkdir zh
(2)mkdir -p zh(mkdir -vp zh/zh/zh)
6.2.文件
6.2.1.查看
6.2.1.1.外壳
6.2.1.1.1.ls
6.2.1.1.1.1.示例
(1)ls
(2)ls -lrta
(3)ls -i
6.2.1.1.2.stat(istat)
6.2.1.1.2.1.示例
(1)stat 11.txt
(2)stat -f /dev/sda1
6.2.1.1.3.file
6.2.1.1.3.1.示例
(1)file 11.txt
(2)file -i 11.txt
6.2.1.1.4.umask
6.2.1.1.4.1.示例
(1)umask
(2)umask 0022
6.2.1.2.内容
6.2.1.2.1.明细
6.2.1.2.1.1.cat
6.2.1.2.1.1.1.示例
(1)cat 11.txt
(2)cat -n 11.txt
(3)cat -s 11.txt
(4)cat -e 11.txt
6.2.1.2.1.2.more
6.2.1.2.1.2.1.示例
(1)more 11.txt
(2)more +2 11.txt
(3)more -2 11.txt
6.2.1.2.1.3.head
6.2.1.2.1.3.1.示例
(1)head -n 30 my_reflection.java
(2)head -n -30 my_reflection.java
(3)head -c 100 my_reflection.java
6.2.1.2.1.4.tail
6.2.1.2.1.4.1.示例
(1)tail -n 10 my_reflection.java
(2)tail -c 100 my_reflection.java
(3)tail -f my_reflection.java
6.2.1.2.1.5.nm/strings
6.2.1.2.1.5.1.示例
(1)nm ATM_SVR
(2)strings ExceptionDemo.class
6.2.1.2.1.6.diff:diff 1.txt 2.txt
6.2.1.2.2.统计
6.2.1.2.2.1.wc
6.2.1.2.2.1.1示例
(1)wc -c 12.txt
(1)wc -m 12.txt
(1)wc -w 12.txt
(1)wc -l 12.txt
6.2.2.搜索
6.2.2.1.find
6.2.2.1.1.示例
(1)find . -name “.txt"
(2)find . -mtime -5 -a -name "
.txt”
(3)find . -user star31 -a -name “.txt"
(4)find . -size +4 -a -name "
.txt”
(5)find . -name ".txt" -type f
(6)find . -inum 2222
6.2.2.2.xargs
6.2.2.2.1.示例
(1)find . –name “
.txt”|xargs grep star31
(2)ls |xargs grep star31
6.2.2.3.grep
6.2.2.3.1.示例
(1)grep –i zh 1.txt
(2)grep –l zh 1.txt
(3)grep –n zh 1.txt
(4)grep –v zh 1.txt
6.2.3.设置
6.2.3.1.外壳
6.2.3.1.1.cp、mv
6.2.3.1.1.1.示例
(1)cp -f 1.txt 2.txt(默认为-f参数)
(2)cp -i 1.txt 2.txt
(3)cp -r com com_test
(4)mv -f 1.txt 2.txt(默认为-f参数)
(5)mv -i 1.txt 2.txt
(6)mv -b 1.txt 2.txt
6.2.3.1.2.rm
6.2.3.1.2.1.示例
(1)rm 555.sh
(2)rm -rf tmp
6.2.3.1.3.chmod
6.2.3.1.3.1.示例
(1)chmod 777 1.txt
(2)chmod 4771 1.txt(使文件在执行时临时拥有文件所属用户权限)
6.2.3.1.4.chown
6.2.3.1.4.1.示例
(1)chown root:root 1.txt
(2)chown -R root:root db2_demo
6.2.3.1.5.ln
6.2.3.1.5.1.示例
(1)ln -s source.txt target.txt
6.2.3.2.内容
6.2.3.2.1.awk
6.2.3.2.1.1.示例
(1)awk ‘{print $1}’ 5.txt
(2)awk -F# ‘{print $1}’ 5.txt
(3)awk ‘{if($1==“1” && $2==“zh”) print $0}’ 6.txt
6.2.3.2.2.|、tee
6.2.3.2.2.1.示例
(1)ls |xargs grep like
(2)ls -lrt|tee 11.txt
(3)ls -lrt|tee -a 11.txt
6.2.3.2.3.sed
6.2.3.2.3.1.示例
(1)sed -n ‘1,3p’ 2019.txt
(2)sed ‘1,10 s/my/newnew/’ 2019.txt
(3)sed -n ‘1, 3p’ 2019.txt|sed ‘/my/ p’
(4)sed ‘s/123/d’ 2019.txt
(5)sed ‘y/my/ll/’ 2019.txt
6.2.3.2.4.cut
6.2.3.2.4.1.示例
(1)cut -b 1-4 20190510.txt
(2)cut -c 1-4 20190510.txt
(3)cut -d ‘:’ -f1-3 new1.txt
6.2.3.2.5.sort
6.2.3.2.5.1.示例
(1)sort -n new1.txt
(2)sort -t ‘:’ -r –k4 44.txt
(3)sort -u 44.txt
(4)sort -m -k2 new1.txt new2.txt
6.2.3.2.6.join
6.2.3.2.6.1.示例
(1)join –a1 –a2 names.txt town.txt
(2)join –o 1.2 2.2 names.txt town.txt
(3)join –j2 –j2 names.txt town.txt
(4)join –j3 –j3 names.txt town.txt
(5)join –t: -j2 –j2 names.txt town.txt
6.2.3.2.7.paste
6.2.3.2.7.1.示例
(1)paste new1.txt new2.txt
(1)paste -d ‘:’ new1.txt new2.txt
(3)paste -d ‘:’ -s new1.txt new2.txt
6.2.3.2.8.split
6.2.3.2.8.1.示例
(1)split -b 20 new1.txt outfilename
(2)split -C 20 new1.txt outfilename
(3)split -l 2 new1.txt outfilename
6.2.4.打包压缩
6.2.4.1.tar
6.2.4.1.1.示例
(1)tar -cvf x.tar com
(2)tar -tvf x.tar com
(3)tar -xvf x.tar com
6.2.4.2.gzip
6.2.4.2.1.示例
(1)gzip -9 1.txt
(2)gzip -d 1.txt.gz
6.2.4.3.compress、uncompress
6.2.4.3.1.示例
(1)compress 1.txt
(2)compress -d 1.txt.Z
(3)uncompress -f 1.txt.Z

相关文章:

  • 2022-01-20
  • 2022-01-05
  • 2021-09-18
  • 2021-10-15
  • 2021-11-10
  • 2021-10-12
  • 2021-04-11
  • 2021-09-03
猜你喜欢
  • 2021-10-14
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案