LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-12-2012, 07:59 AM   #1
charging-ibis
Member
 
Registered: Dec 2011
Location: Columbus, OH
Distribution: Slackware 13.37
Posts: 38

Rep: Reputation: 0
login and non-login shell question


Hello this is just a simple question When you are at a graphical login to log into a Window manager, Is it considered a login shell or a non-login shell?

Thanks.
 
Old 09-12-2012, 08:13 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
It'll be a login shell; i.e., the content of /etc/profile (and anything it includes, such as /etc/login.defs) will be executed as will your .profile, .bashrc, .whatever.

Where you might experience non-login shells is when you open a terminal window (where you just get a $ as a prompt). That behavior can be altered in your window manager preferences or in the preferences for the terminal program -- in Xfce (and probably others) you can check a box to "run command as login shell" (which executes all the above as if you logged in).

Usually, if you open a terminal and execute
Code:
ps -f
you'll see something like this
Code:
UID        PID  PPID  C STIME TTY          TIME CMD
trona    30585 30583  0 09:07 pts/0    00:00:00 -ksh
trona    30604 30585  0 09:10 pts/0    00:00:00 ps -f
where the dash in front of, in my case, ksh (KornShell) indicates that it's a login shell; the dash won't be there otherwise. You're probably using BASH so the dash would be in front of bash.

Hope this helps some.

Last edited by tronayne; 09-12-2012 at 08:14 AM.
 
Old 09-12-2012, 09:00 AM   #3
charging-ibis
Member
 
Registered: Dec 2011
Location: Columbus, OH
Distribution: Slackware 13.37
Posts: 38

Original Poster
Rep: Reputation: 0
Yes i found your information helpful. As a matter of fact i am on the chapter regurding shells lol.
So what your saying is that even though it is a GUI login screen the login shell is running in the background correct?

Thanks
 
Old 09-12-2012, 12:13 PM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Quote:
Originally Posted by charging-ibis View Post
So what your saying is that even though it is a GUI login screen the login shell is running in the background correct?
Well, sort of (and this might be a little more complicated than you're interested in but here goes anyway).

Shell programs -- BASH, Bourne, C, Korn (and others) -- are command interpreters; they're the interface between you on a console or terminal emulator (like an X Terminal) and the operating system. They're not running until you log in. You type a command at a shell program prompt and the shell "forks and exec's" that program. You can create shell programs that perform useful work incorporating such concepts as if-else if-else, for, while and other constructs -- a shell program is a programming language like any other.

Logging in is a different concept and not necessarily related to any of the shells. There are three programs, init, getty and login, used for that purpose.

The init program "is the parent of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab. This file usually has entries which cause init to spawn gettys on each line that users can log in. It also controls autonomous processes required by any particular system." (from the manual page).

In /etc/inittab, there is a default run level defined. On my system it is run level 3 which stops at a full-screen console (no GUI). On your system, it will probably be run level 4 (possibly some other run level but not 0, 1, or 6 which are 0 = halt the system and shut off the power, 1 = single user mode, 6 = reboot). The entry in /etc/inittab will look something like this:
Code:
# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:
Now, the different run levels cause init to execute different directives (found in /etc/inittab), most notably for our purposes, the directive for run level 4. Run level 4 will attempt to start gdm, kdm or xdm (maybe one or two others). If you're going to fiddle with it, make sure you write down what the run level was before you change it.

The gdm program, I'm pretty sure, is for GNOME (don't have GNOME on my system, don't know), kdm is for KDE and xdm is if you don't have either of those. Only one of those will get started and it will handle the functions of getty and login.

So what does getty do? If you set your default run level to 3 (you can do that, just edit /etc/inittab and log out). Run level 3 takes you to a console, getty opens a port, prints a login prompt and initiates a login process (you enter your user and password). If you type correctly, you get logged in and are prompted to enter commands until you exit (type Ctrl-D or the word exit) which takes you back to the login prompt (yeah, it's the login program).

You can, of course, star X running: simply enter
Code:
startx
at a system prompt and, viola! GNOME, KDE, Xfce or whatever starts and will run until you log out and you'll be back to the console (from which you can log out and log in as another user, log in as root or use su - or use sudo) and shut down the system with shutdown or init 0).

You can always edit /etc/inittab and set the default run level back to 4.

Bottom line, nope, it's not a shell, it's a display manager (that might actually invoke a shell for the login and password but probably not).

You may want to look at the manual pages for init, getty, login and gdm, kdm or xdm (xdm is a manual page, gdm and kdm are probably info pages).

Hope this helps some.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check in a script whether the shell is login or non login? frankie_DJ Programming 7 10-21-2015 10:09 AM
Difference between normal shell and login shell Manish Linux - General 7 11-14-2012 08:30 AM
Prevent Login by IP address / limit login attempts / remedial IP tables question whiskey06 Linux - Security 5 04-26-2009 03:48 AM
How do I get the /etc/login.defs in a non login shell acummings Slackware 7 05-20-2007 10:17 PM
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 08:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration