马哥教育网络班20期+第二周博客作业

1.Linux上的文件管理类命令 
2.bash命令学习总结 
3.bash命令实例 
4.元数据与时间戳 
5.命令别名 
6.练习题6~12


1.Linux上的文件管理类命令

       Linux上的文件管理类命令可分为查看类、目录管理类、权限管理类、文本处理类。

1.1 查看类命令

ls: 用于显示目录 
用法: ls [OPTION]… [FILE]… 
选项: 
       -a: 显示所有文件包括隐藏文件 
       ll : 显示目录详细信息

[root@MyCloudServer ~]# ls /usr  
bin  etc  games  include  lib  lib64  libexec  local  sbin  share  src  tmp

pwd: 显示当前工作目录 
用法: pwd [DIR]…

[root@MyCloudServer ~]# pwd
/root

cat: 用于察看文本内容 
用法: cat [OPTION]… [FILE]…

[root@MyCloudServer ~]# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m

more: 与cat命令相似,逐页显示文本 
用法: more [OPTION]… [FILE]…

[root@MyCloudServer etc]# more yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
--More--(91%)

less: 与more命令相似,不同的是可往回浏览 
用法: less [OPTION]… [FILE]…

[root@MyCloudServer etc]# less yum.conf
#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
(END)

head: 从头开始显示文本内容,默认前10行 
用法:* head [OPTION]… [FILE]… 
选项: 
        -c #: 指定获取前#字节 
        -n #: 指定获取前#行

[root@MyCloudServer etc]# head -n 5 yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log

tail: 与head相似,从尾部开始显示文本内容 
用法: tail [OPTION]… [FILE]… 
选项: 
        -c #: 指定获取前#字节 
        -n #: 指定获取前#行 
        -f : 跟踪显示文件新追加的内容

[root@MyCloudServer etc]# tail -n 5 yum.conf
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

echo: 将内容输出到屏幕

[root@MyCloudServer etc]# echo yum.conf
yum.conf

1.2 目录及文件管理类命令

cd: 可用于目录之间的切换 
用法: cd [DIR]… 
选项: 
        cd 或 cd ~: 回当前用户主目录 
        cd ~USERNAME: 切换指定用户目录 
        cd -:在上一个目录和当前目录之间来回切换 在上一个目录和当前目录之间来回切换

[root@MyCloudServer etc]# cd /opt
[root@MyCloudServer opt]#

mkdir: 用于创建目录 
用法: mkdir [DIR]… 
选项: 
        -p: 由于创建多级目录

