• 系统目录结构/ls命令/文件类型/alias命令


    • 2.1/2.2 系统目录结构
    • 2.3 ls命令 2.4 文件类型
    • 2.5 alias命令

    linux文件目录结构

        • linux文件结构
          • / 系统跟目录
          • root  root用户主目录,存放启动linux系统的核心文件,如操作系统的内核、引导程序grub等
          • home 普通用户主目录
          • bin 存放系统启动时需要执行的二进制文件,普通用户使用的命令。
          • sbin 可执行文件目录,存放系统管理的命令,root用户或者root权限才能执行里面的命令。
          • boot 存放系统启动时需要的文件
          • lib     存放系统需要的动态库以及核心模块
          • lib64 存放系统需要的库文件
          • mnt挂载系统之外的文件系统,需要提前挂载的目录
          • media 插入优盘会挂载到该处
          • tmp临时文件目录
          • lost_found存放系统错误的内容、系统恢复时恢复的文件
          • opt用来安装第三方的软件包
          • dev (device)包含键盘鼠标等设备
          • run 存放已关机就会消失的文件。例如某些进程产生的PID就放在该处。
          • srv  (service)存放服务文件
          • proc (process)存放linux系统的所有内核参数以及系统的配置信息,按照进程的编号进行存取
            • 1 存储进程init的信息,每一个进程号都有相应的目录文件存储相关的信息
            • cpuinfo存储cpu相关的信息,如制造商、基本性能参数等
            • devices存储当前运行的核心配置的设备驱动列表
            • dma显示当前使用的DMA通道
            • loadavg显示平均负载,指示系统当前的工作量
            • modules显示当前系统加载了哪些核心模块
            • meminfo存储物理内存和交换内存的实用信息
            • version核心版本
          • usr 用户目录,存放用户文件
            • bin存放用户可以直接执行的所有的命令,存放普通用户使用的命令
            • sbin存放于系统管理员相关的命令,如服务器的程序,需要root用户才能执行
            • Include存放C和C++语言的头文件
            • local本地安装程序的默认安装目录 apache的服务就放在这里
            • man手动生成的目录
            • info信息文档
            • doc安装包的文档信息
          • etc存放各种配置文件
            • rc或rc.d或rc*.d存储系统的启动脚本或改变运行级别的脚本
            • passwd系统的合法用户,包含用户名,主目录,密文形式的登录密码以及其他信息,按照一定的格式进行存储。
            • group存储用户组相关的信息
            • issue登录提示符的输出信息,通常包括系统的一段短说明或欢迎信息。内容由系统管理员决定。
            • shadow存储用户登录密码,明文和密文相对应,使用md5算法进行加密
            • profile创建全局变量,一般存放的是环境变量
            • shells 包含可以使用的shell
          • var 运行时要改变的数据(系统进程服务产生的临时文件、log、缓存)
            • local 安装程序的可变数据
            • lock锁定文件,防止当前文件正在使用时被其它程序修改
            • log存储系统的各种日志文件,存储系统的所有操作信息:所有核心和系统程序信息
            • run保存到下次引导前有效的关于系统的信息文件
            • spool存储队列,涉及email,news,打印队列等
            • tmp存储临时性文件,存储的文件比/tmp中的文件要大或存储的时间要长

     

     

    tree显示文件系统结构

    yum install tree

     

    man tree/ tree --help 显示帮助文档

     

     

    man tree -L 2 显示文件二级结构

     

    命令的存放:

    /bin/      -----一般存放普通用户使用的命令

    /sbin/    -----一般存放root用户使用的命令

    /bin/做了软链接:/usr/bin/

    /sbin/做了软链接:/usr/sbin/

     

    查看依赖的库文件:

    例如查看ls依赖的库文件:

    ldd    /bin/ls

      

    绝对路径:从根开始的路径;文件所在的路径;

    相对路径:相对于当前目录而言的路径;上一级或者下一级的路径。

     

    查看当前路径:pwd

    进入指定目录: cd

     

     

    2.ls

     

    ls -l列出文件详细信息

    [root@centos_1 ~]# ls -l

    总用量 4

    -rw-------. 1 root root 1417 11月  9 16:01 anaconda-ks.cfg

    其中 1 是表示有多少个文件使用了相同的inode

    ls -i 查看文件inode号

     

    -rw-------. 1 root root 1417 11月  9 16:01 anaconda-ks.cfg

     

     权限     有多少个文件使用了相同的inode     所有者     所属主   大小    日期    文件名

     

    ls  -lh 显示文件单位大小

    [root@centos_1 ~]# ls -lh anaconda-ks.cfg 

    -rw-------. 1 root root 1.4K 11月  9 16:01 anaconda-ks.cfg

     

    ls   -la 显示所有文件包括隐藏文件

    ls   -a

     

    ls -ld 显示目录的详细信息

    [root@centos_1 ~]# ls -ld /root

    dr-xr-x---. 3 root root 147 11月 11 22:54 /root

     

    有3个目录文件使用了相同的inode号,也可以理解为当前有多少个目录,有3个目录。

     

    [root@centos_1 ~]# ls -i /root/

    67172258 anaconda-ks.cfg

    [root@centos_1 ~]# ls -i .

    67172258 anaconda-ks.cfg

    [root@centos_1 ~]# ls -i .ssh/..

    67172258 anaconda-ks.cfg

     

    其实就是root目录

     

     

    .是当前目录   ..是上一级目录;

     

    总用量是指使用的inode号之和:

     

    3可以理解为当前有3个目录    .    ..   .ssh目录

     

     

     

     

    ls   -t 是以时间的顺序排序。时间越早的排在上面。

    ls   -lta

     

     

    ls   -d 列出目录

    ls   -l 列出根目录所有文件

    ls   -ld列出目录

     

     

    ll 是ls   -l的别名(alias):

     

    [root@centos_1 ~]# which  ll

    alias ll='ls -l --color=auto'

    /usr/bin/ls

     

     

    3.文件类型

    文件类型:(- d c l b s)

    -普通文件  :文本文档,二进制文件

    -rw-------. 1 root root 1417 11月  9 16:01 anaconda-ks.cfg

    d目录文件;

    drwxr-xr-x. 4 root root          80 11月 16 21:46 v4l

    c 字符串设备文件;

    crw-rw----. 1 root tty       7, 129 11月 16 21:46 vcsa1

    l 软链接文件,快捷方式文件

    lrwxrwxrwx. 1 root root          13 11月 16 21:46 fd -> /proc/self/fd

    箭头后面是原来的文件

    b (block)块设备文件:光盘、磁盘都是这种b文件

    brw-rw----. 1 root disk      8,   2 11月 16 21:46 sda2

    s (socket)文件:用于通信

    srw-rw-rw-. 1 root root 0 11月 16 21:46 /dev/log

     

    权限最前面第一个字符是文件类型。

     

     

    4.alias

    查看别名:which

    [root@centos_1 ~]# which ll

    alias ll='ls -l --color=auto'

    /usr/bin/ls

    alias 查看有谁定义了别名:

    [root@centos_1 ~]# 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'

    自定义别名:alias xiaobo='ls -lsa'

    [root@centos_1 ~]# alias xiaobo='ls -lha'

    [root@centos_1 ~]# xiaobo

    总用量 28K

    dr-xr-x---.  3 root root  147 11月 11 22:54 .

    dr-xr-xr-x. 17 root root  224 11月 15 22:24 ..

    -rw-------.  1 root root 1.4K 11月  9 16:01 anaconda-ks.cfg

    -rw-------.  1 root root 2.8K 11月 17 02:26 .bash_history

    -rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout

    -rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile

    -rw-r--r--.  1 root root  176 12月 29 2013 .bashrc

    -rw-r--r--.  1 root root  100 12月 29 2013 .cshrc

    drwx------.  2 root root   80 11月 16 22:19 .ssh

    -rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc

    [root@centos_1 ~]# 

    取消别名:unalias     xiaobo

    [root@centos_1 ~]# unalias xiaobo

     

     

     

     

  • 相关阅读:
    spoj705
    bzoj2440
    spoj220
    bzoj2301
    hdu1695
    poj3294
    hdu3518
    poj3693
    函数
    样式
  • 原文地址:https://www.cnblogs.com/zhaocundang/p/8044795.html
Copyright © 2020-2023  润新知