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 现代操作系统一般属于多用户的操作系统,也就是说,同一台机器可以为多个用户建立账户,一般这些用户都是为普通用户,这些普通用户能同时登录这台计算机,计算机对这些用户分配一定的资源. 普通用户在所 ...
随机推荐
- RobotFramework自动化测试框架-移动手机自动化测试Get Element Location关键字的使用
Get Element Location关键字用来获取一个Element的Location位置,该关键字接收一个参数[ locator ] 示例1:使用Get Element Location来获取一 ...
- centos7安装python3和Django后,ModuleNotFoundError: No module named '_sqlite3'
1.准备安装环境 yum groupinstall 'Development Tools' yum install zlib-devel bzip2-devel openssl-devel ncurs ...
- 项目实战2.2—nginx 反向代理负载均衡、动静分离和缓存的实现
实验一:实现反向代理负载均衡且动静分离 1.环境准备: 机器名称 IP配置 服务角色 备注 nginx VIP:172.17.11.11 反向代理服务器 开启代理功能 设置监控,调度 rs01 RIP ...
- Python之argparse模块
argparse 命令行参数解析模块,原optparse已经停止开发,建议替换为argparse 在python2.7后默认加入 parser ArgumentParser默认解析来源sys.argv ...
- [转]动态管理视图和函数 (Transact-SQL)
动态管理视图和函数返回可用于监视服务器实例的运行状况.诊断故障以及优化性能的服务器状态信息. 重要提示 动态管理视图和函数返回特定于实现的内部状态数据. 在未来的 SQL Server 版本中,它们的 ...
- AI 新技术革命将如何重塑就业和全球化格局?深度解读 UN 报告(上篇)
欢迎大家前往腾讯云社区,获取更多腾讯海量技术实践干货哦~ 张钦坤 腾讯研究院秘书长蔡雄山 腾讯研究院法律研究中心副主任祝林华 腾讯研究院法律研究中心助理研究员曹建峰 腾讯研究院法律研究中心高级研究员 ...
- bootstrap的模态简单案例
使用时需添加bootstrap的引用,否则实现不出来效果 <!DOCTYPE html> <html><head> <meta name="v ...
- configpraser模块
configpraser配置文件,example.conf [data] #节点 username = Jason password = 123 [public] comment = stuff pu ...
- jfinal 源码学习
源由 最近闲来无事,顺带看了下jfinal的源码,以下均为自己的个人理解,如有错误请指定: jfinal 使用 在web.xml中配置JfinalFilter 并定义JfinalConfig的类 自定 ...
- 深入理解js中的apply、call、bind
概述 js中的apply,call都是为了改变某个函数运行时的上下文环境而存在的,即改变函数内部的this指向. apply() apply 方法传入两个参数:一个是作为函数上下文的对象,另外一个是作 ...