[root@MyCloudServer tmp]# mkdir c/d
mkdir: cannot create directory `c/d': No such file or directory
[root@MyCloudServer tmp]# mkdir -p c/d

rmdir:删除空目录 
用法: rmdir [DIR]…

[root@MyCloudServer tmp]# rmdir c/d

cp:用于复制文件或目录到指定位置 
用法: cp [OPTION]… /PATH/[DIR or FILE]… /PATH/ 
选项: 
        -r: 递归复制目录及内部的所有内容 
        -f: –force

[root@MyCloudServer tmp]# cp /etc/yum.conf /tmp

mv:用于移动文件或目录到指定位置,可以将文件或目录重命名 
用法: mv /PATH/[DIR or FILE]… /PATH/

[root@MyCloudServer tmp]# mv 1 a/b
[root@MyCloudServer tmp]# mv a/b/1   a/b/2    #重命名

rm: 删除命令 
用法: mv [OPTION]… /PATH/[DIR or FILE] 
选项: 
        -r: 递归删除目录及内部的所有内容 
        -f: –force

[root@MyCloudServer tmp]# rm -rf c/4

1.3 权限管理类

chmod:用于修改文件或目录权限 
用法: chmod [OPTION]… MODE[,MODE]… FILE… 
MODE: 
rwx  111  7 r–  100  4 –x  001  1 
rw-  110  6 -wx  011 3 —  000  0 
r-x  101   5 -w-  010  2

[root@MyCloudServer tmp]# ll
total 12
drwxr-xr-x  3 root root 4096 Jun 19 07:06 a
drwxr-xr-x  2 root root 4096 Jun 19 07:11 c
-rw-r--r--  1 root root  969 Jun 19 07:16 yum.conf
-rw-------. 1 root root    0 Dec 21  2011 yum.log
[root@MyCloudServer tmp]# chmod 111 yum.log
[root@MyCloudServer tmp]# ll
total 12
drwxr-xr-x  3 root root 4096 Jun 19 07:06 a
drwxr-xr-x  2 root root 4096 Jun 19 07:11 c
-rw-r--r--  1 root root  969 Jun 19 07:16 yum.conf
---x--x--x. 1 root root    0 Dec 21  2011 yum.log

chown:修改文件或目录的属主,属组 
chown [OPTION]… [OWENER]:[GROUP] FILE… 
用法: 
选项: 
       -R: 递归

[root@MyCloudServer tmp]# chown CentOS:CentOS a
[root@MyCloudServer tmp]# ll
total 12
drwxr-xr-x  3 CentOS CentOS 4096 Jun 19 07:06 a
drwxr-xr-x  2 root   root   4096 Jun 19 07:11 c
-rw-r--r--  1 root   root    969 Jun 19 07:16 yum.conf
---x--x--x. 1 root   root      0 Dec 21  2011 yum.log

1.4 文本处理类

cut: 从文本每一行上移除部分内容,选择性显示结果 
用法: cut [OPTION]… [FILE]… 
选项: 
        -d DELIMITER: 指明分隔符 
        -f FILEDS: 
                #: 第#个字段 
               #,#[,#]:离散的多个字段,例如1,3,6 
               #-#: 连续的多个字段,例如1-6 
               混合使用:1-3,7

[root@MyCloudServer ~]# cut -d: -f 1 /etc/passwd
root
bin
daemon
adm
lp
sync

wc:统计指定文本的行数、字节数、字数,并将结果显示输出 
用法: wc [OPTION]… [FILE]… 
选项: 
        -l : 统计行数 
        -w: 统计单词数 
        -c: 统计字节数

[root@MyCloudServer ~]# wc -l /etc/passwd
20 /etc/passwd
[root@MyCloudServer ~]# wc -w /etc/passwd
26 /etc/passwd
[root@MyCloudServer ~]# wc -c /etc/passwd
898 /etc/passwd

sort:帮助我们将不同数据类型排序 
用法: wc [OPTION]… [FILE]… 
选项: 
        -f: 忽略字符大小写 
        -r: 逆序 
        -t DELIMITER: 字段分隔符 
        -k #: 以指定字段排序 
        -n: 以数值大小排序 
        -u: 排序后去重

[root@MyCloudServer ~]# sort -f -r /etc/passwd
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
saslauth:x:499:499:"Saslauthd user":/var/empty/saslauth:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
postfix:x:89:89::/var/spool/postfix:/sbin/nologin

uniq: 显示或删除重复的行 
用法: uniq [OPTION]… [FILE]… 
选项: 
        -c: 显示每行重复出现的次数; 
        -d: 仅显示重复过的行; 
        -u: 仅显示不曾重复的行;

[root@MyCloudServer tmp]# uniq -u 1
b
c
d
[root@MyCloudServer tmp]# uniq -d 1
a
e

2.bash命令学习总结

bash的基础特性:

2.1、命令补全 
        bash执行命令分为内建命令与外部命令 
2.2、命令历史:history

[root@MyCloudServer tmp]# history
1  yum install wget -y
2  ping baidu.com
...
341  tree mylinux
342  history

CTRL+R:快速搜索历史命令

(reverse-i-search)`rm': rm -rf mylinux

快速重复执行上一条命令 
       有 4 种方法可以重复执行上一条命令: 
       使用上方向键,并回车执行。 
       按 !! 并回车执行。 
       输入 !-1 并回车执行。 
       按 Ctrl+P 并回车执行 
。 
如果你想清除所有的命令历史: history -c

2.3、路径补全:Tab 
直接补全:所需补全的内容为唯一时,直接补全;如果内容不为唯一时,再按一次Tab给出列表

2.4、命令行展开: 
~ :展开为用户的主目录 
~ HOMENAME:展开指定用户的家目录 
{}:以逗号分隔,并展开为多个路径

2.5、命令的执行状态结果 
       成功:0 
       失败:1-255 
       echo $?:输出状态结果 
        程序执行的结果有两类:返回值与执行状态结果。

2.6、命令别名:alias 
详情见 5.命令别名

2.7、glob

golb用于实现bash文件名的“通配”

       *:表示任意数量个字符 
       ?:表示一个字符 
       []:指定[]范围内的字符 
       [^]:指定[^]范围外的字符 
              [^0-9a-z]:表示除0-9,a-z,用来表示特殊字符

