Review:
File management: LS, cat, TAC, tail, head, more, less, CP, MV, RM, touch, stat, file, nano
User management: Useradd, Usermod, Userdel, passwd, Groupadd, Groupmod, Groupdel, id, su, chage, Chfn, Chsh, Newgrp, gpasswd
User type:
Admin: 0
General Users: 1-65535
System users: 1-499,
The role of these users is that the system has just started to be used to start the processes of the system users, because the process is dependent on the user to create, indicating which resources can be accessed.
Ordinary users: the researcher
Userdd
-R: This is to create a system user,
Do not create home directories for users, start Bin/nologin, unable to log in users, so these system users are set for security period
Group Type:
Basic Group
Additional groups
Linux file types: All file types can be viewed using the document command
Normal file:-,f
Catalog: D
Link file: L (soft link)
Device files:
Character device (linear device): C
Block device (random device): b
Named pipes: P
Socket file: S
-D
-g-n
-L
Rights Management: Owner, group
File attributes have the concept of belonging to and belonging to the group:
Three types of users
Owner, group, other
File1:fedora, Fedora
Permissions: Divided into three types, read, write, execute
R, W, X
File:
R: You can use the Content view Class command to display its related content;
W: You can use the editor to modify its contents;
X: It is possible to initiate a process;
Catalog Files:
R: You can use the LS command to view the directory contents of the file information;
W: can create, delete files;
X: You can use the Ls-l command to view file information for the contents of the directory, and you can use the CD command to switch the directory to the working directory;
The user does not own a certain permission, then uses the-placeholder;
R-x:
r--
rw-
-rw-r--r--1 root root 852 Jul bincp.sh
:---, 0
001:--x, 1
010:-w-
011:-wx
100:r--
101:r-x
110:rw-, 6
111:RWX, 7
6:rw-
5:r-x
640:rw-r-----
With three-bit octal, you can represent three types of permissions.
Meta data, attributes, Inode:
An index node has an index node number, which stores the timestamp, permissions, owner, genus, size, and disk blocks of each file.
The user's permissions are put in the metadata of the file that exists.
Modify the owner, genus Group: admin only, Chown (change owner), CHGRP
Change file permissions: chmod
chmod command:
Permission to operate three types of users: using 8 binary form
chmod [-R] Octal-mode (octal) file ...
ACTION Specifies the permissions of the category User: Use U,g,o,a to assign weights, based on = or +/-
[Email protected] ~]# chmod u=rw,g=rw,o= [email protected]
[Email protected] ~]# chmod-r u+x g-x [email protected]
[[email protected] ~]# chmod +x [email protected] Execute permissions directly to the file plus all users
chmod Default does not modify the internal file permissions, need to add optional-R
U: Owner
G: Genus Group
O: Other
A: All
=: Operation permission of the specified category user; u=, ug=, u=,g=
+/-: Operation individual permissions for the specified category user: U-x, g+r, O-x, +x
Permissions to refer to other files are granted when a file is assigned
chmod--reference= file to modify permissions for the file to be referenced
rw-r--r--: rwxr-xr--
Common Permissions Models:
755:rwxr-xr-x
644:rw-r--r--
700:RWX------
600
750
640:rw-r-----
040
Umask: Each user has his or her own umask
Create file: 666-umask= octal permissions
The file default is never allowed to execute permissions;
Umask 023
666-023=644, if the last one appears is odd then +1 operation
Create directory: 777-umask
You can use umask+ numbers to modify the current user's umask
root:022
If the user name and the base group name are the same: 002; otherwise 022;
!!!!!!!!!!!!!!!!!!!! Important!!!!!!!!!!!!!!!!!!!!!!!!
Modify the owner or genus of a file:
Chown, Chgrp here is the file.
-R: Recursive, so that the directory is changed
--reference=
chown [option] username[{:|.} GroupName] File ... Change the owner of the file
Chown Root:root/tmp/permfile can simultaneously modify a file's owner and owner group
Very important!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Permissions Application Model:
Note file: Drwxr-xr-x 2 root root 4096 Oct 7 12:40 2015-10-07-12-40
The current process is to run as the current user's identity;
The owner of the process is the same as the owner of the file, and if it is the same, the process accesses the file with the permission of the owner of the file;
The group to which the owner of a process belongs, whether one is the same as the genus of the file, or, if the same, the process accesses the file with the permissions of the filegroup;
The process accesses the file with the permission of the other user of the file;
Practice:
1. Create a new user OpenStack, but do not give it a home directory; After creation, use the SU command to switch to this user to view its command prompt and the values of the path and home environment variables;
# useradd-m OpenStack
# Su-openstack
# echo $PATH $HOME
2, copy/etc/skel directory for/home/openstack;
# Cp-r/etc/skel/home/openstack
3, change/home/openstack and its internal documents belong to the main group are openstack;
# Chown-r Openstack.openstack/home/openstack
4,/home/openstack and its internal files, belong to the group and other users do not have any access rights;
# chmod-r go=/home/openstack
# Su-openstack
# echo $PATH $HOME
Practice:
Complete the following tasks:
(1) New System group MySQL, new system user MySQL, belongs to MySQL group, requires that it has no home directory and shell for/sbin/nologin;
# groupadd-r MySQL
# useradd-r-s/sbin/nologin-g MySQL MySQL
(2) The new group of GID is 600 magedu; new user Gentoo, request their home directory for/users/gentoo, password and user name;
# groupadd-g Magedu
# mkdir/users must make sure it's there first
# useradd-d/users/gentoo Gentoo
# passwd Gentoo
(3) New user CentOS, whose home directory is/users/centos, password and user name;
# useradd-d/users/centos CentOS
# passwd CentOS
(4) New user www, whose home directory is/users/www; Delete www users, but keep their home directory;
# useradd-d/users/www www
# Userdel www
(5) User Gentoo and CentOS are magedu as their additional groups;
# usermod-a-G magedu Gentoo
# usermod-a-G magedu CentOS
Summary Rights Management: Chmod, Chown, Chgrp, umask
Bash Introduction:
Shell: human-computer interface
SH, csh, tcsh, bash, ksh, Dash, zsh
BASH: command interpreter, can explain what the instructions are, where to find the appropriate program, sent to the kernel
Bash feature SIX: Bash shortcut keys
CTRL + A: Jump to the beginning of the command
Ctrl+e: Tail
Ctrl+u: Deletes the contents of the command line from the beginning to the current cursor location
Ctrl+k: Delete the contents of the current cursor at the end of the command line
Ctrl+l: Clear screen, equivalent to clear command
CTRL + C: Cancel or terminate;
CTRL + Z: Send the current command to the background
Bash feature VII: Bash completion
Command completion:
Shell command: Internal, external
External: There is an executable program under a path in the system
which+ command to view the specific path of the command
Path, a colon-delimited set of paths that the directive defaults to to find the path of the executing program
command can be run with full path + instruction
Use the TAB key to perform a complete completion
Path completion: The completion of the given head path, or the current if there is no head path;
#,$
BASH: Interpreter, parser
Programming Languages:
C: Keywords, selection, order
Compiler: Language platform
Interpreter: Language platform
Program execution Logic:
Sequential execution
Select Execution (condition)
Cyclic execution: 1+...+100
Dynamic Language:
Apply for space at any time
Explanatory type
Perl, bash, Python
Static language:
Reasonable allocation of space in advance, high efficiency
Compiled type
C, C + +
Variable:
Data storage format:
Ascii:11 character encoding
Binary:11
Divide according to whether their variables need to be strictly defined by their type:
Strongly typed language: C requires the type of the variable to be pre-declared
Weakly typed language: Bash
Define the role of the variable type:
1, data storage format;
2, the effective storage range of data;
3, the comparison mechanism is different;
4. The type of operation involved is different;
Character type
Numeric type: positive, negative
Precise numerical type:
Integral type:
Approximate numerical type:
Floating point number
Single precision
Double precision
Boolean type:
Bash feature VIII: providing a programming environment
Variable
Program
#!/bin/bash the first line of the script file to tell the kernel which interpreter to use!!!!!! Which interpreter to use to interpret the script
Claims to be shebang
#! is to tell the kernel that this is a program entry, and the subsequent kernel discovery is an interpreter, then it is considered not a simple executable program, it will invoke the interpreter to process the contents of the file
Each file has permission control, through the X this executable program flag, can determine whether the kernel processing
Add permission chmod +x file name
For example, LS is an instruction, is a binary program, to the kernel, the kernel to find the program's entry execution can
Exercise: Write a script
1, create a group newgroup, the ID number is 4000;
2, create a user mageedu1, ID number 3001, the additional group is newgroup;
3. Create Directory/TMP/HELLODIRXYZ
4, copy the/etc/fstab to the above directory
5. The owners and genera of the directories and internal documents are mageedu1;
6, let the directory and other users of internal documents do not have any permissions;
#!/bin/bash
# Description:
# Version:
# Datetime:
# Author:
mygroup= "Newgroup1"
Myuser= "MAGEEDU2"
Mydir= "/TMP/HELLODIRXYZ1"
myid=3002
Groupadd-g 4001 $myGroup
Useradd-u $myID-G $myGroup $myUser Note-u
mkdir $myDir
Cp/etc/fstab $myDir
Chown-r $myUser: $myUser $myDir Note-R
Chmod-r o= $myDir
unset mygroup myUser MyID MyDir
Learning Log---linux punch 6