Interactive shell vs. non-interactive shell

Source: Internet
Author: User
Tags ssh server

The first point is clear:/etc/profile is the configuration file that sets the environment variables for all users,/home/omm/.profile is the configuration file (omm User) that sets environment variables for a specific user .

But the important difference is: /etc/profile It's not always loaded. It wants to differentiate between login,non-login,interactive and non-interactive. mode of the case.

Loginlog in on behalf of the user, such as using"Su-"Command, or withSSHconnect to a server, will use the user's defaultShellStartLogin Shell mode. in this mode Shellwill go to automatic execution/etc/profileand the~/.profilefile.

no-login Shell Span style= "color: #1f497d; Font-family: The case of the song body is that we enter under terminal Span style= "color: #1f497d; font-family: Arial "> or Bash-c" CMD " Shell This mode is not automatically run any profile file.

Interactive Shell is interactive Shell, as the name implies is used to interact with the user , provides a command prompt to enter commands.

non-interactive Shell It is generally through bash-c "CMD" to execute. Bash .

SSH Login or sudo or Su-[USER] the commands are typical. Interactive Login Shell

but SSH server CMD Executing a command or executing a remote command through a program should theoretically be both a non-interactive non-login (non-interactive and non-logged) and it will not perform /etc/profile the.

Figure 1

Please refer to the information:

Https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

Https://www.gnu.org/software/bash/manual/html_node/Interactive-Shells.html#Interactive-Shells

Https://wido.me/sunteya/understand-bashrc-and-profile

Http://www.cnblogs.com/qcly/p/3273373.html

Understanding the above scenario, it is more clear.

the memory problem is due to the call to the Curl command to cause. The order of invocation is as follows:

Curl, hdfs-service-check.sh, nodeagent-

because of controller ssh call start nodeagent by the previous description, it is a non-interactive non-login shell

will not be called to load /etc/profile This leads to the nodeagent no nss This environment variable, nodeagent call hdfs-service-check.sh ,

because the child process inherits the environment variables of the parent process, hdfs-service-check.sh also no NSS environment variables, so Curl command still exists

Memory issues.

so why would NSS variables are added to the /home/omm/.profile can you do that?

that's because Fusioninsight The file was loaded with the active explicit invocation.

from this call graph below, you can also see the start nodeagent explicitly loaded when the /home/omm/.profile File:

Figure 2

Interactive shell vs. non-interactive shell

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.