Linux Shell Programming Notes-File security and permissions __ block chain

Source: Internet
Author: User
Tags chmod
1, Documents: 1.1, the file access to 3 kinds of ways:
1 read (show file contents), 2 write (edit, delete, modify permission), 3 execute (Run shell script, program, etc. executable files).
1.2, the file can be divided into 3 kinds of permissions:1 The file is the main 2) the same group of users 3 other users.
The permissions of a file are represented by a 9-bit permission bit, which can be seen through list-l.
1.3. File type:A flag number in front of the 9-bit permission bit that represents the type of file. 1.4, the file type of Linux:
D Directory
L Symbolic Link (point to another file)
s socket file
B Block Device file
C Character device file
P Named pipe file
-Common documents
1.5, create the file:
Touch filename
1.6, change the file permission bit:
chmod [who]operator[permission] filename #命令格式;
chmod g-w myfile #修改单个文件的权限;
chmod g-w ~/documents/shellt/* #修改目录下所有文件的权限;
Chmod-r g-w ~/documents/shellt/* #修改目录下及子目录下的所有文件的权限;
2, Table of contents:
2.1, the Directory access to 3 kinds of permissions:
1), read (the contents of the list), 2, write (can be created in the file); 3 Execute (searchable and accessed the directory);
Access to the directory overrides the access rights of the files in the directory.
3, suid, GUID permission bit:
The X permission on the file's permission bit, which becomes S. The following figure: Ping this shell file has the S permission bit.

The meaning of the suid permission bit: If a shell script is set to be such a permission, other users will also have the permissions of the primary user when executing the file. Suid permission bits are often used to perform database backups or other administrative work in a Linux cluster.
chmod u+s <filename> #用符号方式设置文件具有suid权限位, but before setting up, you must ensure that the file has X permissions.
4, the ownership of the document:
When a user creates a file, the user is the owner of the file and owns the file;
Only the primary user and the system administrator can change the ownership of the file;
chmod [-R] [h] who file #可选:-r contains the files under the subdirectory,-H does not affect the target file of the symbolic connection;
CHGRP [-R] [-h] who file
View information about the user group for the current user:

5, the user creates the file the default permission configuration (umask):
When each user is created, the user is set to create a default configuration for the file. When a user creates a new file, they do not need to specifically specify the access rights of the file.
6. Symbolic Link:
Symbolic links are: soft links (pointers to files), hard connection, the target of symbolic links are 2 kinds: directories, files;
Use the soft link of the file to realize multiple images of the file, modify the source file, and the image file will be modified accordingly;
Ln-s Source_path Target_path #创建软链接;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.