Linux初步学习
基本的三个命令的学习
- chmod
- chown
chgrp
先来看一幅图
1.修改文件的拥有者 chown
目前拥有者和组别都是root
xth@ubuntu:~/Code/C$ ls -l test1.c
-rw-r--r-- 1 root root 0 Oct 10 07:08 test1.c
我们现在修改该文件的拥有者
//首先必须切换到管理员
root@ubuntu:/home/xth/Code/C# chown Yy test1.c
root@ubuntu:/home/xth/Code/C# ls -l test1.c
-rw-r--r-- 1 Yy root 0 Oct 10 07:08 test1.c
这样拥有者就变成Yy这个用户了
2.修改文件组拥有者 chgrp
test1.c这个文件的组拥有者是root 我们修改一下:
root@ubuntu:/home/xth/Code/C# chgrp xth test1.c
root@ubuntu:/home/xth/Code/C# ls -l test1.c
-rw-r--r-- 1 Yy xth 0 Oct 10 07:08 test1.c
组拥有者就是xth这个组了
3.修改文件的权限 chmod
目前拥有者的权限是读和写 组拥有者和其他用户的权限是读。
我们修改如下:
拥有者:读写和执行(rwx)
组拥有者:写和执行(-wx)
其他用户:没有权限(—)
root@ubuntu:/home/xth/Code/C# chmod u+x,g-r+w+x,o-r test1.c
root@ubuntu:/home/xth/Code/C# ls -l test1.c
-rwx-wx--- 1 Yy xth 0 Oct 10 07:08 test1.c
所以
拥有者->u
组拥有者->g
其他->o
+号就是增加权限 -号我就不说了。
2015年10月11日10:22:10