Linux目录结构

2018-03-19  本文已影响0人  RussellYoung

一、命令回顾

1、ll会列出该文件下的所有文件信息,包括隐藏的文件,而ls -l只列出显式文件。信息包括:

文件属性 文件数 拥有者 所属的group 文件大小 建档日期 文件名

-rw-------. 1    root    root       1922     Mar  6 20:08 anaconda-ks.cfg
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Desktop
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Documents
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Downloads
-rw-r--r--. 1    root    root       1953     Mar  6 21:24 initial-setup-ks.cfg
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Music
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Pictures
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Public
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Templates
drwxr-xr-x. 2    root    root       6        Mar  6 22:34 Videos
-rw-r--r--. 1    root    root       250      Mar  9 10:46 who.out

意义:

2、ls 命令可以说是linux下最常用的命令之一。

选项有:

-a 列出目录下的所有文件,包括以 . 开头的隐含文件。

-b 把文件名中不可输出的字符用反斜杠加字符编号(就象在C语言里一样)的形式列出。

-c 输出文件的 i 节点的修改时间,并以此排序。

-d 将目录象文件一样显示,而不是显示其下的文件。

-i 输出文件的 i 节点的索引信息。

-l 列出文件的详细信息。

-m 横向输出文件名,并以“,”作分格符。

-n 用数字的 UID,GID 代替名称。

-o 显示文件的除组信息外的详细信息。

-p -F 在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通

文件;“/”表示目录;“@”表示符号链接;“|”表示FIFOs;“=”表示套

接字(sockets)。

-q 用?代替不可输出的字符。

-r 对目录反向排序。

-s 在每个文件名后输出该文件的大小。

-t 以时间排序。说明以最近修改的日期进行排序!

 -u 以文件上次被访问的时间排序。

-A 显示除 “.”和“..”外的所有文件。

-B 不输出以 “~”结尾的备份文件。

-L 列出链接文件名而不是链接到的文件。

-N 不限制文件长度。

-Q 把输出的文件名用双引号括起来。

-R 列出所有子目录下的文件。

-S 以文件大小排序。

-X 以文件的扩展名(最后一个 . 后的字符)排序。

-1 一行只输出一个文件。

--color=no 不显示彩色文件名

--help 在标准输出上显示帮助信息。

--version 在标准输出上输出版本信息并退出。

只列出子目录

  1. ls -F | grep /$ 或者 alias sub = "ls -F | grep /$"(linux)

  2. ls -l | grep "^d" 或者 ls -lL | grep "^d" (Solaris)

下面命令可以分别计算当前目录下的文件和目录个数:

# ls -l * |grep "^-"|wc -l ---- to count files

# ls -l * |grep "^d"|wc -l ----- to count dir

显示彩色目录列表,打开/etc/bashrc, 加入如下一行:

alias ls="ls --color"

下次启动bash时就可以像在Slackware里那样显示彩色的目录列表了, 其中颜色的含义如下:

1. 蓝色-->目录

2. 绿色-->可执行文件

3. 红色-->压缩文件

4. 浅蓝色-->链接文件

5. 灰色-->其他文件 

ls -tl --time-style=full-iso sshd

ls -ctl --time-style=long-iso

3、help命令用法:

内部命令:help cd
外部命令:ls --help

4、ls-a -l ——> ls -al 效果是一样的

5、man命令:

提供命令帮助的文件,手册页存放在/usr/share/man。几乎每个命令都有man的“页面”,man页面分组为不同的“章节”,统称为Linux手册。
man命令的配置文件:/etc/man.config | man_db.conf
MANPATH /PATH/TO/SOMEWHERE: 指明man文件搜索位置
man - M /PATH/TO/SOMEWHERE COMMAND: 到指定位置下搜索 COMMAND 命令的手册页并显示
中文man需安装包man-pages-zh-CN

MAN章节:

1: 用户命令
2: 系统调用
3: C库调用
4: 设备文件及特殊文件
5: 配置文件格式
6: 游戏
7: 杂项
8: 管理类的命令
9:Linux 内核API

注:因为MAN命令分章节,而有的命令地址有好几个,所以默认打开的MAN章节可能不是自己想查询的那个,可以先查询一下

[root@centos7 ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
[root@centos7 ~]# whatis passwd
sslpasswd (1ssl)     - compute password hashes
passwd (1)           - update user's authentication tokens
passwd (5)           - password file
[root@centos7 ~]# man 5 passwd
[root@centos7 ~]# 

二、文件名规则

三、文件系统结构

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

五、查看定义文件夹和文件颜色的文具文档

[root@centos7 ~]# cat /etc/DIR_COLORS
# Configuration file for the color ls utility  //颜色工具配置文件
# Synchronized with coreutils 8.5 dircolors
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty

# Extra command line options for ls go here.
# Basically these ones are:
#  -F = show '/' for dirs, '*' for executables, etc.
#  -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
TERM color-xterm
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM console
TERM cygwin
·
·
·

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00  # no color code at all
#FILE 00    # normal file, use no color at all
RESET 0 # reset to "normal" color
DIR 01;34   # directory
LINK 01;36  # symbolic link (If you set this to 'target' instead of a
        # numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00    # regular file with more than one link
FIFO 40;33  # pipe   //数字代表颜色
SOCK 01;35  # socket
DOOR 01;35  # door
BLK 40;33;01    # block device driver
CHR 40;33;01    # character device driver
ORPHAN 40;31;01  # symlink to nonexistent file, or non-stat'able file
MISSING 01;05;37;41 # ... and the files they point to
SETUID 37;41    # file that is setuid (u+s)
SETGID 30;43    # file that is setgid (g+s)
CAPABILITY 30;41    # file with capability
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44    # dir with the sticky bit set (+t) and not other-writable

# This is for files with execute permission:
EXEC 01;32

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# executables (bright green)
#.cmd 01;32  //以下数字皆表示文件
#.exe 01;32
#.com 01;32
#.btm 01;32
#.bat 01;32
#.sh  01;32
#.csh 01;32
上一篇 下一篇

猜你喜欢

热点阅读