Linux权限相关操作命令
以下是关于创建用户,设置用户密码,以及查看文件权限,给用户设置权限的一系列操作过程。
#查看当前用户的信息
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
#查看是否存在test用户,以及用户信息
[root@VM_64_7_centos tmp]# id test
id: test: no such user
[root@VM_64_7_centos tmp]# id root
uid=0(root) gid=0(root) groups=0(root)
#创建新的用户
[root@VM_64_7_centos tmp]# useradd test
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test)
#将test用户添加到root组
[root@VM_64_7_centos tmp]# gpasswd -a test root
Adding user test to group root
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test),0(root)
#将test移出root组
[root@VM_64_7_centos tmp]# gpasswd -d test root
Removing user test from group root
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test)
#设置test用户的登录密码
[root@VM_64_7_centos ~]# passwd test
Changing password for user test.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[test@VM_64_7_centos tmp]$ id
uid=1000(test) gid=1000(test) groups=1000(test)
#切换root用户
[test@VM_64_7_centos tmp]$ su - root
Password:
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]#
#删除用户
[root@VM_64_7_centos tmp]# userdel -r test
[root@VM_64_7_centos tmp]# id test
id: test: no such user
#查看文件详细信息,包含文件操作的权限(r--r--r--)
# r:可读(4) w:可写(2) x:可执行(1)
# 文件权限分三组,第一组user,自身用户权限;第二组group,用户组权限;第三者other,其他用户权限
# u:代表自身用户;g:代表用户组;o:代表其他用户;a:代表所有用户
[root@VM_64_7_centos tmp]# ls -l
total 8
-r--r--r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod g+w o+x ./test.sh
chmod: cannot access 'o+x': No such file or directory
[root@VM_64_7_centos tmp]# chmod g+w ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-r--rw-r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+wx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxrw-r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod o+x ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxrw-r-x 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod a-rwx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+rwx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 000 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+001 ./test.sh
chmod: invalid mode: 'u+001'
Try 'chmod --help' for more information.
[root@VM_64_7_centos tmp]# chmod 001 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------x 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 020 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-----w---- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 400 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-r-------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 600 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rw------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 700 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 744 test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxr--r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]#
#查看文件权限
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
#设置文件权限
[root@VM_64_7_centos tmp]# setfacl -m u:test:rwx test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
user:test:rwx
group::r-x
mask::rwx
other::r-x
#删除文件权限
[root@VM_64_7_centos tmp]# setfacl -x user:test test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
mask::r-x
other::r-x
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxr-xr-x+ 1 root root 616 Dec 18 13:48 test.sh
#清空文件权限到设置权限之前的权限状态
[root@VM_64_7_centos tmp]# setfacl -b test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
[root@VM_64_7_centos tmp]#
Linux权限相关操作命令的更多相关文章
- linux权限相关操作
Linux权限管理是Linux中一个十分重要的概念,也是系统安全性的重要保障.这里主要介绍Linux的基本权限和默认权限,通过理论讲解与实验演示,可以详细了解到权限的相关操作及其重要性. 文件权限 [ ...
- linux mysql 相关操作命令
1.linux下启动mysql的命令:mysqladmin start/ect/init.d/mysql start (前面为mysql的安装路径) 2.linux下重启mysql的命令:mysqla ...
- Linux 权限相关
Linux中,所有文件都有 三种权限:User ,Group,Other 三个文件: /etc/passwd :包括所有系统账号,一般用户身份和root信息 /etc/shadow :保存个人密码 / ...
- Linux权限相关
权限分组 用户:文件所有者 用户组:多个用户的集合 其他:除了用户和用户组之外的任何用户 权限类别 r:表示读的权限 w:表示写的权限 x:表示执行的权限 s:表示setuid权限,允许用户以其拥有者 ...
- linux用户权限相关内容查看
linux用户权限相关内容查看 1 用户信息 创建用户一个名为 webuser 的账号,并填写相应的信息: root@iZ94fabhqhuZ:~# adduser webuser Adding ...
- 《The Linux Command Line》 读书笔记04 Linux用户以及权限相关命令
Linux用户以及权限相关命令 查看身份 id:Display user identity. 这个命令的输出会显示uid,gid和用户所属的组. uid即user ID,这是账户创建时被赋予的. gi ...
- Linux基础知识第八讲,系统相关操作命令
目录 Linux基础知识第八讲,系统相关操作命令 一丶简介命令 2.磁盘信息查看. 3.系统进程 Linux基础知识第八讲,系统相关操作命令 一丶简介命令 时间和日期 date cal 磁盘和目录空间 ...
- Linux - 用户权限相关命令
用户权限相关命令 目标 用户 和 权限 的基本概念 用户管理 终端命令 组管理 终端命令 修改权限 终端命令 01. 用户 和 权限 的基本概念 1.1 基本概念 用户 是 Linux 系统工作中重要 ...
- linux用户、文件权限相关命令
root 现代操作系统一般属于多用户的操作系统,也就是说,同一台机器可以为多个用户建立账户,一般这些用户都是为普通用户,这些普通用户能同时登录这台计算机,计算机对这些用户分配一定的资源. 普通用户在所 ...
随机推荐
- dp百题大过关(第一场)
好吧,这名字真是让我想起了某段被某教科书支配的历史.....各种DP题层出不穷,不过终于做完了orz 虽然各种手糊加乱搞,但还是要总结一下. T1 Monkey Banana Problem 这 ...
- ajax跨域请求解决方案
大家好,今天我们学习了js的跨域请求的解决方案,由于JS中存在同源策略,当请求不同协议名,不同端口号.不同主机名下面的文件时,将会违背同源策略,无法请求成功!需要进行跨域处理! 方案一.后台PHP进行 ...
- Unity跨平台C/CPP动态库编译---可靠UDP网络库kcp基于CMake的各平台构建实践
1.为什么需要动态库 a)提供原生代码(native code)的支持,也叫原生插件,但是我实践的是c/cpp跨平台动态库,这里不具体涉及安卓平台java库和ios平台的objectc库构建. b)某 ...
- jmockit学习
下图为jmockit 类图.在我们编写代码时几乎都会用到Expectations(期望)和Verifications(校验),二者均继承自Invacations. 常会用到的注解有:@Mocked @ ...
- mysql主从同步+mycat读写分离+.NET程序连接mycat代理
背景 最近新项目需要用到mysql数据库,并且由于数据量大的原因,故打算采用1主1从(主数据库负责增.删.改操作:从数据库负责查操作)的数据库架构,在实现主从之后还要实现读写分离的代理,在网上搜寻了很 ...
- TCP:传输控制协议
概述: 书中采用了8章来介绍TCP,可见其重要性.TCP是一种面向连接的.可靠的字节流服务,也就是说两方要交换数据必须先建立一个连接. TCP的信息单位称为segment.TCP对字节流的内容不作任何 ...
- 移动端页面input输入框被键盘遮挡问题
<body class="layout-fixed"> <!-- fixed定位的头部 --> <header> </header> ...
- 《java.util.concurrent 包源码阅读》21 CyclicBarrier和CountDownLatch
CyclicBarrier是一个用于线程同步的辅助类,它允许一组线程等待彼此,直到所有线程都到达集合点,然后执行某个设定的任务. 现实中有个很好的例子来形容:几个人约定了某个地方集中,然后一起出发去旅 ...
- MapReduce 入门之一步步自实现词频统计功能
原创播客,如需转载请注明出处.原文地址:http://www.cnblogs.com/crawl/p/7687120.html ------------------------------------ ...
- MatlabR2015b用了一段时间之后需要重新激活
问题描述:MatlabR2015b安装成功,用了一段时间之后需要重新激活,按照http://www.cr173.com/soft/490645.html教程,无法激活成功,卸载重新安装也不行. 解决方 ...