标签:文件 empty ESS passwd tin 生成 有一个 cst groupadd
Linux是个多用户、多任务的操作系统
用户:
文件和进程对应用户关系
Linux用户分类
超级管理员:root
[root@oldboyedu ~]# id root #查看用户ID
d=0(root) gid=0(root) groups=0(root)
[root@oldboyedu ~]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@oldboyedu ~]# su - oldboy #切换用户
[oldboy@oldboyedu ~]$ logout
[root@oldboyedu ~]# vim /etc/passwd #修改用户ID
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sb
in/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
oldboy:x:0:1000:oldboy:/home/oldboy:/bin/bash
tcpdump:x:72:72::/:/sbin/nologin
"/etc/passwd" 22L, 1017C written
[root@oldboyedu ~]# su - oldboy
Last login: Fri Apr 10 18:52:44 CST 2020 from 10.0.0.1 on pts/0
[root@oldboyedu ~]# cd /root/
[root@oldboyedu /root]# cd ..
[root@oldboyedu /]# ^C
[root@oldboyedu /]# logout
[root@oldboyedu ~]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@oldboyedu ~]# su - oldboy
Last login: Fri Apr 10 18:53:33 CST 2020 on pts/0
[root@oldboyedu ~]# id
uid=0(root) gid=1000(oldboy) groups=1000(oldboy) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@oldboyedu ~]# whoami #查询当前用户
root
虚拟用户
普通用户
实际存在的用户,又允许他登入,管理员身份创建的,帮助管理员管理系统的。
UID:1000~60000
[root@oldboyedu ~]# useradd oldgirl #创建普通用户
[root@oldboyedu ~]# id oldgirl
uid=1001(oldgirl) gid=1001(oldgirl) groups=1001(oldgirl)
输入2次一样的新密码,注意输入密码的时候屏幕上不会有字符出现。
更新系统信息 touch /.authorelabel
最后输入以下命令重启系统即可
相当于集合、组织(比如人的家庭)
Linux里每个用户必须要有一个组织,这个组织就是叫做用户组
用户组也是给人看,用户组也有唯一标识,group ID 简称GID
默认情况创建用户,并没有创建用户组,他会自动创建一个用户组,和用户名相同的用户组,以及相同的GID
[root@oldboyedu ~]# id oldgirl
uid=1001(oldgirl) gid=1001(oldgirl) groups=1001(oldgirl)
一个用户(user)对应一个用户组(user group)
一个用户(user)对应多个用户组(user groups)
多个用户(users)对应一个用户组(user group)
[root@oldboyedu ~]# useradd oldgirl
[root@oldboyedu ~]# id oldgirl
uid=1001(oldgirl) gid=1001(oldgirl) groups=1001(oldgirl)
[root@oldboyedu ~]# useradd -g root text #创建用户指定用户组
[root@oldboyedu ~]# id text
uid=1002(text) gid=0(root) groups=0(root)
[root@oldboyedu ~]# groupadd sa #创建用户组
[root@oldboyedu ~]# useradd -g sa uu
[root@oldboyedu ~]# id uu
uid=1003(uu) gid=1002(sa) groups=1002(sa)
[root@oldboyedu ~]# id oldboy
uid=1000(oldboy) gid=1000(oldboy) groups=1000(oldboy)
[root@oldboyedu ~]# id root
uid=0(root) gid=0(root) groups=0(root)
Linux系统对文件安全权限要求严格
[root@oldboyedu /]# ls -lih /etc/sysconfig/
total 108K
33575490 -rw-r--r--. 1 root root 412 Apr 4 18:09 anaconda
34063111 -rw-r--r--. 1 root root 483 Apr 4 18:08 authconfig
16841044 drwxr-xr-x. 2 root root 43 Apr 4 18:22 cbq
16881480 drwxr-xr-x. 2 root root 6 Aug 9 2019 console
33743063 -rw-r--r--. 1 root root 150 Mar 18 07:59 cpupower
34061028 -rw-------. 1 root root 110 Aug 9 2019 crond
34061967 -rw-------. 1 root root 1.4K Apr 11 2018 ebtables-config
1 2 3 4 5 6 7 8 9 10
rwxr-xr-x:文件权限
789列:文件的最后修改时间
文件时间有三种
stat查看文件的所有时间
[root@oldboyedu ~]# stat /etc/hosts
File: ‘/etc/hosts’
Size: 158 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 16777794 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:net_conf_t:s0
Access: 2020-04-10 19:27:37.963000075 +0800
Modify: 2013-06-07 22:31:32.000000000 +0800
Change: 2020-04-04 18:05:04.725808731 +0800
Birth: -
-c 获取权限一部分
%A 显示字符权限
[root@oldboyedu ~]# stat -c %A /etc/hosts
-rw-r--r--
#练习一、修改访问时间和变化时间
[root@oldboyedu ~]# echo oldboy > test.txt
[root@oldboyedu ~]# stat test.txt
File: ‘test.txt’
Size: 7 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 34060899 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2020-04-10 20:26:41.347028313 +0800
Modify: 2020-04-10 20:26:41.347028313 +0800
Change: 2020-04-10 20:26:41.347028313 +0800
Birth: -
[root@oldboyedu ~]# echo oldboy >> test.txt
[root@oldboyedu ~]# stat test.txt
File: ‘test.txt’
Size: 14 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 34060899 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2020-04-10 20:26:41.347028313 +0800
Modify: 2020-04-10 20:26:59.226028455 +0800
Change: 2020-04-10 20:26:59.226028455 +0800
Birth: -
#练习二、修改变化时间
[root@oldboyedu ~]# stat test.txt
File: ‘test.txt’
Size: 14 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 34060899 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2020-04-10 20:26:41.347028313 +0800
Modify: 2020-04-10 20:26:59.226028455 +0800
Change: 2020-04-10 20:26:59.226028455 +0800
Birth: -
[root@oldboyedu ~]# chmod +x test.txt
[root@oldboyedu ~]# stat test.txt
File: ‘test.txt’
Size: 14 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 34060899 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2020-04-10 20:26:41.347028313 +0800
Modify: 2020-04-10 20:26:59.226028455 +0800
Change: 2020-04-10 20:29:18.668029566 +0800
第一列
文件节点
索引节点
inode和block
查看inode
[root@oldboyedu /]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 480007 370 479637 1% /dev
tmpfs 482665 1 482664 1% /dev/shm
tmpfs 482665 1227 481438 1% /run
tmpfs 482665 16 482649 1% /sys/fs/cgroup
/dev/sda3 9960960 72530 9888430 1% /
/dev/sda1 131072 334 130738 1% /boot
tmpfs 482665 1 482664 1% /run/user/0
查看block
[root@oldboyedu /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 19G 2.0G 18G 11% /
/dev/sda1 253M 161M 93M 64% /boot
tmpfs 378M 0 378M 0% /run/user/0
磁盘满的两种情况
提示:
#模拟磁盘被占满情况
[root@oldboyedu ~]# mkdir -p /app/logs
[root@oldboyedu ~]# dd if=/dev/zero of=/dev/sdc bs=8K count=10
10+0 records in
10+0 records out
81920 bytes (82 kB) copied, 0.000135709 s, 604 MB/s
[root@oldboyedu ~]# mkfs.ext4 /dev/sdc
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdc is not a block special device.
Proceed anyway? (y,n) y
Filesystem too small for a journal
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
16 inodes, 80 blocks
4 blocks (5.00%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
16 inodes per group
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
[root@oldboyedu ~]# mount -o loop /dev/sdc /app/logs/
[root@oldboyedu ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 52K 1.9G 1% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 19G 2.0G 18G 11% /
/dev/sda1 253M 161M 93M 64% /boot
tmpfs 378M 0 378M 0% /run/user/0
/dev/loop0 73K 14K 54K 21% /app/logs
[root@oldboyedu ~]# cd /app/logs/
[root@oldboyedu /app/logs]# touch {1..15}.txt
touch: cannot touch ‘6.txt’: No space left on device
touch: cannot touch ‘7.txt’: No space left on device
touch: cannot touch ‘8.txt’: No space left on device
touch: cannot touch ‘9.txt’: No space left on device
touch: cannot touch ‘10.txt’: No space left on device
touch: cannot touch ‘11.txt’: No space left on device
touch: cannot touch ‘12.txt’: No space left on device
touch: cannot touch ‘13.txt’: No space left on device
touch: cannot touch ‘14.txt’: No space left on device
touch: cannot touch ‘15.txt’: No space left on device
[root@oldboyedu /app/logs]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 52K 1.9G 1% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 19G 2.0G 18G 11% /
/dev/sda1 253M 161M 93M 64% /boot
tmpfs 378M 0 378M 0% /run/user/0
/dev/loop0 73K 15K 53K 23% /app/logs
[root@oldboyedu /app/logs]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 480007 375 479632 1% /dev
tmpfs 482665 1 482664 1% /dev/shm
tmpfs 482665 1233 481432 1% /run
tmpfs 482665 16 482649 1% /sys/fs/cgroup
/dev/sda3 9960960 72669 9888291 1% /
/dev/sda1 131072 334 130738 1% /boot
tmpfs 482665 1 482664 1% /run/user/0
/dev/loop0 16 16 0 100% /app/logs
模拟磁盘空间被占满
[root@oldboyedu /app/logs]# rm -rf *
[root@oldboyedu /app/logs]# ll
[root@oldboyedu /app/logs]# cp /bin/cat ddd
[root@oldboyedu /app/logs]# cp /bin/cat ddddd
cp: error writing ‘ddddd’: No space left on device
cp: failed to extend ‘ddddd’: No space left on device
[root@oldboyedu /app/logs]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 80K 1.9G 1% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 19G 2.0G 18G 11% /
/dev/sda1 253M 161M 93M 64% /boot
tmpfs 378M 0 378M 0% /run/user/0
/dev/loop0 73K 72K 0 100% /app/logs
第三列
文件硬连接数
普通文件硬连接数为1
目录硬连接数为2
是因为还有本身目录(.)
[root@oldboyedu /]# ls -lihd /data/ /data/.
34060900 drwxr-xr-x. 2 root root 137 Apr 10 20:36 /data/
34060900 drwxr-xr-x. 2 root root 137 Apr 10 20:36 /data/.
标签:文件 empty ESS passwd tin 生成 有一个 cst groupadd
原文地址:https://www.cnblogs.com/sunyuhang1/p/12676100.html