一、描述Linux发行版的系统目录名称命名规则以及用途

1、文件名命名规则

(1).文件名最长255字节

(2).包括路径在内的文件名称最长4095个字节

(3).除了斜扛和NUL,所有字符都有效。但不推荐使用特殊字符作为目录名与文件名。

(4).标准的Linux文件系统,对文件名称的大小写敏感

2、Linux文件系统结构

/boot :引导文件存放目录,内核文件(vmlinuz)、引导加载器(bootloader,grub)都存放在此目录

/bin :所有用户使用的基本命令;不能关联至独立分区,OS启动时即会用到的程序

/sbin :管理类的基本命令;不能关联至独立分区,OS启动时即会用到的程序

/lib :启动时程序依赖的基本共享库文件以及内核模块文件(/lib/modules)

/lib64 :专用于x86_64系统上的辅助共享库文件的存放位置

/etc :配置文件目录

/home :普通用户家目录

/root :管理员的家目录

/media :便携式移动设备挂载点

/mnt :临时文件系统挂载点

/dev :设备文件及特殊文件存储位置

/opt :第三方应用程序的安装位置

/srv :系统上运行的服务用到的数据

/tmp :临时文件存储位置

/usr :操作系统软件资源存放位置
  bin :保证系统拥有完整功能而提供的应用程序
  sbin :管理类命令
  lib :32位系统使用 
  lib64 :只存在64位系统
  include :C程序的头文件
  share :结构化独立的数据,如doc,man等
  local :第三方应用程序的安装位置

/var :经常发生变化的文件的存放位置
  cache :应用程序缓存数据目录
  lib :应用程序状态信息数据
  local :专用于为 /usr/local 下的应用程序存储可变数据
  lock :锁文件
  log :日志目录及文件
  opt :专用于 /opt 下的应用程序存储可变数据
  run :运行中的进程想着数据,通常用于存储进程pid文件
  spool :应用程序数据池
  tmp :保存系统两次重启之间产生的临时数据

/proc :用于输出内核与进程信息相关的虚拟文件系统,也叫伪文件系统,由内核参数映射而来

/sys :用于输出当前系统上硬件设备相关信息的虚拟文件系统,内核中与硬件设备相关的信息映射

/selinux :selinux(security enhanced Linux),selinux相关的安全策略等信息的存储位置

3、Linux上的应用程序组成部分

二进制程序:/bin , /sbin , /usr/bin , /usr/sbin , /usr/local/bin , /usr/local/sbin

库文件:/lib , /lib64 , /usr/lib , /usr/lib64 , /usr/local/lib , /usr/local/lib64

配置文件:/etc , /etc/DIRECTROY , /usr/local/etc

帮助文件:/usr/shareman , /usr/share/doc , /usr/local/share/man , /usr/local/share/doc

4、CentOS7目录变化

[root@centos7 ~]# ll -d /bin /sbin /lib /lib64
lrwxrwxrwx. root root Oct : /bin -> usr/bin
lrwxrwxrwx. root root Oct : /lib -> usr/lib
lrwxrwxrwx. root root Oct : /lib64 -> usr/lib64
lrwxrwxrwx. root root Oct : /sbin -> usr/sbin

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

1、元数据信息包含:
  File:文件名
  Size:文件大小(单位:B)
  Blocks:文件所占块个数
  IO Block:每个数据块的大小(单位:B)
  regular file:普通文件(此处显示文件的类型)
  Inode:文件的Inode号,文件的索引节点号
  Links:硬链接次数
  Access:权限
  Uid:(属主id/属主名)
  Gid:(属组id/属组名)
  Context:文件所在的环境
  Access:访问时间 access time (atime)
  Modify:修改时间 modification time (mtime)
  Change:改变时间,元数据改动时间 change time (ctime)

2、查看元数据信息可用 stat 命令

