1.Linux 文件权限: Linux 文件访问的身份一般分为 owner group others 即 所有者 组成员 其他 。文件 的权限一般为 r w x 即可读 可写 可执行
2.Linux 群组的概念 :即可以对文件的执行权限进行分配,同一个文件可以指定分组或个人对其进行 读 写 执行操作,也可以三者兼有 。 实际应用中根据需要和等级权限需要进行用 ROOT 帐户分配或者文件创建者对文件权限的分配
3.Linux 文件的属性: 使用 ls - l 命令进行常看后
d - rw-r--rw- 2 root icecream 3949 sep 8 2008 .bash log
d 为目录 |权限|连接数|所有者|用户组|文件容量|创建日期|文件名
rw-r--rwx
文件所有者权限 文件所属组权限 其他人权限
4.如何改变文件属性与权限:
chgrp: 改变文件属性与权限 chown 改变文件所有者 chmod 改变文件的权限
-R 递归更改
利用 cp 命令进行 文件复制 时复制的文件属性不变,故复制后文件的属性需加以修改别人才可以读写,操作改文件
chmod 命令操作方式: (1)数字类型改变文件权限, r:4 w:2 x:1 例如 chmod 777 .bash 则将 .bash 文件的权限改为 owner group others 都为所有权限
(2)符号类型改变文件权限, 使用用户标识加上(+)所需要赋予权限首字母 例如 chmod a+x .bash 就为将可执行权限赋予了所有人 chmod a-x 则相反 chmod 为直接设置
目录权限的说明: 目录权限:r 表示可以查看目录下文件列表 仅此而已
w 表示你可以更改目录结构列表的内容 也就是可以新建文件 删除文件 转移文件 重命名已有文件或目录
x 表示你是否可以切换至此目录 进行工作
5.相对路径与绝对路径问题:
绝对路径:由根目录开始写起的文件名或者目录名 /home/xiazai
相对路径:相对于当前路径的文件名写法 ./home/icecream
..代表上一层目录 或者 ../ .代表当前目录 或者./
-代表一个工作目录 ~代表“目前用户身份”所在的文件夹
~account代表account这个用户的主文件夹,那么,根目录存在上层目录吗?经过ls -al 验证.. 和.是同一个目录
几个基本的目录处理命令:cd 切换目录,pwd显示当前目录,mkdir创建一个新的目录,rmdir删除一个空的目录。
6
.[852deSN@localhost ~]$ cd ~
[852deSN@localhost ~]$ cd 切换当前用户主目录
[852deSN@localhost ~]$ cd .. 切换到上层目录
[852deSN@localhost home]$ ls
852deSN
[852deSN@localhost home]$ cd - 切换到刚才的目录
/home/852deSN
[852deSN@localhost ~]$ ls
Desktop Test
[852deSN@localhost ~]$ cd /home/Test 切换命令不正确,不是绝对路径
bash: cd: /home/Test: 没有那个文件或目录
[852deSN@localhost ~]$ cd /Test
bash: cd: /Test: 没有那个文件或目录
[852deSN@localhost home]$ ls -l 852deSN/
.adobe/ .evolution/ .metacity/
.bash_history .gconf/ .mozilla/
.bash_logout .gconfd/ .nautilus/
.bash_profile .gnome/ .recently-used.xbel
.bashrc .gnome2/ .redhat/
.chewing/ .gnome2_private/ .scim/
.config/ .gstreamer-0.10/ Test/
Desktop/ .gtkrc-1.2-gnome2 .themes/
.dmrc .ICEauthority .thumbnails/
.eggcups/ .icons/ .Trash/
.emacs .lesshst .xsession-errors
.esd_auth .macromedia/ .zshrc
[852deSN@localhost home]$ ls -l 852deSN/
总计 16
drwxr-xr-x 3 852deSN 852deSN 4096 08-22 20:17 Desktop
drwxr--r-- 2 852deSN 852deSN 4096 08-23 08:40 Test
[852deSN@localhost home]$ cd /852deSN/Test
bash: cd: /852deSN/Test: 没有那个文件或目录
[852deSN@localhost home]$ cd /home/852deSN/Test
[852deSN@localhost Test]$ cd ../Desktop/ 切换到上层目录的desktop文件夹,为相对路径操作
[852deSN@localhost Desktop]$ ls
文件权限练习
[852deSN@localhost Desktop]$
以下为mkdir命令的man操作输出:(几乎所有Linux类的书籍都强调了man手册的重要性)
MKDIR(1) 参见图1代号代表内容 User Commands MKDIR(1)(图1)
NAME
mkdir - make directories
SYNOPSIS
mkdir [OPTION] DIRECTORY...
DESCRIPTION
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE
set permission mode (as in chmod), not rwxrwxrwx - umask 直接设置所创建目录权限
-p, --parents
no error if existing, make parent directories as needed 递归创建一系列目录
-v, --verbose
print a message for each created directory 打印创建的目录信息
-Z, --context=CONTEXT (SELinux) set security context to CONTEXT
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright © 2006 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WAR-
RANTY, to the extent permitted by law.
rmdir只能删除空目录
rmdir -p 可以删除非空目录 rm -r进行递归删除
MKDIR(1) User Commands MKDIR(1)
NAME
mkdir - make directories
SYNOPSIS
mkdir [OPTION] DIRECTORY...
DESCRIPTION
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE
set permission mode (as in chmod), not rwxrwxrwx - umask
-p, --parents
no error if existing, make parent directories as needed
-v, --verbose
print a message for each created directory
-Z, --context=CONTEXT (SELinux) set security context to CONTEXT
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright © 2006 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WAR-
RANTY, to the extent permitted by law.