Login shell and non-Login shell

You use an interactive shell when you enter commands at the shell prompt; you use a non-interactive shell when you run a shell script.

Whenever you log in, the shell that starts is called a LOGIN SHELL. All other interactive shells are called NON-LOGIN SHELLS

The distinction is important because initialization fi les are processed differently for login shells than for non-login shells.

1. Virtual consoles and terminal windows
When you use a desktop environment, such as Gnome or KDE, there are two ways to get to a shell prompt: you can open a terminal window, or you can change to a virtual console When you use a virtual console — say, by pressing <Ctrl-Alt-F1> — you
are required to log in. When you do, a login shell starts. On the other hand, if you simply open a terminal window, a non-login shell starts (because you did not log in).

2. Starting a new shell
At any time, you can start a new shell by entering its name. For example, say you are using Bash, and you want to try the Tcsh. Just enter the tcshcommand. The new shell is a non-login shell (because you did not log in)

3. Using a remote host
To connect to a remote Unix host, you use the ssh(Secure Shell) program. Once ssh makes the connection for you, you must log in. Doing so starts a login shell.

1. A login shell executes your login file andyour environment file.
2. A non-login shell only executes your environment file

 Thus, your login file should contain commands to (1) create or modify environment variables, and (2) perform all one-time actions.

As we discussed earlier in the chapter, the environment is automatically inherited by all child processes, including new shells. Thus, you only need to set environment variables (such as PATH) once, in your login file.

转载于:https://www.cnblogs.com/hshuzhao/archive/2013/04/02/2996509.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值