linux学习笔记
组管理和权限管理
文件或目录的所有者 chown
- 查看文件所有这
ls -l - 修改文件所有者:
chown [OPTION]... [OWNER][:[GROUP]] FILE...
[root@VM-0-8-centos liyf]# ls -l
总用量 4
-rw-rw-r-- 1 liyf liyf 0 12月 28 22:34 index.js
drwxrwxr-x 2 liyf liyf 4096 12月 28 22:34 test
[root@VM-0-8-centos liyf]# chown tom index.js
[root@VM-0-8-centos liyf]# ls -l
总用量 4
-rw-rw-r-- 1 tom liyf 0 12月 28 22:34 index.js
drwxrwxr-x 2 liyf liyf 4096 12月 28 22:34 test
文件或目录的所在组 chgrp
- 查看文件所在组
ls -l - 修改文件所在组
chgrp [OPTION]... GROUP FILE...
# 创建一个组
[root@VM-0-8-centos liyf]# groupadd master
# 再组下创建一个用户
[root@VM-0-8-centos liyf]# useradd -g master fox
# 设置密码
[root@VM-0-8-centos liyf]# passwd fox
# 切换用户
[root@VM-0-8-centos liyf]# su fox
[fox@VM-0-8-centos liyf]$ cd ~
[fox@VM-0-8-centos ~]$ touch index.html
[fox@VM-0-8-centos ~]$ ls -l
总用量 0
-rw-r--r-- 1 fox master 0 12月 28 22:51 index.html
# 修改组
[root@VM-0-8-centos fox]# chgrp frout index.html
[root@VM-0-8-centos fox]# ll
总用量 0
-rw-r--r-- 1 fox frout 0 12月 28 22:51 index.html
改变用户所在组 usermod
- 改变用户所在组
usermod -g 新组名 用户名
[root@VM-0-8-centos fox]# id tom
uid=1001(tom) gid=1001(tom) 组=1001(tom)
[root@VM-0-8-centos fox]# usermod -g frout tom
[root@VM-0-8-centos fox]# id tom
uid=1001(tom) gid=1003(frout) 组=1003(frout)
权限的基本介绍
drwxr-xr-x 3 root root 4096 12月 17 13:57 dist
1.第一位确定文件类型(l - d c b)
l链接-文件d目录c字符设备文件,鼠标键盘b块设备文件,硬盘r读 4w写 2x执行 1
1-3所有者的权限4-6文件所在组的用户的权限7-9除所有者和所再组的用户的权限
1.rwx 作用在文件
r读取文件w修改文件,对文件的删除权限是对文件所在目录有写权限x执行文件 2.rwx 作用在目录r可以读,ls查看目录内容w修改目录,对目录重命名,对目录内文件读写x可以进入该目录 cd
[root@VM-0-8-centos dev]# ls -l
总用量 0
crw------- 1 root root 10, 235 12月 7 10:45 autofs
drwxr-xr-x 2 root root 100 12月 7 10:45 block
drwxr-xr-x 2 root root 60 12月 7 10:45 bsg
crw------- 1 root root 10, 234 12月 7 10:45 btrfs-control
drwxr-xr-x 3 root root 60 12月 7 10:45 bus
lrwxrwxrwx 1 root root 3 12月 7 10:45 cdrom -> sr0
...
修改文件或目录的权限 chmod
- +、-、= 变更权限 u:所有者,g:所有组用户,o:其他用户,a:g+u+o
- chmod u=rwx,g=rw,o=r 文件/目录
- chmod u+w 文件/目录
- chmod u-w 文件/目录
- 通过数字修改
- chmod 751 文件/目录
修改文件所有者 chown
NAME
chown - change file owner and group
SYNOPSIS
chown [OPTION]... [OWNER][:[GROUP]] FILE...
-R 递归的修改
[root@VM-0-8-centos tom]# ll
drwxr-xr-x 2 tom tom 4096 12月 30 23:28 dist
-rw-r--r-- 1 tom root 0 12月 30 23:20 index.js
# 修改目录的所有者或所在组
[root@VM-0-8-centos tom]# chown root:frout dist
[root@VM-0-8-centos tom]# ll
总用量 4
drwxr-xr-x 2 root frout 4096 12月 30 23:28 dist
-rw-r--r-- 1 tom root 0 12月 30 23:20 index.js
[root@VM-0-8-centos tom]# ls dist/ -l
总用量 0
# 子目录和文件的权限没变
-rw-r--r-- 1 tom root 0 12月 30 23:28 index.html
-rw-r--r-- 1 root root 0 12月 30 23:26 index.js
crond定时任务调度
在LINUX中,周期执行的任务一般由cron这个守护进程来处理[ps -ef| grep] cron读取一个或多个配置文件,这些配置文件中包含了命令行及其调用时间。
cron的配置文件称为“crontab”,是“cron table”的简写。