免费爱碰视频在线观看,九九精品国产屋,欧美亚洲尤物久久精品,1024在线观看视频亚洲

      4、liunx系統基礎命令及特殊符號知識考題

      4、liunx系統基礎命令及特殊符號知識考題

      什么是PATH環(huán)境變量,它有什么作用?

      LANG PS1 PATH

      ######PATH含義

      存放的是命令位置/路徑

      [root@oldboyedu01-nb ~]# echo $PATH

      /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

      第二個里程牌-liunx 下面運行命令過程

      ####1、輸入命令

      ####2、在PATH里面 路徑進行查找

      ####3、找到了就運行

      ####4、找不到就提示 command not found

      第1題

      如何過濾出已知當前目錄下oldboy中的所有一級目錄(提示:不包含oldboy目錄下面目錄的子目錄及隱藏目錄,即只能是第一級目錄)?

      mkdir /oldboy -p

      cd /oldboy

      mkdir ext/oldboy test xiaodong xingfujie -p

      touch jeacen olaboy wodi.gz yingsui.gz

      yum install tree -y

      [root@oldboyedu01-nb oldboy]# #如何查詢某個軟件是否安裝了?

      [root@oldboyedu01-nb oldboy]# rpm -qa (查找所有安裝軟件)

      [root@oldboyedu01-nb oldboy]# rpm -qa

      [root@oldboyedu01-nb oldboy]# rpm -qa |grep tree (查找具體的軟件安裝包)

      tree-1.5.3-3.el6.x86_64

      [root@oldboyedu01-nb oldboy]# rpm -qa tree

      tree-1.5.3-3.el6.x86_64

      [root@oldboyedu01-nb oldboy]# rpm -qa |grep ipt

      initscripts-9.03.58-1.el6.centos.x86_64

      iptables-ipv6-1.4.7-16.el6.x86_64

      plymouth-scripts-0.8.3-29.el6.centos.x86_64

      iptables-1.4.7-16.el6.x86_64

      [root@oldboyedu01-nb oldboy]# #查看某個軟件包里面的內容

      [root@oldboyedu01-nb oldboy]# rpm -ql tre

      package tre is not installed

      [root@oldboyedu01-nb oldboy]# rpm -ql tree (查看具體安裝包里面的內容)

      /usr/bin/tree

      /usr/share/doc/tree-1.5.3

      /usr/share/doc/tree-1.5.3/LICENSE

      ###方法1

      [root@oldboyedu01-nb oldboy]# tree -d /oldboy/

      /oldboy/

      ext

      oldboy

      test

      xiaodong

      xingfujie

      5 directories

      [root@oldboyedu01-nb oldboy]#

      [root@oldboyedu01-nb oldboy]# tree -dL 1 /oldboy/

      /oldboy/

      ext

      test

      xiaodong

      xingfujie

      ##方法2

      [root@oldboyedu01-nb oldboy]# find -type d

      .

      ./ext

      ./ext/oldboy

      ./xiaodong

      ./test

      ./xingfujie

      [root@oldboyedu01-nb oldboy]# find -maxdepth 1 -type d ! -name “.” (找出名字不是點)

      ./ext

      ./xiaodong

      ./test

      ./xingfujie

      ###方法3

      [root@oldboyedu01-nb oldboy]# ls -l

      total 28

      -rw-r–r–. 1 root root 0 Jun 9 07:06 alex.txt

      -rw-r–r–. 1 root root 292 Jun 9 06:34 ett.txt

      drwxr-xr-x 3 root root 4096 Jun 22 21:55 ext

      -rw-r–r– 1 root root 0 Jun 22 23:44 jeacen

      -rw-r–r– 1 root root 0 Jun 22 23:44 olaboy

      -rw-r–r–. 1 root root 0 Jun 9 07:06 oldboy.txt

      drwxr-xr-x. 2 root root 4096 Jun 9 07:26 test

      -rw-r–r–. 1 root root 8 Jun 9 07:26 test.sh

      -rw-r–r–. 1 root root 8 Jun 9 07:26 t.sh

      -rw-r–r– 1 root root 0 Jun 22 23:44 wodi.gz

      drwxr-xr-x 2 root root 4096 Jun 22 21:55 xiaodong

      drwxr-xr-x 2 root root 4096 Jun 22 21:55 xingfujie

      -rw-r–r– 1 root root 0 Jun 22 23:44 yingsui.gz

      [root@oldboyedu01-nb oldboy]# ls -l |grep “^d” (找出目錄為d開頭的文件

      drwxr-xr-x 3 root root 4096 Jun 22 21:55 ext

      drwxr-xr-x. 2 root root 4096 Jun 9 07:26 test

      drwxr-xr-x 2 root root 4096 Jun 22 21:55 xiaodong

      drwxr-xr-x 2 root root 4096 Jun 22 21:55 xingfujie

      [root@oldboyedu01-nb oldboy]#

      #方法4

      [root@oldboyedu01-nb oldboy]# ls -l|awk ‘$2>1’ (第二列大于1)

      total 28

      drwxr-xr-x 3 root root 4096 Jun 22 21:55 ext

      drwxr-xr-x. 2 root root 4096 Jun 9 07:26 test

      drwxr-xr-x 2 root root 4096 Jun 22 21:55 xiaodong

      drwxr-xr-x 2 root root 4096 Jun 22 21:55 xingfujie

      [root@oldboyedu01-nb oldboy]#

      #第2題假如當前目錄[root@oldboyedu01-nb oldboy]# pwd #==>這是打印當前目錄的,最菜的命令

      /oldboy

      現在因為需要進入到/tmp目錄下進行操作,執(zhí)行的命令如下:

      [root@oldboy oldboy]# cd /tmp/

      [root@oldboy tmp]#pwd

      /tmp/

      操作完畢后,希望快速返回上一次進入的目錄,即/oldboy目錄,如何操作(不使用cd/oldboy)

      [root@oldboyedu01-nb tmp]# #快速回到上一次的所在的位置/目錄

      [root@oldboyedu01-nb tmp]# cd –

      /oldboy

      [root@oldboyedu01-nb oldboy]# pwd

      /oldboy

      [root@oldboyedu01-nb oldboy]#

      cd –

      cd . =====當前目錄 復制/移動 cp/etc/host.

      cd.. =====進入到當前目錄的上一級目錄

      cd~ =====進入當前用戶的家目錄,回老家

      (root用戶)~ ====/root

      (普通用戶)~ ====/home/

      cd =====回老家 回家

      cd – #快速回到上一次的所在位置/目錄

      [root@oldboyedu01-nb oldboy]##進入到/etc/sysconfig/network-scripts/目錄,并查看你所在的位置

      [root@oldboyedu01-nb oldboy]#進入到上一級目錄,并查看你所在位置

      [root@oldboyedu01-nb oldboy]##進入到/root目錄下面,并顯示你所在位置

      [root@oldboyedu01-nb oldboy]#回到老家

      [root@VM-8-6-centos ~]# cd /oldboy/

      [root@VM-8-6-centos oldboy]# cd /etc/sysconfig/network-scripts/

      [root@VM-8-6-centos network-scripts]# pwd

      /etc/sysconfig/network-scripts

      [root@VM-8-6-centos network-scripts]# cd ..

      [root@VM-8-6-centos sysconfig]# pwd

      /etc/sysconfig

      [root@VM-8-6-centos sysconfig]# cd /root/

      [root@VM-8-6-centos ~]# pwd

      /root

      [root@VM-8-6-centos ~]# cd –

      /etc/sysconfig

      #第3題一個目錄中有多文件(ls查看時好多屏),想最快速度查看到最近更新的文件,怎么查

      ls -lrt

      第5題 調試系統服務時,希望能實時查看系統日志/var/log/messages的更新,如何做?

      tail -f 顯示文件的實時更新

      taillf ====tail -f

      第4題 打印配置文件nginx.conf 內容的行號及內容,該如何做?

      [root@oldboyedu01-nb oldboy]# echo {1..5}

      1 2 3 4 5

      [root@oldboyedu01-nb oldboy]# echo stu {01..10}

      stu 01 02 03 04 05 06 07 08 09 10

      [root@oldboyedu01-nb oldboy]# echo stu{01..10}

      stu01 stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10

      [root@oldboyedu01-nb oldboy]# echo stu{01..10}xargs -n1

      stu01xargs stu02xargs stu03xargs stu04xargs stu05xargs stu06xargs stu07xargs stu08xargs stu09xargs stu10xargs -n1

      [root@oldboyedu01-nb oldboy]# echo stu{01..10}|xargs -n1

      stu01

      stu02

      stu03

      stu04

      stu05

      stu06

      stu07

      stu08

      stu09

      stu10

      [root@oldboyedu01-nb oldboy]# echo stu{01..10}|xargs -n1 >nginx.conf

      [root@oldboyedu01-nb oldboy]# cat nginx.conf

      stu01

      stu02

      stu03

      stu04

      stu05

      stu06

      stu07

      stu08

      stu09

      stu10

      [root@oldboyedu01-nb oldboy]#

      ###方法1

      [root@oldboyedu01-nb oldboy]# cat -n nginx.conf (-n表示行號)

      1 stu01

      2 stu02

      3 stu03

      4 stu04

      5 stu05

      6 stu06

      7 stu07

      8 stu08

      9 stu09

      10 stu10

      ###方法2 -vi/vim

      :set nu #顯示行號 number

      :set monu #取消小時行號

      ###方法3 -grep -n參數

      [root@oldboyedu01-nb oldboy]# grep -n “stu” nginx.conf

      1:stu01

      2:stu02

      3:stu03

      4:stu04

      5:stu05

      6:stu06

      7:stu07

      8:stu08

      9:stu09

      10:stu10

      [root@oldboyedu01-nb oldboy]# grep -n “.” nginx.conf

      1:stu01

      2:stu02

      3:stu03

      4:stu04

      5:stu05

      6:stu06

      7:stu07

      8:stu08

      9:stu09

      10:stu10

      小結

      1.cat -n;vi/vim顯示行號

      2、grep -n

      3、awk NR $ print

      ###第5題,裝完系統后,希望讓網絡文件共享服務器NFS(iptables),僅在3級別上開機自啟動,如何操作?

      chkconfig iptables off

      ###第6題,liunx系統中查看中文,但是亂碼,請問如何解決?

      ###原因:liunx使用字符集與原創(chuàng)連接工具的不同

      解決:

      方法1:推薦修改xshell 字符集

      方法2:修改系統字符集

      1:命令行 export LANG=en_us.utf-8

      2.寫入配置文件

      cp /etc/sysconfig/i18n /etc/sysconfig/i18n.bat

      echo ‘LANG=en_us.UTF-8′>/etc/sysconfig/i18n

      3、生效

      source /etc/sysconfig/i18n

      ###第7題; /etc/目錄為liunx系統默認的配置文件及服務啟動命令的目錄

      a、請用tar 打包/etc整個目錄(打包及壓縮)

      b、請把a點命令的壓縮包,解壓到/tmp指定目錄下(最好只用tar命令實現)

      c、請用tar打包/etc整個目錄(打包及壓縮,但需要排除/etc/services文件)。

      tar 創(chuàng)建查看解壓壓縮包

      [root@oldboyedu01-nb oldboy]# tar zcvf /tmp/etc.tar.gz /etc/

      創(chuàng)建壓縮包 壓縮包存放的位置 壓縮能夠目錄

      zcvf注釋:

      z—-通過gzip工具進行壓縮 ,

      c—–表示create創(chuàng)建 壓縮包 ,

      v—表示verbose顯示執(zhí)行過程

      f—–顯示file 接上壓縮包的名字

      [root@oldboyedu01-nb oldboy]# ls -l /tmp/ (查看文件)

      total 9508

      -rw-r–r– 1 root root 9736182 Jun 23 05:48 etc.tar.gz

      查看壓縮包的內容

      [root@oldboyedu01-nb oldboy]# tar ztf /tmp/etc.tar.gz

      ztf注釋: t—-表示list 顯示壓縮包的內容

      解壓

      [root@oldboyedu01-nb oldboy]# cd /tmp/

      [root@oldboyedu01-nb tmp]# tar zxf etc.tar.gz (解壓)

      創(chuàng)建

      tar zcf

      查看

      tar tf

      解壓

      tar xf

      [root@oldboyedu01-nb tmp]# tar zxf etc.tar.gz

      [root@oldboyedu01-nb tmp]# tar zcf /tmp/sysconfig.tar.gz /etc/sysconfig/

      tar: Removing leading /’ from member names tar: Removing leading /’ from hard link targets

      [root@oldboyedu01-nb tmp]# tar tf /tmp/sysconfig.tar.gz

      [root@oldboyedu01-nb tmp]# ls -l

      total 9568

      drwxr-xr-x 78 root root 4096 Jun 23 03:39 etc

      -rw-r–r– 1 root root 9736182 Jun 23 05:48 etc.tar.gz

      -rw-r–r– 1 root root 53851 Jun 23 06:00 sysconfig.tar.gz

      [root@oldboyedu01-nb tmp]# rm -fr etc

      do not use rm -fr etc

      [root@oldboyedu01-nb tmp]# ll

      total 9568

      drwxr-xr-x 78 root root 4096 Jun 23 03:39 etc

      -rw-r–r– 1 root root 9736182 Jun 23 05:48 etc.tar.gz

      -rw-r–r– 1 root root 53851 Jun 23 06:00 sysconfig.tar.gz

      [root@oldboyedu01-nb tmp]# rm -fr etc

      [root@oldboyedu01-nb tmp]# ll

      total 9564

      -rw-r–r– 1 root root 9736182 Jun 23 05:48 etc.tar.gz

      -rw-r–r– 1 root root 53851 Jun 23 06:00 sysconfig.tar.gz

      [root@oldboyedu01-nb tmp]# tar xf sysconfig.tar.gz

      [root@oldboyedu01-nb tmp]# ll

      total 9568

      drwxr-xr-x 3 root root 4096 Jun 23 06:02 etc

      -rw-r–r– 1 root root 9736182 Jun 23 05:48 etc.tar.gz

      -rw-r–r– 1 root root 53851 Jun 23 06:00 sysconfig.tar.gz

      [root@oldboyedu01-nb tmp]# ls etc

      sysconfig

      [root@oldboyedu01-nb tmp]# ls etc

      sysconfig

      [root@oldboyedu01-nb tmp]# ls etc/sysconfig/

      acpid i18n kernel quota_nld sshd

      atd init keyboard raid-check sysstat

      auditd ip6tables modules readahead sysstat.ioconf

      authconfig ip6tables-config netconsole readonly-root system-config-firewall

      cbq ip6tables.old network rngd system-config-firewall.old

      clock iptables networking rsyslog udev

      console iptables-config network-scripts sandbox

      cpuspeed iptables.old ntpd saslauthd

      crond irqbalance ntpdate selinux

      grub kdump prelink smartmontools

      請把A點命令的壓縮包,解壓到/tmp指定目錄下(最好用tar命令實現)

      [root@oldboyedu01-nb tmp]# tar xf etc.tar.gz -C /opt/ (指定目錄)

      [root@oldboyedu01-nb tmp]# ls -l /opt/ (查看解壓后的目錄情況)

      請用tar打包/etc整個目錄(打包及壓縮,但需要排除/etc/services文件)

      [root@oldboyedu01-nb tmp]# tar zcf /tmp/etc.tar.gz /etc/

      tar: Removing leading `/’ from member names

      tar: Removing leading `/’ from hard link targets

      [root@oldboyedu01-nb tmp]#

      [root@oldboyedu01-nb tmp]# tar zcf /tmp/etc-paichu.tar.gz /etc/ –exclude=/etc/services

      tar: Removing leading `/’ from member names

      tar: Removing leading `/’ from hard link targets

      [root@oldboyedu01-nb tmp]# tar zcf /tmp/etc-paichu.tar.gz /etc/ –exclude=/etc/services

      tar: Removing leading `/’ from member names

      tar: Removing leading `/’ from hard link targets

      [root@oldboyedu01-nb tmp]# tar tf /tmp/etc.tar.gz |grep services

      etc/init/readahead-disable-services.conf

      etc/services

      [root@oldboyedu01-nb tmp]# tar tf /tmp/etc-paichu.tar.gz|grep services

      etc/init/readahead-disable-services.conf

      [root@oldboyedu01-nb tmp]#

      cd /

      tar zcf /tmp/etc.tar.gz etc/

      小結:

      1、tar 打包壓縮

      2、創(chuàng)建壓縮包 查看壓縮包, 解壓

      3、解壓到指定的文件夾

      4、創(chuàng)建壓縮包排除

      #第8題如何查看etc/services文件的有多少行?

      [root@oldboyedu01-nb ~]# cd /oldboy/

      [root@oldboyedu01-nb oldboy]# wc -l /etc/services

      10774 /etc/services、

      屌絲去洗浴中心之路

      3、

      (1)查看22端口是否開啟telnet

      (2)sshd遠程連接進程是否在運行

      ps -ef

      [root@oldboyedu01-nb oldboy]# ps -ef |grep “sshd” (過濾進程sshd)

      root 1436 1 0 Jun22 ? 00:00:00 /usr/sbin/sshd

      root 2461 1436 0 05:11 ? 00:00:00 sshd: root@pts/0

      root 2588 1436 0 06:45 ? 00:00:00 sshd: root@pts/1

      root 2656 1436 0 07:30 ? 00:00:00 sshd: root@pts/2

      root 2701 2658 0 08:01 pts/2 00:00:00 grep sshd

      [root@oldboyedu01-nb oldboy]# ps -ef |grep “/sshd”

      root 1436 1 0 Jun22 ? 00:00:00 /usr/sbin/sshd

      root 2705 2658 0 08:03 pts/2 00:00:00 grep /sshd

      [root@oldboyedu01-nb oldboy]# ps -ef |grep “/sshd”|wc -l (顯示進程出現幾個;次數)

      2

      第9題:過濾出/etc/services 文件包含3306和1521兩數字所在行號的內容

      [root@oldboyedu01-nb oldboy]# grep “3306” /etc/services

      mysql 3306/tcp # MySQL

      mysql 3306/udp # MySQL

      [root@oldboyedu01-nb oldboy]# egrep “3306|1521” /etc/services

      mysql 3306/tcp # MySQL

      mysql 3306/udp # MySQL

      ncube-lm 1521/tcp # nCube License Manager

      ncube-lm 1521/udp # nCube License Manager

      [root@oldboyedu01-nb oldboy]# #egrep ==grep -E支持高級正則(公雞里的戰(zhàn)斗機)

      [root@oldboyedu01-nb oldboy]#

      第10題命令行及shell中不加引號、加單引號和加雙引號的區(qū)別小結

      單引號 所見即所得 吃啥吐啥

      雙引號 里面的特殊符號會被解析

      [root@VM-8-6-centos oldboy]# echo ‘hello lls $LANG $(hostname) ‘pwd”

      hello lls $LANG $(hostname) pwd

      鄭重聲明:本文內容及圖片均整理自互聯網,不代表本站立場,版權歸原作者所有,如有侵權請聯系管理員(admin#wlmqw.com)刪除。
      (0)
      用戶投稿
      上一篇 2022年7月2日 06:34
      下一篇 2022年7月2日 06:35

      相關推薦

      聯系我們

      聯系郵箱:admin#wlmqw.com
      工作時間:周一至周五,10:30-18:30,節(jié)假日休息