Linux学习笔记——零碎的小知识
华亮
Linux文件权限解读
~/Project/Code/Server$ ls -al
总用量 3636
drwx------ 8 cedricporter cedricporter 4096 2011-08-27 19:32 .
drwxr-xr-x 8 cedricporter cedricporter 4096 2011-08-27 18:24 ..
-rw-r--r-- 1 cedricporter cedricporter 206 2011-08-06 09:17 Account.py
-rw-r--r-- 1 cedricporter cedricporter 611 2011-08-06 09:18 Account.pyc
-rw-r--r-- 1 cedricporter cedricporter 2220 2011-08-25 08:53 Album.py
-rw-r--r-- 1 cedricporter cedricporter 3000 2011-08-27 18:34 Album.pyc
-rw-r--r-- 1 cedricporter cedricporter 2221 2011-08-22 08:49 config.py
-rw-r--r-- 1 cedricporter cedricporter 947 2011-08-27 18:30 config.pyc
drwx------ 3 cedricporter cedricporter 4096 2011-08-11 08:55 create_table
-rw-r--r-- 1 cedricporter cedricporter 1102 2011-07-29 10:46 create_table_sqlite.py
-rw-r--r-- 1 cedricporter cedricporter 3311 2011-08-27 19:32 db.py
-rw-r--r-- 1 cedricporter cedricporter 3135 2011-08-27 19:32 db.pyc
-rw-r--r-- 1 cedricporter cedricporter 7680 2011-08-18 15:28 Diary.py
-rw-r--r-- 1 cedricporter cedricporter 7821 2011-08-27 18:42 Diary.pyc
-rw-r--r-- 1 cedricporter cedricporter 7805 2011-08-25 21:17 Friends.py
-rw-r--r-- 1 cedricporter cedricporter 7091 2011-08-27 18:32 Friends.pyc
如何解读 -rw-r--r--
[-] [rw-] [r--] [r--]
1 234 567 890
1: 类型。 - 代表文件, d代表目录
234: 拥有者的权限
567: 同用户组的权限
890: 其他用户权限
Linux文件类型和扩展名
一般情况下,Linux下的文件是没有所谓的扩展名。与Windows看扩展名不同,Linux下主要看那10个属性。
Linux目录配置
目录类型
可分享的:可以分享给其他系统挂载使用的目录,包括网络上其他主机。
不可分享的:自己机器上面运行的设备文件或者程序有关的socket。
不变的:函数库,说明文件,配置文件。
可变的:很多。
可分享的(shareable) | 不可分享的(unshareable) | |
不变的(static) | /usr(软件放置处) | /etc(配置文件) |
/opt(第三方软件) | /boot(开机与内核文件) | |
可变动的(variable) | /var/mail | /var/run |
/var/spool/news | /var/lock |
Filesystem Hierarchy Standard ( FHS ) 标准针对目录树架构定义出三层目录下该放什么数据:
/ ( 根目录 ) : 与开机系统有关
/usr ( Unix Software Resource ):与软件安装与执行有关
/var ( variable ):与系统运作过程有关。
FHS标准建议:根目录( / )所在分区应该越小越好,而且应用程序所安装的软件最好不要与根目录放在同一个分区,保持根目录越小越好。
不可与根目录放在不同分区的目录:
/etc:配置文件
/bin:重要执行文件
/dev:所需要的设备文件
/lib:执行文件所需要的函数库与内核所需的模块
/sbin:重要的系统执行文件
路径:
. :代表当前的目录,也可以用 ./ 表示;
..:代表上一层目录,也可以用 ../ 表示;
参考:《鸟哥的Linux私房菜》