LPI学习之--文件系统层次结构

Linux系统常见的根目录结构:

  • / (根目录)
  • /boot (引导装入程序的静态文件)
  • /dev (设备文件)
  • /etc (主机特定的系统配置)
  • /lib (基本共享库和核心模块)
  • /mnt (临时挂装文件系统的挂装点)
  • /opt (附加的应用程序软件包)
  • /sbin (基本系统二进制文件)
  • /tmp (临时文件)
  • /usr (辅助层次结构)
  • /var (可变数据)
FHS 的布局规范基于存在两个独立的文件类别:可共享与不可共享以及可变与静态这一思想。可共享数据 能在主机之间被共享;不可共享数据 特定于给定主机(例如配置文件)。可变数据 可以被修改;静态数据 不可以被修改(除了在系统安装和维护阶段)。

  +---------+-----------------+-------------+
| | 可共享 | 不可共享 |
+---------+-----------------+-------------+
|静态 | /usr | /etc |
| | /opt | /boot |
+---------+-----------------+-------------+
|可变 | /var/mail | /var/run |
| | /var/spool/news | /var/lock |

+---------+-----------------+-------------+

FHS与查找文件:
PATH:
当您在命令行上运行程序时,bash 实际上搜索目录列表来查找您所请求的程序。 但是,bash 引用一个名为 PATH 的环境变量,它是一个用冒号分隔的目录列表

[root@rcc-pok-idg-2305 /]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[root@rcc-pok-idg-2305 /]# which --help
Usage: /usr/bin/which [options] [--] programname [...]
Options: --version, -[vV] Print version and exit successfully.
--help, Print this help and exit successfully.
--skip-dot Skip directories in PATH that start with a dot.
--skip-tilde Skip directories in PATH that start with a tilde.
--show-dot Don't expand a dot to current directory in output.
--show-tilde Output a tilde for HOME directory for non-root.
--tty-only Stop processing options on the right if not on tty.
--all, -a Print all matches in PATH, not just the first
--read-alias, -i Read list of aliases from stdin.
--skip-alias Ignore option --read-alias; don't read stdin.
--read-functions Read shell functions from stdin.
--skip-functions Ignore option --read-functions; don't read stdin.
whereis - locate the binary, source, and manual page files for a command

find 和通配符:
可以在 -name 的参数中使用“glob”通配符,前提条件是您用双引号引用了它们或用反斜杠进行了转义

使用 -iname 来进行不区分大小写的搜索

find与正则表达式:
$ find /etc -iregex
 '.*xt.*'
/etc/X11/xkb/types/extra
/etc/X11/xkb/semantics/xtest
/etc/X11/xkb/compat/xtest
/etc/X11/app-defaults/XTerm
-iregex 选项,该选项忽略模式中的大小写
注意:
find 要求指定的正则表达式与整个路径匹配,而不只是该路径的一部分。为此,指定前导和尾随的 .* 是必要的
如:[root@rcc-pok-idg-2305 /]# find /etc -iregex 'xt'
[root@rcc-pok-idg-2305 /]#
而[root@rcc-pok-idg-2305 /]# find /etc -iregex '.*xt.*'
/etc/racoon/psk.txt
/etc/DIR_COLORS.xterm
/etc/skel/.mozilla/extensions
/etc/selinux/targeted/modules/active/file_contexts.template

find -type选项:
-type 参数是 b
(块设备)、c (字符设备)、d (目录)、p (命名管道)、f (常规文件)、l (符号链接)和 s (套接字)允许查找某一类型的文件系统对象。

[root@rcc-pok-idg-2305 /]# find /usr/bin -name '*vim*' -type l
/usr/bin/rvim
/usr/bin/vimdiff

-mtime 选项允许您根据最近一次的修改时间来选择文件。mtime 的参数以 24 小时为单位,当输入时带加号(表示“之后”)或者减号(表示“之前”)时,它最有用

-size 选项允许您根据文件的大小来查找它们。缺省情况下,-size 的参数是 512 个字节的块,但是添加后缀可以使操作更简便。可用的后缀是 b (512 字节的块)、c (字节)、k (千字节)和 w (2 字节的字)。另外,您可以在前放置加号(“大于”)或者减号(“小于”)。

slocate 代表“安全定位(secure locate)”。它将许可权信息存储在数据库中,这样普通用户不能以别的方式窥探他们不能读取的目录。slocate 的用法信息在本质上与 locate 的信息相同,尽管输出可能不同(取决于正在运行命令的用户

Slocate 与locate区别:
Slocate and locate both do essentially the same thing:
search a database containing the file names and locations on the system
for a match and report all that are found.
Both count on another program -- updatedb -- to do the heavy lifting by creating/maintaining
the database to be searched.
Slocate provides greater security by storing the permissions and ownership of each file, and then only
showing the files that the user running the slocate request has permission to access.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

惹不起的程咬金

来都来了,不赏点银子么

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值