[root@centos6 ~]# stat /etc/fstab
File: `/etc/fstab'
Size: Blocks: IO Block: regular file
Device: 802h/2050d Inode: Links:
Access: (/-rw-r--r--) Uid: ( / root) Gid: ( / root)
Access: -- ::27.739118186 -
Modify: -- ::14.061610677 -
Change: -- ::25.102883839 -

3、修改文件的时间戳可用touch命令

 touch [OPTION]... FILE...

   -a  仅改变 atime和ctime

   -m 仅改变 mtime和ctime

   -t   [[CC]YY]MMDDhhmm[.ss] 指定atime和mtime的时间戳

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

[root@centos7 link]# touch a.txt
[root@centos7 link]# stat a.txt
File: ‘a.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 805h/2053d Inode: 87 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-11-07 17:07:54.025158474 +0800
Modify: 2019-11-07 17:07:54.025158474 +0800
Change: 2019-11-07 17:07:54.025158474 +0800
Birth: -
[root@centos7 link]# touch -a a.txt
[root@centos7 link]# stat a.txt
File: ‘a.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 805h/2053d Inode: 87 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-11-07 17:08:06.209629645 +0800
Modify: 2019-11-07 17:07:54.025158474 +0800
Change: 2019-11-07 17:08:06.209629645 +0800
Birth: -
[root@centos7 link]# touch -m a.txt
[root@centos7 link]# stat a.txt
File: ‘a.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 805h/2053d Inode: 87 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-11-07 17:08:06.209629645 +0800
Modify: 2019-11-07 17:08:41.346981184 +0800
Change: 2019-11-07 17:08:41.346981184 +0800
Birth: -

三、总结软链接和硬链接区别,并用实例操作说明

1、硬链接

 创建硬链接会增加额外的记录项以引用文件

 对应于同一文件系统上一个物理文件

 不能对目录使用,每个目录引用相同的inode号

 创建硬链接时链接数递增

 删除文件时,链接数递减,当链接数为零时,该文件被删除

 不能跨越驱动器或分区

 语法:ln filename [linkname]

2、软链接

 一个符号链接指向另一个文件

 一个符号链接的内容是它引用文件的名称

 可以对目录进行

 可以跨分区

 指向的是另一个文件的路径;其大小为指向的路径字符串长度;不增加或减少目标文件inode的引用计数

 创建软链接时,如果原始文件要写相对路径,相对路径一定是相对于软链接的相对路径而不是相对于当前工作目录

 语法:ln -s filename [linkname]

[root@centos7 link]# ln /etc/fstab /data/link/fstab.link    #硬链接不能跨分区
ln: failed to create hard link ‘/data/link/fstab.link’ => ‘/etc/fstab’: Invalid cross-device link
[root@centos7 link]# ln -s /etc/fstab /data/link/fstab.slink #软链接可以跨分区
[root@centos7 link]# cp /etc/fstab ./
[root@centos7 link]# ln fstab fstab.link
[root@centos7 link]# ln -s fstab fstab.slink2
[root@centos7 link]# ls -il #硬链接会增加链接数,软链接不会
total
-rw-r--r-- root root Nov : fstab
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# ls -il
#删了源文件时,硬链接数递减,且硬链接文件还可用,软链接则失败
total
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# cat fstab.link
#
# /etc/fstab
# Created by anaconda on Mon Oct ::
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(), findfs(), mount() and/or blkid() for more info
#
UUID=4c35d267-ce4a-4ede-add4-64da62067bfb / xfs defaults
UUID=71e72e0a--4edd-b321-fef6ab4ba406 /boot xfs defaults
UUID=67285b9c-6dea--b48b-d6103ba3cfcb /data xfs defaults
UUID=0da7a17b-95d7-4c1a-9fe3-f1969b73df9f swap swap defaults
[root@centos7 link]# cat fstab.slink2
cat: fstab.slink2: No such file or directory
[root@centos7 link]# mkdir dir1
[root@centos7 link]# ls -il
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# ln -s fstab dir1/fstab.slink
#创建软链接时相对当前工作目录,发现软链接不可用
[root@centos7 link]# ls -il dir1
total
lrwxrwxrwx root root Nov : fstab.slink -> fstab
[root@centos7 link]# cat dir1/fstab.slink
cat: dir1/fstab.slink: No such file or directory
[root@centos7 dir1]# cd dir1/
[root@centos7 dir1]# ls -il
total
lrwxrwxrwx root root Nov : fstab.slink -> fstab
[root@centos7 dir1]# ln -s ../fstab fstab.slink2 #进入目录再创建
[root@centos7 dir1]# ll
total
lrwxrwxrwx root root Nov : fstab.slink -> fstab #不可用
lrwxrwxrwx root root Nov : fstab.slink2 -> ../fstab #可用
[root@centos7 dir1]# mkdir dir2
[root@centos7 dir1]# touch dir2/{f1,f2}
[root@centos7 dir1]# tree
.
├── dir2
│   ├── f1
│   └── f2
├── etc.slink -> /etc
├── fstab
└── fstab.slink2 -> ../fstab directories, files
[root@centos7 dir1]# ln -s dir2 dir2.slink #创建目录软链接
[root@centos7 dir1]# ll
total
drwxr-xr-x root root Nov : dir2
lrwxrwxrwx root root Nov : dir2.slink -> dir2
lrwxrwxrwx root root Nov : etc.slink -> /etc
-rw-r--r-- root root Nov : fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> ../fstab
[root@centos7 dir1]# ls dir2.slink/
f1 f2
[root@centos7 dir1]# rm -rf dir2.slink/ #删除目录软链接时,如果带了/,是删除目录内容,而不是删除软链接本身
[root@centos7 dir1]# ll
total
drwxr-xr-x root root Nov : dir2
lrwxrwxrwx root root Nov : dir2.slink -> dir2
lrwxrwxrwx root root Nov : etc.slink -> /etc
-rw-r--r-- root root Nov : fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> ../fstab
[root@centos7 dir1]# ls dir2.slink/
[root@centos7 dir1]# ll
total
drwxr-xr-x root root Nov : dir2
lrwxrwxrwx root root Nov : dir2.slink -> dir2
lrwxrwxrwx root root Nov : etc.slink -> /etc
-rw-r--r-- root root Nov : fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> ../fstab
[root@centos7 dir1]# rm -rf dir2.slink #不带/,删除软链接本身
[root@centos7 dir1]# ll
total
drwxr-xr-x root root Nov : dir2
lrwxrwxrwx root root Nov : etc.slink -> /etc
-rw-r--r-- root root Nov : fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> ../fstab

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

1、pwd:显示当前工作目录

 选项:

  -P 显示真实物路径

  -L 显示链接路径(默认)

[root@centos7 dir1]# ln -s /etc etc.slink  #创建/etc目录的软链接
[root@centos7 dir1]# ll
total
lrwxrwxrwx root root Nov : etc.slink -> /etc
lrwxrwxrwx root root Nov : fstab.slink2 -> ../fstab
[root@centos7 dir1]# cd etc.slink/
[root@centos7 etc.slink]# pwd
/data/link/dir1/etc.slink
[root@centos7 etc.slink]# pwd -P
/etc
[root@centos7 etc.slink]# pwd -L
/data/link/dir1/etc.slink

2、cd:切换目录

 可以使用相对路径也可使用绝对路径:cd link/dir1 或 cd /data/link/dir1

 切换至父目录:cd ..

 切换至当前用户的主目录:cd

 切换至之前的工作目录:cd -

[root@centos7 dir1]# pwd
/data/link/dir1
[root@centos7 dir1]# cd ..
[root@centos7 link]# pwd
/data/link
[root@centos7 link]# cd -
/data/link/dir1
[root@centos7 dir1]# pwd
/data/link/dir1
[root@centos7 dir1]# cd
[root@centos7 ~]# pwd
/root

3、ls:列出当前目录内容或指定目录

 用法:ls [OPTIONS] [files_or dirs]

 选项:

    -a 显示所有文件,包含隐藏文件,同时显示 . 与 ..

    -A 显示所有文件,包含隐藏文件,不显示 . 与 ..

    -R 目录递归

    -l 显示列表信息

    -d 显示目录本身

    -1 文件分行显示

    -S 按从大到小排序

    -s 显示文件块大小

    -t 按修改时间mtime排序

    -u 配合-t选项,显示并按atime从新到旧排序

    -U 按目录存放顺序显示

    -X 按文件后缀排序

    -h 配合-l选项,将文件大小转换成易读形式

[root@centos7 link]# ls -a
. .. dir1 fstab fstab.link fstab.slink fstab.slink2
[root@centos7 link]# ls -A
dir1 fstab fstab.link fstab.slink fstab.slink2
[root@centos7 link]# ls -R
.:
dir1 fstab fstab.link fstab.slink fstab.slink2 ./dir1:
dir2 etc.slink fstab fstab.slink2 ./dir1/dir2:
[root@centos7 link]# ls -l
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# ls -
dir1
fstab
fstab.link
fstab.slink
fstab.slink2
[root@centos7 link]# ls -dl dir1
drwxr-xr-x root root Nov : dir1
[root@centos7 link]# ls -S
fstab fstab.link dir1 fstab.slink fstab.slink2
[root@centos7 link]# ls -Sl
total
-rw-r--r-- root root Nov : fstab
-rw-r--r-- root root Nov : fstab.link
drwxr-xr-x root root Nov : dir1
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# ls -tl
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
[root@centos7 link]# ls -lh
total .0K
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# ls -X
dir1 fstab fstab.link fstab.slink fstab.slink2
[root@centos7 link]# ls -Xl
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
-rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab
[root@centos7 link]# ls -s
total
dir1 fstab fstab.link fstab.slink fstab.slink2
[root@centos7 link]# ls -sh
total .0K
dir1 .0K fstab .0K fstab.link fstab.slink fstab.slink2
[root@centos7 link]# ls -shl
total .0K
drwxr-xr-x root root Nov : dir1
.0K -rw-r--r-- root root Nov : fstab
.0K -rw-r--r-- root root Nov : fstab.link
lrwxrwxrwx root root Nov : fstab.slink -> /etc/fstab
lrwxrwxrwx root root Nov : fstab.slink2 -> fstab

4、stat:查看文件状态

 文件三个时间戳:

  access time  访问时间,atime,读取文件内容

  modify time  修改时间, mtime,改变文件内容(数据)

  change time  改变时间, ctime,元数据发生改变

[root@centos7 link]# stat fstab
File: ‘fstab’
Size: Blocks: IO Block: regular file
Device: 805h/2053d Inode: Links:
Access: (/-rw-r--r--) Uid: ( / root) Gid: ( / root)
Access: -- ::55.022537492 +
Modify: -- ::55.022537492 +
Change: -- ::55.022537492 +
Birth: -

5、touch:创建空文件或刷新时间

 touch [OPTION]... FILE...

   -a  仅改变 atime和ctime

   -m 仅改变 mtime和ctime

   -t   [[CC]YY]MMDDhhmm[.ss] 指定atime和mtime的时间戳

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

[root@centos7 link]# touch a.txt
[root@centos7 link]# stat a.txt
File: ‘a.txt’
Size: Blocks: IO Block: regular empty file
Device: 805h/2053d Inode: Links:
Access: (/-rw-r--r--) Uid: ( / root) Gid: ( / root)
Access: -- ::54.025158474 +
Modify: -- ::54.025158474 +
Change: -- ::54.025158474 +
Birth: -
[root@centos7 link]# touch -a a.txt
[root@centos7 link]# stat a.txt
File: ‘a.txt’
Size: Blocks: IO Block: regular empty file
Device: 805h/2053d Inode: Links:
Access: (/-rw-r--r--) Uid: ( / root) Gid: ( / root)
Access: -- ::06.209629645 +
Modify: -- ::54.025158474 +
Change: -- ::06.209629645 +
Birth: -
[root@centos7 link]# touch -m a.txt
[root@centos7 link]# stat a.txt
File: ‘a.txt’
Size: Blocks: IO Block: regular empty file
Device: 805h/2053d Inode: Links:
Access: (/-rw-r--r--) Uid: ( / root) Gid: ( / root)
Access: -- ::06.209629645 +
Modify: -- ::41.346981184 +
Change: -- ::41.346981184 +
Birth: -

6、cp:复制文件和目录cp

 选项:

    -i   覆盖前提示

    -n   不覆盖,注意两者顺序

    -r,-R 递归复制目录及内部的所有内容

    -a  归档,相当于-dR -preserv=all

    -d --no-dereference --preserv=links 不复制原文件,只复制链接名

    --preserv[=ATTR_LIST]
        mode: 权限
        ownership: 属主属组
        timestamp:
        links
        xattr
        context
        all
    -p 等同--preserv=mode,ownership,timestamp
    -v 显示详情
    -f 强制复制
    -u 只复制源比目标更新的文件或目标不存在的文件 
    -b 目标存大,覆盖前先备份,形式为filename~
    --backup=numbered 目标存在,覆盖前先备份加数字后缀

[root@centos7 dir2]# ls
[root@centos7 dir2]# cp /etc/fstab ./
[root@centos7 dir2]# ls
fstab
[root@centos7 dir2]# cp -r ../dir1 ./
[root@centos7 dir2]# ll
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
[root@centos7 dir2]# cp -i /etc/fstab ./
cp: overwrite ‘./fstab’? y
[root@centos7 dir2]# cp -n /etc/fstab ./
[root@centos7 dir2]# ll
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
[root@centos7 dir2]# cp -a /etc/fstab fstab2
[root@centos7 dir2]# ll
total
drwxr-xr-x root root Nov : dir1
-rw-r--r-- root root Nov : fstab
-rw-r--r--. root root Oct : fstab2
[root@centos7 dir2]# ll /etc/fstab fstab2
-rw-r--r--. root root Oct : /etc/fstab
-rw-r--r--. root root Oct : fstab2
[root@centos7 dir2]# cp -b /etc/fstab ./
cp: overwrite ‘./fstab’? y
[root@centos7 dir2]# ls
dir1 fstab fstab~ fstab2
[root@centos7 dir2]# cp --backup=numbered /etc/fstab ./
cp: overwrite ‘./fstab’? y
[root@centos7 dir2]# ls
dir1 fstab fstab~ fstab.~~ fstab2

7、mv:移动和重命名文件

 mv [OPTION]... [-T] SOURCE DEST
 mv [OPTION]... SOURCE... DIRECTORY
 mv [OPTION]... -t DIRECTORY SOURCE...

 常用选项:

  -i 交互式

  -f 强制

  -b 目标存在,覆盖前先备份

[root@centos7 dir2]# ls
dir1 fstab fstab~ fstab.~~ fstab2
[root@centos7 dir2]# mv fstab fstab.bak
[root@centos7 dir2]# ls
dir1 fstab~ fstab.~~ fstab2 fstab.bak
[root@centos7 dir2]# mv -i fstab2 fstab.bak
mv: overwrite ‘fstab.bak’? y
[root@centos7 dir2]# ls
dir1 fstab~ fstab.~~ fstab.bak
[root@centos7 dir2]# mv -f fstab.bak fstab
[root@centos7 dir2]# ls
dir1 fstab fstab~ fstab.~~
[root@centos7 dir2]# mv -f fstab.~~ fstab~
[root@centos7 dir2]# ls
dir1 fstab fstab~
[root@centos7 dir2]# mv -b fstab fstab~
mv: overwrite ‘fstab~’? y
[root@centos7 dir2]# ls
dir1 fstab~ fstab~~

8、rm:删除

 rm [OPTION]... FILE...

 常用选项:

  -i 交互式

  -f 强制删除

  -r 递归--no-preserve-root 删除/

[root@centos7 dir2]# rm dir1
rm: cannot remove ‘dir1’: Is a directory
[root@centos7 dir2]# rm -rf dir1
[root@centos7 dir2]# rm -i fstab~~
rm: remove regular file ‘fstab~~’? y

9、tree:显示目录树

    -d: 只显示目录

    -L level:指定显示的层级数目

    -P pattern: 只显示由指定pattern匹配到的路径

[root@centos7 link]# tree
.
├── a.txt
├── dir1
│   ├── dir2
│   ├── etc.slink -> /etc
│   ├── fstab
│   └── fstab.slink2 -> ../fstab
├── dir2
│   └── fstab~
├── fstab
├── fstab.link
├── fstab.slink -> /etc/fstab
└── fstab.slink2 -> fstab directories, files
[root@centos7 link]# tree -d
.
├── dir1
│   ├── dir2
│   └── etc.slink -> /etc
└── dir2 directories
[root@centos7 link]# tree -L
.
├── a.txt
├── dir1
├── dir2
├── fstab
├── fstab.link
├── fstab.slink -> /etc/fstab
└── fstab.slink2 -> fstab

10、mkdir:创建目录

  -p: 存在于不报错,且可自动创建所需的各目录-v: 显示详细信息

  -m MODE: 创建目录时直接指定权限

[root@centos7 link]# ls
a.txt dir1 dir2 fstab fstab.link fstab.slink fstab.slink2
[root@centos7 link]# mkdir -p dir3/d1/d2
[root@centos7 link]# ls
a.txt dir1 dir2 dir3 fstab fstab.link fstab.slink fstab.slink2
[root@centos7 link]# tree dir3
dir3
└── d1
└── d2 directories, files
[root@centos7 link]# mkdir -m dir4
[root@centos7 link]# ls -ld dir4
dr--r--r-- root root Nov : dir4

11、rmdir 删除空目录

  -p: 递归删除父空目录

  -v: 显示详细信息

[root@centos7 link]# mkdir -pv dir4/p1/p2
mkdir: created directory ‘dir4/p1’
mkdir: created directory ‘dir4/p1/p2’
[root@centos7 link]# tree dir4
dir4
└── p1
└── p2 directories, files
[root@centos7 link]# rmdir -pv dir4/p1/p2/
rmdir: removing directory, ‘dir4/p1/p2/’
rmdir: removing directory, ‘dir4/p1’
rmdir: removing directory, ‘dir4’

12、file:确定文件内容

 file [options] <filename>...

 常用选项:

  -b 列出文件辨识结果时,不显示文件名称

  -f filelist 列出文件filelist中文件名的文件类型

  -F 使用指定分隔符号替换输出文件名后默认的”:”分隔符-L 查看对应软链接对应文件的文件类型

  --help 显示命令在线帮助

[root@centos7 link]# cat a.txt
aaa
ddd
ddd
ccc
[root@centos7 link]# file a.txt
a.txt: ASCII text
[root@centos7 link]# file -b a.txt
ASCII text
[root@centos7 link]# file -F "==>" a.txt
a.txt==> ASCII text
[root@centos7 link]# file -L fstab.link
fstab.link: ASCII text
[root@centos7 link]# file -L fstab.slink
fstab.slink: ASCII text
[root@centos7 link]# file -L fstab.slink2

五、复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的行首的空白字符

  cp /etc/profile /tmp/

  vim /tmp/profile

  shift+: 然后输入 %s#^[[:space:]]\+##g

[root@centos7 ~]# cp /etc/profile /tmp/
[root@centos7 ~]# vim /tmp/profile
# /etc/profile # System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates. pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$
else
PATH=$:$PATH
fi
esac
}
... :%s#^[[:space:]]\+##g # /etc/profile # System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates. pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$
else
PATH=$:$PATH
fi
esac
}
...

六、在vim中设置tab缩进为4个字符

  vim ~/.vimrc

  按 i 进行编辑模式,输入 set tabstop = 4

  按ESC,shift+: 进行命令模式,输入 wq 保存退出即可。

第二周作业—N42-虚怀若谷的更多相关文章

  1. 20169212《Linux内核原理与分析》第二周作业

    <Linux内核原理与分析>第二周作业 这一周学习了MOOCLinux内核分析的第一讲,计算机是如何工作的?由于本科对相关知识的不熟悉,所以感觉有的知识理解起来了有一定的难度,不过多查查资 ...

  2. 20169210《Linux内核原理与分析》第二周作业

    <Linux内核原理与分析>第二周作业 本周作业分为两部分:第一部分为观看学习视频并完成实验楼实验一:第二部分为看<Linux内核设计与实现>1.2.18章并安装配置内核. 第 ...

  3. Java第二周作业

    Java第二周作业 本周作业: 参考http://www.cnblogs.com/rocedu/p/7911138.html 学习第二三章视频 参考http://www.cnblogs.com/roc ...

  4. C语言--第二周作业评分和总结(5班)

    作业链接:https://edu.cnblogs.com/campus/hljkj/CS2017-5/homework/1026 一.评分要求 要求1 阅读指定博客+阅读收获+例子.(5分) 要求2 ...

  5. 2017-2018-1 Java小组-1623 第二周作业

    2017-2018-1 Java小组-1623 第二周作业 关于游戏软件的问题 讨论结果 20162301张师瑜 20162305李昱兴 20162306陈是奇 20162308马平川 2016231 ...

  6. 2017-2018-1 JAVA实验站 第二周作业

    2017-2018-1 JAVA实验站 第二周作业 小组成员: 组长 20162318张泰毓 成员 20162303石亚鑫 20162304张浩林 20162307张韵琪 20162321王彪 201 ...

  7. 2017-2018-1 20179205《Linux内核原理与设计》第二周作业

    <Linux内核原理与分析>第二周作业 本周视频学习情况: 通过孟老师的视频教程,大致对风诺依曼体系结构有了一个初步的认识,视频从硬件角度和程序员角度对CPU和Main Memory(内存 ...

  8. 2017-2018-1 20179215《Linux内核原理与分析》第二周作业

    20179215<Linux内核原理与分析>第二周作业 这一周主要了解了计算机是如何工作的,包括现在存储程序计算机的工作模型.X86汇编指令包括几种内存地址的寻址方式和push.pop.c ...

  9. 2019-2020-1 20199303<Linux内核原理与分析>第二周作业

    2019-2020-1 20199303第二周作业 1.汇编与寄存器的学习 寄存器是中央处理器内的组成部份.寄存器是有限存贮容量的高速存贮部件,它们可用来暂存指令.数据和位址.在中央处理器的控制部件中 ...

  10. 2019-2020-1 20199329《Linux内核原理与分析》第二周作业

    <Linux内核原理与分析>第二周作业 一.上周问题总结: 未能及时整理笔记 Linux还需要多用 markdown格式不熟练 发布博客时间超过规定期限 二.本周学习内容: <庖丁解 ...

随机推荐

  1. windows mysql官方绿色版zip包安装教程

    环境: 系统环境 Windows 10 64位 mysql版本 5.7.19 一.万变不离的下载 下载页面:https://dev.mysql.com/downloads/mysql/ 点击 Down ...

  2. delphi idhttpsever

    http://blog.csdn.net/chelen_jak/article/details/50203809 delphi idhttpsever 2015-12-07 11:36 216人阅读  ...

  3. Leapin' Lizards [HDU - 2732]【网络流最大流】

    题目链接 网络流直接最大流就是了,只是要拆点小心一个点的流超出了原本的正常范围才是. #include <iostream> #include <cstdio> #includ ...

  4. Orcle获取当前时间加小时

    如下是oracle 获取当前数据库时间加2个小时 select to_date(TO_CHAR (SYSDATE, 'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24: ...

  5. 函数式编程filter和map的区别

    # b = filter(lambda x:x>5,[1,2,3,4,5,6,7]) # print(list(b)) def filters(x): if x > 5: return x ...

  6. bash 特殊符号的含义

    bash常见特殊符号及含义 linux中shell变量的含义解释

  7. jvm(4) 对象创建

    1.对象的创建过程: 1.new 类名 2.根据new的参数在常量池中定位一个类的符号的引用. 3.如果没找到这个符号的引用,说明类还没有被加载.则进行类的加载,解析和初始化 4.虚拟机为对象分配内存 ...

  8. 矩阵快速幂(queue递推)

    http://acm.hdu.edu.cn/showproblem.php?pid=2604 Queuing Time Limit: 10000/5000 MS (Java/Others)    Me ...

  9. kmp(前缀出现次数next应用)

    http://acm.hdu.edu.cn/showproblem.php?pid=3336 Count the string Time Limit: 2000/1000 MS (Java/Other ...

  10. 15、numpy——排序、条件刷选函数

    NumPy 提供了多种排序的方法. 这些排序函数实现不同的排序算法,每个排序算法的特征在于执行速度,最坏情况性能,所需的工作空间和算法的稳定性. 下表显示了三种排序算法的比较. 种类 速度 最坏情况 ...