1. File permissions
In the Linux terminal, enter the command ll can view the details of all the files under the current folder, where the first column represents the permissions of the file, such as Drwxrw-r--.
The first character, either "D" or "-", "D" means a directory, "-" means a file.
The following nine characters, divided into three groups, that is, rwx,rw-,r--, the first group represents the user (owner) permissions, the second group represents the group (the owner of the groups within the user) has permissions; The third group is the permissions that other users have. R represents the Read permission, W represents write permission, x represents the Execute permission,-indicates that the current user does not have the permission. (-w-permissions can occur, that is, you can write content, but you cannot see what is written, and this permission is not normally set.) )
Set permissions:
cd/tmp/Open File
Touch File1 wear a file1 file
Change Permissions chmod
chmod u=rwx file1 Set owner (user) permissions
chmod u=rwx,g=rwx,o=rwx file1 set permissions, U=user,g=group,o=other
chmod 777 File1 is equivalent to the previous line (a three-bit binary number can be used to represent a set of permissions.) With this permission, the bit is 1, otherwise 0, such as RWX's permission is 111, the decimal representation is 7, therefore, 764 means that the user's permission is rwx,group permission is the Rw-,other permission is R--。 )
chmod u+x file1 Add permissions to add execute permissions to user users
chmod u-x file1 Remove Permissions and Cancel Execute permissions for user users
chmod a+w file1 Add Write permission to everyone, A=all all users Ugo
2. Scripts
Linux under the Bash language file extension is. sh perl extension. pl python to. py
Weak variables: Determining variable types based on assignment type
echo character (string): Prints the character (string) to the screen in the form of a standard output.
The echo $a prints out the value of the variable A. $a take out the value of a
Touch user.sh Create a file and write a script
The following is the contents of the script file:
#! /bin/bash the first line, declares the shell used by the script
For x in 1 2 3 (where there is a space) or write as $ (seq 1) for loop
Do
Useradd user$x Create user User1,user2,... change depending on X value
Finished for loop
Two ways to do this:
Bash user.sh execution
./user.sh execution
This article is from the "Raffaele" blog, make sure to keep this source http://raffaele.blog.51cto.com/6508076/1554488
Linux Learning Note 5-file permissions and scripts