权限和权限管理

Linux下的用户类型分为3类:分别是拥有者(Owner)、所属组(Group)以及其他用户(Others)的权限,每一类用户都有r、w、x的权限。

文件:

r:可以查看文件的内容。

w:可以修改文件的内容。

x:如果文件具有可执行的内容,则可以执行该文件。

目录:

r:可以使用ls列出该目录下的文件和目录,不能使用ls -l。

w:可以创建文件和目录。

x:可以进入到目录下。

chown命令

作用:修改文件或目录的拥有者和/或所属组。

语法格式:

chown [OPTION]... [OWNER][:[GROUP]] FILE...
修改拥有者:chown [option] OWNER FILE...
修改所属组:chown [option] :GROUP FILE...
同时修改拥有者和所属组:chown [option] OWNER:GROUP FILE...

选项:

-R:递归的修改目录的拥有者或/和所属组。

示例:

[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]# chown frame test
[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 frame root 641020 Jul  2 04:23 test
[[email protected] tmp]# chown :frame test
[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 frame frame 641020 Jul  2 04:23 test
[[email protected] tmp]# chown root:root test
[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]#

chgrp命令

作用:修改文件或目录的所属组。

选项:

-R:递归的修改目录及其子目录下的档案或目录的所属组。

示例:

[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]# chgrp frame test 
[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 root frame 641020 Jul  2 04:23 test
[[email protected] tmp]#

chmod命令

作用:修改文件或目录的权限

选项:

-R:递归的修改文件或目录的权限。

方法一:采用u、g、o、a的方式修改权限。

u:代表的是owner

g:代表的是group

o:代表的是others

a:代表的是ugo

操作符:

+:表示在原有权限的基础上增加权限。

-:表示在原有权限的基础上去掉相应的权限。

=:不管原来的权限是什么,直接赋予指定的权限。

示例:

[[email protected] tmp]# ll
total 628
-rw-r--r-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]# chmod u=rwx,g+x,o-r test 
[[email protected] tmp]# ls -l
total 628
-rwxr-x--- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]#
[[email protected] tmp]# ls -l
total 628
-rwxr-x--- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]# chmod a=rw- test 
[[email protected] tmp]# ls -l test 
-rw-rw-rw- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]#
[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]# chmod ug+x test 
[[email protected] tmp]# ls -l test 
-rwxr-xr-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]#

方法二:采用数值的方式修改权限。

r:4

w:2

x:1

示例:

[[email protected] tmp]# ls -l test 
-rw-rw-rw- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]# chmod 644 test 
[[email protected] tmp]# ls -l test 
-rw-r--r-- 1 root root 641020 Jul  2 04:23 test
[[email protected] tmp]#

复制隐藏文件的正确做法:

cp -a /tmp/dira/. /tmp/dirb

权限和权限管理,布布扣,bubuko.com

时间: 2024-07-30 13:49:56

权限和权限管理的相关文章

destoon 给超级管理员系统权限(管理员管理,日志管理等)

destoon 后台某些系统权限除了网站创始人之外其他超管事没有权限的,现需要给其他超级管理员添加普通管理员的权限. 1.首先  admin/global.func.php  admin_check函数 ,去掉admin  这样超管才能访问 ?file=admin } else if($_admin == 1) {?     //if(in_array($file, array('admin', 'setting', 'module', 'area', 'database', 'template

从零开始编写自己的C#框架(18)——Web层后端权限模块——菜单管理

从本章开始,主要讲解的是页面中对框架相关功能的调用方法,比如列表页面(又分为有层次感列表和普通列表).编辑页面.多标签页面等,只要熟悉了这些函数的使用方法,那么开发起来就会很便捷了. 1.如图先创建菜单列表与编辑页面 MenuInfoList.aspx 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MenuInfoList.aspx.cs" Inherits=&quo

Linux学习笔记—— 权限及权限管理

权限及权限管理 权限管理: r: w: x: 三类用户: u:属主 g:属组 o:其他用户 chown:改变文件属主(只有管理员可以使用此命令) # chown USERNAME file,... -R:修改目录及其内部文件的属主       --reference=/path/to/somefile,...指定文件或目录为参考,把操作的文件或目录设置为相同 chown USERNAME:GRPNAME file,... 同时改文件的属主.和属组名  chown USERNAME.GRPNAME

SQL Fundamentals || DCL(Data Control Language) || 系统权限&amp;对象权限管理(GRANT&amp;REVOKE)

SQL Fundamentals || Oracle SQL语言 语句 解释 Create user Creates a user(usually performed by a DBA) Grant Gives other users privileges to access the objects Create role Creates a collection of privileges, usually performed by a DBA Alter user Changes a use

第四课-第二讲04_02_权限及权限管理

第四课-第二讲04_02_权限及权限管理三种权限:rwx三类用户:u:属主g:属组o:其他用户 1.chown:改变文件属主命令(管理员独享命令)chown USERNAME file,file2,file3,.....-R 递归修改,修改目录和目录下文件属主--reference = /path/to/somefile /path/file(主和组一起修改)chown USERNAME:GRPNAME filechown :GRPNAME filechown USERNAME.GRPNAME

权限及归属管理 磁盘管理 文件系统 LVM管理

第五六七章   alias 查看系统别名   67 chmod 设置文件或目录的权限 -R表示以递归的方式设置目录及目录下的所有子目录及文件的权限 u:属主 g:属组 o:其他人 a:所有人 +:添加 -:删除 =:重置   68 chown 属主,文件 chown:属主 文件 chown 属主:属组文件   69 umask 控制新建的文件或目录的权限 查看umask值:umask 设置umask值:umask nnn   70 fdisk -l 检测并确认新硬盘 Device:分区的设备文件

mysql用户账号、权限、密码管理

一:用户账号管理 查看当前可登录数据库的用户 mysql>SELECT host,user FROM mysql.user; 创建新用户 mysql>CREATE USER username@host IDENTIFIED BY '密码'; 注意:username是用户名,host用于指定登录的主机,如果是本地用户用localhost,如果需要远程连接可以指定ip,或者使用“%”可以从任意主机登录. 删除用户 mysql>DROP USER pangpang@localhost ; 修改

Linux基础知识--文件目录权限和归属管理

文件/目录的权限和归属 访问权限: 读取:允许查看文件内容,显示目录列表 写入:允许修改文件内容,允许在目录中新建.移动或者删除文件或子目录 可执行:允许运行程序,允许切换目录 归属(所有权): 属主:拥有该文件或目录的用户账户 数组:拥有该文件或目录的组账户 查看文件/目录的权限 [root@localhost ~]# ls -l install.log -rw-r--r-- 1 root root 36157 Jan 23 08:05 install.log 第一位代表的是文件或者目录,"-

用户 组 和权限 以及权限的 分类

关于文件的安全我们要从3A验证 说起 1  Authentication:认证 2  Authorization:授权 3  Accouting|Audition:审计 由于系统文件的用户太多为了便于管理 我们便把系统的用户 进行分类 赋予权限 合理地分配资源 所以今天介绍的是 系统用户 用户组 的一些权限的 分配 修改 和文件的 权限修改 和赋权 以及一些特殊权限的用法 用户的分类 管理员:root 0 普通用户:1-65535 系统用户:1-499(CENTOS6) 1-999 对守护进程获