What does this team do? "exec bash -l"

What does this team do?

exec bash -l 

I found this command as part of a reminder text file, I wrote some instructions on how to create the ssh key and clone the git repository, but I wrote it a long time ago and I can’t remember what it does.

+5
source share
2 answers

exec executes the specified command, replacing the current process, rather than starting a new subprocess.

If you type

 bash -l 

at the shell prompt, it will invoke the new shell process ( -l makes it the login shell). If you exit this shell process, you will return to the original shell process.

Enter

 exec bash -l 

means the new shell process replaces your current shell process. It is probably a little less resource intensive.

The reason for this is probably so that the new shell installs its environment (reading your .bashrc , .bash_profile , etc.).

See the bash documentation for more information:

(You should read the manual on your own system by typing info bash .)

+11
source

This will replace your current shell with a new bash shell running as an login shell.

+1
source

Source: https://habr.com/ru/post/1206213/


All Articles