专用字符集 
       [:digit:]:0-9 
       [:lower:]:任意小写字母 
       [:upper:]:任意大写字母 
       [:alpha:]:任意大小写字母 
       [:alnum:]:任意数字或字母 
       [:space:]:空格 
       [:punct:]:标点符号

2.8、I/O重定与管道

I/0重定分为输入(Input)与输出(Output)重定

输入重定的用法: 
COMMAND < FILE:从命令从文件中读入

[root@MyCloudServer tmp]# cat < 2
cat /etc/passwd

COMMAND << EOF:从命令行输入直到匹配到EOF为止

[root@MyCloudServer tmp]# cat << EOF
> /etc/passwd
> EOF
/etc/passwd

输出重定的用法: 
COMMAND > FILE:将COMMAND命令的输出到FILE中,如果FILE不为空,则清空FILE后再写入

[root@MyCloudServer tmp]# cat 2
HI~
[root@MyCloudServer tmp]# cat 1 > 2
[root@MyCloudServer tmp]# cat 2
HELLO WORLD~

COMMAND >> FILE:将COMMAND命令的输出追加到FILE原有信息后

[root@MyCloudServer tmp]# cat 1 >> 2 
[root@MyCloudServer tmp]# cat 2
HELLO WORLD~
HELLO WORLD~

2.9、配置文件

按生效范围可分为两类: 
全局配置: 
       /etc/profile 
       /etc/bashrc 
个人配置: 
       ~/.bash_profile 
       ~/.bashrc

按功能划分可分为两类: 
profile:为交互式提供配置 
       (1) 定义环境变量 
       (2) 运行脚本或命令 
