在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    4、liunx系統(tǒng)基礎(chǔ)命令及特殊符號(hào)知識(shí)考題

    4、liunx系統(tǒng)基礎(chǔ)命令及特殊符號(hào)知識(shí)考題

    什么是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

    第二個(gè)里程牌-liunx 下面運(yùn)行命令過程

    ####1、輸入命令

    ####2、在PATH里面 路徑進(jìn)行查找

    ####3、找到了就運(yùn)行

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

    第1題

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

    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]# #如何查詢某個(gè)軟件是否安裝了?

    [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]# #查看某個(gè)軟件包里面的內(nèi)容

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

    package tre is not installed

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

    /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 “.” (找出名字不是點(diǎn))

    ./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題假如當(dāng)前目錄[root@oldboyedu01-nb oldboy]# pwd #==>這是打印當(dāng)前目錄的,最菜的命令

    /oldboy

    現(xiàn)在因?yàn)樾枰M(jìn)入到/tmp目錄下進(jìn)行操作,執(zhí)行的命令如下:

    [root@oldboy oldboy]# cd /tmp/

    [root@oldboy tmp]#pwd

    /tmp/

    操作完畢后,希望快速返回上一次進(jìn)入的目錄,即/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 . =====當(dāng)前目錄 復(fù)制/移動(dòng) cp/etc/host.

    cd.. =====進(jìn)入到當(dāng)前目錄的上一級(jí)目錄

    cd~ =====進(jìn)入當(dāng)前用戶的家目錄,回老家

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

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

    cd =====回老家 回家

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

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

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

    [root@oldboyedu01-nb oldboy]##進(jìn)入到/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題一個(gè)目錄中有多文件(ls查看時(shí)好多屏),想最快速度查看到最近更新的文件,怎么查

    ls -lrt

    第5題 調(diào)試系統(tǒng)服務(wù)時(shí),希望能實(shí)時(shí)查看系統(tǒng)日志/var/log/messages的更新,如何做?

    tail -f 顯示文件的實(shí)時(shí)更新

    taillf ====tail -f

    第4題 打印配置文件nginx.conf 內(nèi)容的行號(hào)及內(nèi)容,該如何做?

    [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表示行號(hào))

    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 #顯示行號(hào) number

    :set monu #取消小時(shí)行號(hào)

    ###方法3 -grep -n參數(shù)

    [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

    小結(jié)

    1.cat -n;vi/vim顯示行號(hào)

    2、grep -n

    3、awk NR $ print

    ###第5題,裝完系統(tǒng)后,希望讓網(wǎng)絡(luò)文件共享服務(wù)器NFS(iptables),僅在3級(jí)別上開機(jī)自啟動(dòng),如何操作?

    chkconfig iptables off

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

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

    解決:

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

    方法2:修改系統(tǒng)字符集

    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系統(tǒng)默認(rèn)的配置文件及服務(wù)啟動(dòng)命令的目錄

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

    b、請把a(bǔ)點(diǎn)命令的壓縮包,解壓到/tmp指定目錄下(最好只用tar命令實(shí)現(xiàn))

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

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

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

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

    zcvf注釋:

    z—-通過gzip工具進(jìn)行壓縮 ,

    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

    查看壓縮包的內(nèi)容

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

    ztf注釋: t—-表示list 顯示壓縮包的內(nèi)容

    解壓

    [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點(diǎn)命令的壓縮包,解壓到/tmp指定目錄下(最好用tar命令實(shí)現(xiàn))

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

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

    請用tar打包/etc整個(gè)目錄(打包及壓縮,但需要排除/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/

    小結(jié):

    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遠(yuǎn)程連接進(jìn)程是否在運(yùn)行

    ps -ef

    [root@oldboyedu01-nb oldboy]# ps -ef |grep “sshd” (過濾進(jìn)程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 (顯示進(jìn)程出現(xiàn)幾個(gè);次數(shù))

    2

    第9題:過濾出/etc/services 文件包含3306和1521兩數(shù)字所在行號(hào)的內(nèi)容

    [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支持高級(jí)正則(公雞里的戰(zhàn)斗機(jī))

    [root@oldboyedu01-nb oldboy]#

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

    單引號(hào) 所見即所得 吃啥吐啥

    雙引號(hào) 里面的特殊符號(hào)會(huì)被解析

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

    hello lls $LANG $(hostname) pwd

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

    相關(guān)推薦

    聯(lián)系我們

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