Bash Environment configuration:
configuration file, the scope of effective, there are two categories:
Global configuration:
/etc/profile,/etc/profile.d/*.sh
/etc/bashrc
Personal configuration:
~/.bash_profile
~/.bashrc
By function, there are two categories:
Profile class: Provides configuration for the interactive logon shell
/etc/profile,/etc/profile.d/*.sh
~/.bash_profile
Function:
(1) Define environment variables, such as path, PS1
(2) run a command or script
BASHRC class: Provides configuration for non-interactive logon shell
/etc/bashrc
~/.bashrc
Function:
(1) Define command aliases;
(2) define local variables;
Variables: Memory space, variable name
Type:
Environment variables: scope current shell process and its child processes
Local variable: scope current shell process
Local variables: scoped only to a snippet of code in the current shell process (usually a function context)
Position variable: $ $, $
Special variables: $?
How variables are defined:
Bash built-in variables: can be called directly, built in a number of environment variables, such as Path
Custom variables:
Variable assignment: variable name = value
Bash Weak type:
When a variable stores data, it is written by default, and any variable can be directly referenced without being declared;
120:24bits
120:8bits
To define a local variable:
Name=value
View: Set
Define Environment variables:
Export Name=value
Declare-x Name=value
View: env, printenv, export
Undo Variable:
unset name
Reference variable:
${name}, $name
Reference symbols in bash:
': Strong reference, variable substitution does not occur
"": Weak reference
": Command Reference
Shell Logon Type:
Interactive login:
Login directly through the terminal;
User Switching implemented by su-l username command;
Non-interactive logon:
A command-line window opens under the graphical interface;
Execute the script;
Su Username;
Configuration file Action Order:
Interactive login:
/etc/profile--/etc/profile.d/*.sh--and ~/.bash_profile--~/.BASHRC--/ETC/BASHRC
Non-interactive logon:
~/.BASHRC--/ETC/BASHRC-/etc/profile.d/*.sh
How does the new configuration of the Edit profile definition take effect?
(1) Re-login;
(2) Let the current shell process to re-read the specified configuration file;
Source/path/to/somefile
. /path/to/somefile
Note: Side effects
Problem:
1. Define the aliases that are valid for all uses.
2. What if only the modification of the PATH environment variable takes effect for the root user?
Special permissions on the Linux file system
Permission model:
U, G, O
R, W, X
Security context for the process:
Prerequisite: The process is owned by the owner (the process is running as the user's identity);
(1) Whether the user can start an executable program file as a process, depending on whether the user has Execute permission on the program file;
(2) After the program is started as a process, the owner of the process is the current user, the initiator of the process, the group to which the process belongs, and the base group for the initiator;
(3) The access rights of the process, depending on the owner's access rights:
(a) The owner of the process and the owner of the document, the application document is the master authority;
(b) The owner of the process, belonging to the group of documents, the application file is a group of permissions;
(c) Apply other rights;
SUID:
(1) Any executable program file can be started as a process: depending on whether the initiator has EXECUTE permission on the program file;
(2) After initiating as a process, its owner is not the initiator, and the program file is the owner of its own, the mechanism is suid;
Permission settings:
chmod u+s FILE ...
chmod u-s FILE ...
Attention:
S: The owner of the original X permission;
S: The original owner has no x permission;
SGID:
By default, when a user creates a file, it belongs to the base group that the user is a member of;
Once a directory has been set with Sgid permissions, the user who has write permission to this directory has the same group as the directory, not the user's base group, to which the files created in this directory belong.
Permission settings:
chmod g+s FILE ...
chmod g-s FILE ...
Sticky:
For a multi-person writable directory, this permission is used to restrict each file that can only delete itself;
Permission settings
chmod o+t FILE ...
chmod o-t FILE ...
Practice:
1, so that ordinary users can use/tmp/cat to view/etc/shadow files;
2, create the directory/test/data, let a group of ordinary users have write permission to it, and all the files created by the group of directories belong to the group, in addition, each user can only delete their own files;
8-30 Bash Environment configuration and special permission descriptions on Linux