Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  97] [ 0]  / answers: 1 / hits: 72057  / 1 Year ago, thu, february 2, 2023, 10:43:30

It is said that settings for non login shell to go into .bashrc file and login shell settings to go into .profile file.



What is really meant by login and non-login shells?



Please explain without using technical jargon as far as possible.


More From » bash

 Answers
4

Simply put:



  • If you open a shell or terminal (or switch to one), and it asks you to log in (Username? Password?) before it gives you a prompt, it's a login shell.

  • If it doesn't (like gnome-terminal), and lets you use it straight away, it's a non-login shell.


If you are a normal user of Ubuntu Desktop, the only login shell is...your desktop (you type a password to get in, right ;)? Well, technically it's a login shell that starts a GUI, but that's getting in to jargon. And yes, it will read the settings in .profile


The only time you (a normal user) will probably see a login shell that looks like a login shell is if you are having some problem with your desktop and you switch to a virtual terminal with the Ctrl+Alt+F1 shortcut.




The other general cases for having a login shell include:



  • accessing your computer remotely via ssh (or connecting locally with ssh localhost)

  • simulating an initial login shell with bash -l (or sh -l)

  • simulating an initial root login shell with sudo -i

    • or sudo -u username -i for another non-root user



  • authenticating as another non-root user with su - username (and their password)

  • using the sudo login command to switch user


[#37296] Thursday, February 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tionavocad

Total Points: 189
Total Questions: 101
Total Answers: 118

Location: Liechtenstein
Member since Wed, Dec 8, 2021
2 Years ago
tionavocad questions
Tue, May 23, 23, 00:07, 1 Year ago
Tue, Jan 17, 23, 20:38, 1 Year ago
Sun, Oct 10, 21, 04:50, 3 Years ago
Tue, Jun 7, 22, 08:50, 2 Years ago
;