生效顺序:/etc/profile –> /etc/profile.d/*.sh –> ~/.bash_profile –> ~/.bashrc –> /etc/bashrc

bashrc:为非交互式提供配置 
       (1) 定义命令别名 
       (2) 定义本地变量 
生效顺序:~/.bashrc –> etc/bashrc –> etc/profile.d/*.sh

2.10、运算符

常用的运算: 
+,-,, /, %, *

算术运算的实现: 
let var = 算术表达式

[root@MyCloudServer tmp]# cat 3
#!/bin/bash
#
let test=1+3
echo $test
[root@MyCloudServer tmp]# ./3
4

运算的测试类型: 
       数据型: 
              -gt:大于 
              -ge:大于等于 
              -lt:小于 
              -le:小于等于 
              -eq:等于 
              -ne:不等于 
       字符型: 
              ==:等于 
              >:大于 
              <:小于 
              !=:不等于 
              =~:左侧字符能否匹配到右侧字符 
              -z:是否为空 
              -n:是否为不空

2.11、条件测试与逻辑运算

条件测试的用法: 
test EXPRESSION 
[ EXPRESSION ] 
[[ EXPRESSON ]]

[root@MyCloudServer tmp]# [ -a 1 ]&& echo yes || echo no
yes

文件测试: 
       存在性测试 
              -a FILE: 
              -e FILE: 
       存在及类型测试 
              -b FILE:存在且为块文件 
              -c FILE:存在且为字符型设备文件 
              -d FILE:存在且为为目录文件 
              -f FILE:存在且为为普通文件 
              -h FILE:存在且为符号链接文件 
              -p FILE:存在且为命令管道文件 
              -S FILE:存在且为套接字文件 
       文件权限测试: 
              -r FILE:存在且为可读 
              -w FILE:存在且为可写 
              -x FILE:存在且为可执行 
       文件特殊权限: 
              -g FILE:存在且为sgid 
              -u FILE:存在且为suid 
              -k FILE:存在且为sticky 
       文件大小测试: 
              -s FILE:存在且为非空

逻辑运算的两种方式: 
第一种方式: 
COMMAND1 && COMMAND2 
COMMAND1 || COMMAND2 
! COMMAND

[root@MyCloudServer tmp]# [ -r 1 ] && [ -f 1 ]
[root@MyCloudServer tmp]# echo $?
0

第二种方式: 
EXPRESSION1 -a EXPRESSION2 
EXPRESSION1 -o EXPRESSION2 
!EXPRESSION

[root@MyCloudServer tmp]# [ -r 1 -a -f 1  ]
[root@MyCloudServer tmp]# echo $?
0

2.12、文件查找

文件查找可分类为两类: 
       非实时查找:local 
              依赖于事先构建的索引,需要自动更新或手工更新DB,索引的构建需要遍历整个根文件系统,极耗资源

       实时查找:find 
              通过遍历指定路径来完成查找

find的用法: 
find [OPTION]… [PATH]…[EXPRESSION]

根据文件名: 
       -name "NAME"

[root@MyCloudServer tmp]# find -name linuxtest
./linuxtest

       -iname "NAME":不区分大小写

[root@MyCloudServer tmp]# find -iname linuxtest
./linuxtest
./LiNuxTesT

根据属主、属组查找 
       -user USERNAME:属主 
       -group GROUPNAME:属组 
       -uid UID:UID号 
       -gid GID:GID号 
       -nouser:查找没有属主的文件 
       -nogroup:查找没有属组的文件

可以用2.11 条件测试与逻辑运算里的文件测试与逻辑测试的相关参数

2.13、脚本与变量

变量的类型: 
强类型:定义变量时必须指定类型,参与运算必须符合类型要求,调用未声明变量会产生错误 
弱类型:无须指定类型,默认为字符型,参与运算里会自动隐式类型转换

变量的赋值: 
(1) 可以直接赋值:NAME = "VALUE" 
(2) 可以引用变量:NAME = "$VALUE" 
(3) 可以引用命令:NAME = 'COMMAND' , NAME = $(COMMAND) 
强引用 '' :其中变量不会被引用,保持原字符串 
弱引用 "" : 其中变量会被替换成变量的值 
set:显示所有定义的变量 
unset NAME:销毁指定的变量 
$[1,2..]:调用对应参数 
$0:命令本身

只读变量: 
       readonly name 
       declare -r name

脚本:

[root@MyCloudServer tmp]# ls
1  3.sh  a_d  b_d        LiNuxTesT  tree-1.5.3-3.el6.x86_64.rpm  yum.log
2  a_c   b_c  linuxtest  mylinux    yum.conf
[root@MyCloudServer tmp]# ./3.sh      #执行脚本
yes
[root@MyCloudServer tmp]# cat 3.sh    #察看脚本内容
#!/bin/bash
#
[ -a 1 ]&& echo yes || echo no

3.bash使用实例

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

[root@MyCloudServer tmp]# mkdir {a,b}_{c,d}
[root@MyCloudServer tmp]# ls
1  a_c  a_d  b_c  b_d  yum.conf  yum.log

(2) 创建/tmp/mylinux目录下的 
mylinux/ 
bin 
boot 
        grub 
dev 
etc 
        re.d 
                init.d 
        sysconfig 
                network-scripts 
lib 
        modules 
lib64 
proc 
sbin 
sys 
tmp 
usr 
        local 
                bin 
                sbin 
var 
        lock 
        log 
        run

[root@MyCloudServer tmp]# rm -rf mylinux
[root@MyCloudServer tmp]# mkdir -p mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-script},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var/{lock,log,run}}
[root@MyCloudServer tmp]# tree mylinux
mylinux
├── bin
├── boot
│   └── grub
├── dev
├── etc
│   ├── rc.d
│   │   └── init.d
│   └── sysconfig
│       └── network-script
├── lib
│   └── modules
├── lib64
├── proc
├── sbin
├── sys
├── tmp
├── usr
│   └── local
│       ├── bin
│       └── sbin
└── var
    ├── lock
    ├── log
    └── run

4.元数据与时间戳

4.1 元数据

ll:用来描述一个文件的系统特征,如访问权限,文件数据分布等。 
用法: ll [FILE]

[root@MyCloudServer tmp]# ll 1
-r---w---x  1 root root 13 Jun 19 15:52 1

-r—w—x 1 root root 13 Jun 19 15:52 1 便是文件1的元数据信息 
-  :文件类型,参考2.11 条件测试与逻辑运算里的文件测试 
r– :属主权限,r为可读 
w–:属组权限, w为可写 
–x :其它,x为可执行 
1    :表示硬链接数量 
root:第一个root表示属主 
root:第二个root表示属组 
13   :为文件d大小 
Jun 19 15:52:为时间 
1    :最后一位表示文件名

时间戳:通常是一个字符序列,唯一标识某一刻的时间。

4.2 时间戳

第一类系统时间:

date:显示或修改系统时间 
用法: date [OPTION]… [+FORMAT] 或者 date [-u|–utc|–universal] [MMDDhhmm[[CC]YY][.ss]]

[root@MyCloudServer tmp]# date
Sun Jun 19 17:53:43 CST 2016
[root@MyCloudServer tmp]# date '+%D'
06/19/16
[root@MyCloudServer tmp]# date '+%F'
2016-06-19
[root@MyCloudServer tmp]# date '+%T'
17:56:55

[root@MyCloudServer tmp]# date -s 20160619 #设置成20160619  
[root@MyCloudServer tmp]# date -s 10:13:10 #设置具体时间
[root@MyCloudServer tmp]# date -s "10:13:10 20160619" #设置全部时间
[root@MyCloudServer tmp]# ntpdate xxx.xxx.xxx.xxx #同步xxx.xxx.xxx.xxx IP地址的时间

第二类文件时间:

stat:显示文件状态 
用法: stat [FILE]…

[root@MyCloudServer tmp]# stat 1
File: `1'
Size: 13              Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 259795      Links: 1
Access: (0421/-r---w---x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-06-19 18:12:50.465801870 +0800
Modify: 2016-06-19 18:12:50.465801870 +0800
Change: 2016-06-19 18:12:50.465801870 +0800

touch: 可用于修改时间戳 
用法: touch [OPTION]… [FILE]… 
选项: 
     -a: 改读取文件内容变atime 
     -m: 改变mtime 
     -t STAMP: 指明要变为的时间 
     -c: 如果文件不存在,则不予创建

[root@MyCloudServer tmp]# touch -t 201411121249.50 -a 1
[root@MyCloudServer tmp]# stat 1
  File: `1'
  Size: 13              Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 259795      Links: 1
Access: (0421/-r---w---x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-11-12 12:49:50.000000000 +0800
Modify: 2016-06-19 18:12:50.465801870 +0800
Change: 2016-06-19 18:22:30.231802498 +0800

5.命令别名

5.1 alias显示当前进程可用所有别名列表 
用法: alias

[root@MyCloudServer tmp]# alias
alias cp='cp -i'
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'

5.2 定义别名 
用法: alisa NAME='COMMAND'

[root@MyCloudServer tmp]# alias test='ls /tmp'
[root@MyCloudServer tmp]# test
1  a_c  a_d  b_c  b_d  mylinux  tree-1.5.3-3.el6.x86_64.rpm  yum.conf  yum.log

Note:在命令行中定义的别名,仅对当前shell进程有效 
       仅对当前用户:~/.bashrc 
       对所有用户有效:/etc/bashrc

bash进程重新读取配置文件; 
       source /PATH/TO/CONFIG_FILE 
       ./PATH/TO/CONFIG_FILE

5.3 定义别名并在命令中引用另一个命令的执行结果

[root@MyCloudServer tmp]# ls mydata
ls: cannot access mydata: No such file or directory
[root@MyCloudServer opt]# alias test='cd /tmp/mydata >>/dev/null 2>&1'
[root@MyCloudServer tmp]# test
[root@MyCloudServer tmp]# [ $? == 0 ]&&echo exits||echo no exits
no exits

6.习题6~12

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

[root@MyCloudServer var]# ls
cache  empty  l.123p  l23.p   lib    lock  mail  opt       run    tmp
db     games  l.231p  l342.p  local  log   nis   preserve  spool  yp
[root@MyCloudServer var]# ls -d /var/l*[0-9]*[[:lower:]]
/var/l.123p  /var/l.231p  /var/l23.p  /var/l342.p

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

[root@MyCloudServer etc]# touch 123sf
[root@MyCloudServer etc]# touch 12345
[root@MyCloudServer etc]# mkdir 23456
[root@MyCloudServer etc]# mkdir 234sf
[root@MyCloudServer etc]# ls -d /etc/[0-9]*[^0-9]
/etc/123sf  /etc/234sf

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

[root@MyCloudServer etc]# touch 1fdsf
[root@MyCloudServer etc]# mkdir 2f123
[root@MyCloudServer etc]# ls -d /etc/[^a-zA-Z][[:alpha:]]*
/etc/1fdsf  /etc/2f123

6.9、在/tmp目录下创建以tfile开头,后面跟当前日期时间的文件,文件名如tfile-2016-5-27-09-32-22

[root@MyCloudServer etc]# touch /tmp/tfile-`date "+%Y-%m-%d-%H-%M-%S"`
[root@MyCloudServer etc]# ls /tmp
2  3.sh  a_d  b_d     linuxtest  mylinux  tfile-2016-06-19-19-38-29    yum.conf
3  a_c   b_c  l324.p  LiNuxTesT  stat     tree-1.5.3-3.el6.x86_64.rpm  yum.log

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

[root@MyCloudServer etc]# cp -r /etc/p*[^0-9] /tmp/mytest1
[root@MyCloudServer etc]# ls /tmp/mytest1
pam.d   passwd-  plymouth  popt.d   ppp       profile    protocols
passwd  pki      pm        postfix  printcap  profile.d

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

[root@MyCloudServer etc]# cp -r /etc/*.d /tmp/mytest2
[root@MyCloudServer etc]# ls /tmp/mytest2
bash_completion.d  dracut.conf.d  makedev.d   profile.d  rc3.d  rc.d        sudoers.d
chkconfig.d        init.d         modprobe.d  rc0.d      rc4.d  rsyslog.d   xinetd.d
cron.d             ld.so.conf.d   pam.d       rc1.d      rc5.d  rwtab.d     yum.repos.d
depmod.d           logrotate.d    popt.d      rc2.d      rc6.d  statetab.d

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

[root@MyCloudServer etc]# cp /etc/[l,m,n]*.conf /tmp/mytest3
[root@MyCloudServer etc]# ls /tmp/mytest3
ld.so.conf  libaudit.conf  libuser.conf  logrotate.conf  mke2fs.conf  nsswitch.conf

原创文章,作者:laiwen2007,如若转载,请注明出处:http://www.178linux.com/18611

(0)
上一篇 2016-06-19 11:32
下一篇 2016-06-19 17:46

相关推荐

  • Linux用户和组管理

    Linux用户和组管理 Username / UID 管理员:root,0 普通用户 : 1–65535 系统用户 :系统已经已经存在专门用来对系统服务或者系统资源进行管理的 1–499(CentOS 6.X) 1–999 (CentOS 7.X) 登录用户:平时专门做系统管理的用户 500+ (CentOS 6.X) 1000+ (CeentOS 7.X)…

    Linux干货 2017-04-01
  • Linux系统操作练习-2

    1、显示当前系统上root、fedora或user1用户的默认shell: 2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello(): 3、使用echo命令输出一个绝对路径,使用grep取出基名;扩展:取出路径名: 扩展: 4、找出ifconfig命令结果中的1-255之间的数字: 5、挑战题:写一个…

    2017-11-25
  • 有关shell脚本

    SHELL脚本 在Linux运维工作中有着大量的重复性质的工作,比如同时给很多台的服务器备份,查看多台的内存情况,等等。这样的情况下总不能一个一个服务器自己去看,那样耗时,费力,还容易出错。所以编写程序来做这些事情就成了必要的工作。而SHELL就是完成这项工作的。   脚本第一行的开头写上#!/bin/bash 这是属于格式性质的,作用在于加上执行…

    2017-08-12
  • 无插件Vim编程技巧

    相信大家看过《简明Vim教程》也玩了《Vim大冒险》的游戏了,相信大家对Vim都有一个好的入门了。我在这里把我日常用Vim编程的一些技巧列出来给大家看看,希望对大家有用,另外,也是一个抛砖引玉的过程,也希望大家把你们的技巧跟贴一下,我会更新到这篇文章中。另外,这篇文章里的这些技巧全都是vim原生态的,不需要你安装什么插件。我的Vim的版本是7.2。 浏览代码…

    Linux干货 2016-08-15
  • 生产环境模拟实现keepalived+Nginx调度器+httpd的高可用集群

    具体过程是用Nginx做负载均衡,可以将Nginx和主机放在同一台机子上,也可以分开放置,只不过分开的话要指明RS是Nginx的主机地址。至于直接将虚拟地址配置在Nginx主机上我暂时还未成功 下面附上我的双主模型的主keepalived服务器的配置 ! Configuration File for keepalive…

    Linux干货 2016-11-11
  • Linux第六周学习博客作业

    对第六周学习的内容进行总结

    2018-01-14

评论列表(5条)

  • zhutoyearn
    zhutoyearn 2016-06-19 21:42

    挺好的,参考你的写一个

  • zhutoyearn
    zhutoyearn 2016-06-19 22:06

    cp:用于复制文件或目录到指定位置
    用法: rmdir [OPTION]… /PATH/[DIR or FILE]… /PATH/

    用法这里写成rmdir了

    • laiwen2007
      laiwen2007 2016-06-20 07:25

      @zhutoyearn恩,多谢指教

  • 马哥教育
    马哥教育 2016-06-21 22:42

    写的很好,非常棒,可以在多关注一些排版,如果能在列举一些命令的常用选项那就更好了,加油!

  • Net20_天意
    Net20_天意 2016-06-22 14:32

    值得借鉴~~~特别好