13-Linux core knowledge - File Properties - Central

After the first column of nine characters represent the permissions linux
9 (12)
of the underlying permission divided into three groups:
-RW- r-- r-- 1 yuyu yoyo Exam
own family items

rw- r-- r--
user permissions user group other permissions

User rights: file corresponding to the user, the file permissions, see the previous three
user group permissions: file corresponding to the user group, the permissions on the file, saw three
other rights: neither own, is not user groups, after the file permissions to other users to see 3

File permissions representation
r read read access: cat / etc / hosts (information not be disclosed)
w write permission to write: vim echo
permission x execute execute: an executable program

  • Permission denied

Linux actually identify the user and group identity instead of the user and group names, but UID and GID, the user name is the administrator of
users and groups:
Linux users is a very important role.

Username root name
identity uid (User Identify)

User group name root
identity: gid (Group Identify)

All existing file should correspond to a user and group, including: files, directories, processes

Files created by default: Users and Groups are current users and groups

The first landing is not permitted root, only ordinary users

Delegation of authority:
1, root for all operation and maintenance personnel: wrong
su -root cut to root privileges
2, root accordance with the ordinary user tasks, assign specific permissions (permission to use a command)
sudo command to achieve

2, ordinary users
of civilians
in general can only be managed at home directory, the home directory can not exceed the
UID 500 more than for the C7 C6 1000 systems
use developers, many files can not try to change and delete. Home directory (/ tmp) can be deleted

3, virtual users (puppet)
virtual users is to satisfy the following environment:
all existing files should correspond to the needs of a user and group
do not want to log in, the device can not log
UID 1-99 C6 1-999 C7

How virtual user is generated?
1, the installation software automatically generates
2, the administrator user created

[root@manager /home]$ useradd mysql -M -s /sbin/nologin
[root@manager /home]$ id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)

/ Sbin / nologin that they can not log in

[root@manager /home]$ useradd  -u 1100 -M -g uuu -s /sbin/nologin uuu
[root@manager /home]$ id uuu
uid=1100(uuu) gid=1001(uuu) groups=1001(uuu)

The relationship between users and groups:
Linux operating system is a multi-user multi-tasking

The relationship between users and groups of
one to one
-to-many
many-to
-many

User-related commands
useradd
userdel
the usermod
groupadd
groupdel

To show file sizes ls -lh
display the contents of the directory plus the size of du in units -sh / etc

[root@manager /home]$ stat /etc/hosts
  File: ‘/etc/hosts’
  Size: 10240       Blocks: 24         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 33689918    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:net_conf_t:s0
Access: 2019-12-04 17:58:29.694161675 -0500
Modify: 2019-12-04 17:08:23.000000000 -0500
Change: 2019-12-04 17:20:26.494268101 -0500
 Birth: -

Access Access is access time is seen
Modify modification time, content changes
Change to change / change time, change the attribute (size)
LS default display is to modify the -l time

find the corresponding parameters
-ctime
-mtime *
-atime

[root@manager /exam]$ ls -lhi
total 28K
 67151519 drwxr-xr-x. 3 root root   18 Nov 21 07:18 ceo
101164638 -rw-r--r--. 1 root root   11 Dec  2 19:28 exam.txt
101253824 -rw-r--r--. 1 root root  465 Nov 21 10:23 fstab
101253825 -rw-r--r--. 1 root root  158 Nov 21 10:25 hosts
101164635 -rw-r--r--. 1 root root   86 Dec  2 19:26 police.md5
101164666 -rw-r--r--. 1 root root  352 Nov 19 10:51 reg.txt
101164667 -rw-r--r--. 1 root root   86 Nov 19 12:29 sed.txt
101256163 drwxr-xr-x. 6 root root 4.0K Nov 21 10:23 sysconfig

Inode, inode (index node)
Each file corresponds to one and only one inode
inode uniquely identifies a file
inode is a storage space, the size of C5 128 / C6 256 bytes in size
index nodes storing things: File pointer to the file attribute information of the entity / location
but does not include the file name (Block directory).

Create a file system is formatted
for ext (ext2 ext3 ext4) file system:
generating at least two things:
inode: inode, space for file attributes, 256 bytes. 2,000,000 generates
a uniquely identify each file
2, file inode are mutually the same hard-linked files
3,256 bytes
4, and the pointer to the file attribute information of the entity
block: storing content entity generates 5000000
1 , store the file contents
2,1K, 2K, 4K
3, a block can only store a file
0.1K accounted for a block, waste of 3.9K (can not put things)
1M files accounted for 25 block
4, the system is in accordance with the block size read take the file.

block大还是小?
大的好处:
1M block  100M  100次读完 。 IO
大的坏处
1K  100M  100000次读完
当小文件多的时候会浪费磁盘空间

Guess you like

Origin blog.51cto.com/1674389/2456117