The shell has a shell meaning, which provides the platform for the user to interact with the kernel, and the kernel then implements the functionality through the underlying system call. Features of the Linux shell:
1. Shortcut: Ctrl + A (ahead) move the cursor to the front
Ctrl+e (end) moves the cursor to the last
CTRL + C (cancel) Cancel command execution
Ctrl+d (equivalent to logout)
Ctrl+r (read history) (Ctrl+r Search to the Historical command tab to modify the query to the command)
2. Other Shortcuts
!! Represents a call to the previous command
! (NUM) executes a history command for the director as Num
! -(NUM) executes the countdown num history command
The shell is an explanatory language, and, like other high-level languages, it has its own variables.
Variables in the shell are divided into local variables and environment variables (System level), equivalent to local variables and global variables in high-level languages
There are many system-defined environment variables in the Linux shell, which can be queried using ENV or SET commands.
Common environment Variables are: PS1, PATH, PWD, MAIL, histsize (variable histsize, command save to content, save to command history file ~/.bahs_history), HOSTNAME, Lang, etc.
Example: The pathvariable is the search path for the command , just like windows. The way to add a PATH variable in the shell can be:path= $PATH:/dir '
(They have a feature that is all capital letters, though not necessary, but a long-established constraint)
difference : The local variable is valid only in the current shell, and the environment variable is valid in the current shell and its child shell
So the question is, how do you set local variables and environment variables?
Define Local variables can be entered directly inside the shell: variable name = variable Value
The local variable is then exported to the environment variable: Export variable name
To delete a defined variable, use the command:unset variable name
You can also alias the command with the alias command
Format: Alias New_value/command=old_value/command
To cancel an alias by: Unalias command
Today's focus is on the shell's landing process, which is very important
So when we landed on the shell, wouldn't it be possible to use them without defining a path and so on?
This is because when a user logs in to the shell, various configuration files are read to obtain the initialized user's environment and system environment.
Landing process is divided into standard landing and non-standard landing
In a literal sense, the standard landing is the need to involve password authentication of the landing process, non-standard landing is not required to involve the password authentication of the landing process
Let's look at the differences between the two different landing methods:
1, first look at the standard landing process:
After the user enters the password to pass the authentication, the system will first read/etc/profile this configuration file (changes the file to define some system level environment variables, as well as some system settings)
By executing the contents of the/etc/profile file to read the/etc/profile.d/*.sh ( if the user wants to perform at boot time, you can create a. sh file in the/ETC/PROFILE.D directory)
Read ~/.bash_profile again(to define the environment variables for the current user)
Then read ~/.BASHRC (used to define the current user's command alias and Jump to/ETC/BASHRC)
Last Read/ETC/BASHRC
/ETC/BASHRC will return to/etc/profile.d/*.sh after the content is executed.
2, next we look at the non-standard landing process
~/.bashrc
/etc/bahsrc
/etc/profile.d/*sh
At this point we understand the login process and the non-login process configuration file read the difference, when we define the variable, we need to consider the location of the variable in effect, when writing to the configuration file is not allowed to take effect.
In addition: The SU command has two modes of switching, SU User is non-login, su-l user is login mode
This is my first blog, hope everyone will like!!! Hope to help everyone!
Shell variables and landing