Logon and non-logon & interactive and noninteractive shell and its environment initialization process

Source: Internet
Author: User
Tags terminates

    • Interactive shell and non-interactive shell (interactive shell and non-interactive shell)

The interactive mode is executed on the terminal, the shell waits for your input, and executes the command you submitted immediately. This pattern is called interactive because the shell interacts with the user. This pattern is also familiar to most users: Log in, execute some commands, and exit. When you quit, the shell also terminates.

The shell can also run in a different mode: non-interactive mode, executed in shell script (non-interactive) way. In this mode, the shell does not interact with you, but instead reads the commands stored in the file and executes them. When it reads the end of the file, Eof,shell terminates.

You can distinguish between interactive and noninteractive shells by printing the value of the "$-" variable (which represents the option flag for the current shell) and viewing the "I" option (representing the interactive shell).

[Email protected]:~/workspace/shell$ Echo $-
Himbh
[Email protected]:~/workspace/shell$./test.sh
Echo $-
Hb

    • Login shell and non-login shell

Login Shell: A shell that requires a username, password login to enter (or a shell generated through the "–login" option).

Non-logon shell: Of course, you do not need to enter a user name and password to open the shell, for example: direct command "Bash" is to open a new non-login shell, in GNOME or KDE open a "terminal" (terminal) window program is also a non-login shell.

Execute Exit command to exit a shell (login or non-login shell);
Execute the logout command to exit the login shell (you cannot exit the non-logon shell).

The initial whole process for a login bash environment is:
/etc/profile
|
--/etc/profile.d/*
~/.bash_profile
|
--~/.bashrc
|
--/etc/bashrc
|
--/etc/profile.d/*
The initial whole process of a normal interactive bash is:
~/.bashrc
|
--/etc/bashrc
|
--/etc/profile.d/*
The initial whole process for non-interactive bash is:
Do not re-source any new shell scripts, only inherit the settings of the current shell

Logon and non-logon & interactive and noninteractive shell and its environment initialization process

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.