该命令的作用是什么? "exec bash -l" [英] What does this command do? "exec bash -l"
问题描述
此命令做什么?
exec bash -l
我发现此命令是提醒文本文件的一部分,当时我写了一些有关如何创建ssh密钥和克隆git repo的说明,但是我很久以前就写了它,我不记得它的作用.
I found this command as part of a reminder text file were I wrote some instructions regarding how to create a ssh key and clone a git repo, but I wrote it a long time ago and I can't remember what it does.
推荐答案
exec
执行指定的命令,替换当前进程,而不是启动新的子进程.
exec
executes a specified command, replacing the current process rather than starting a new subprocess.
如果您输入
bash -l
在shell提示符下,它将调用一个新的shell进程(-l
使其成为登录shell).如果退出该Shell进程,则将返回到原始的Shell进程.
at a shell prompt, it will invoke a new shell process (the -l
makes it a login shell). If you exit that shell process, you'll be back to your original shell process.
输入
exec bash -l
表示新的shell进程替换您当前的shell进程.这可能会减少一些资源消耗.
means that the new shell process replaces your current shell process. It's probably slightly less resource intensive.
这样做的原因可能是因为新的shell设置了其环境(通过阅读.bashrc
,.bash_profile
等).
The reason for doing it is probably so that the new shell sets up its environment (by reading your .bashrc
, .bash_profile
, etc.).
有关更多信息,请参见bash文档:
See the bash documentation for more information:
- Bash启动文件,用于说明登录Shell与密码的区别非登录外壳
- Bourne Shell Builtins ,以获取有关
exec
命令的文档
- Bash Startup Files for how a login shell differs from a non-login shell
- Bourne Shell Builtins for documentation on the
exec
command.
(您应该可以通过输入info bash
在自己的系统上阅读该手册.)
(You should be able to read the manual on your own system by typing info bash
.)
这篇关于该命令的作用是什么? "exec bash -l"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!