LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 12-17-2014, 02:13 PM   #1
szejiekoh
LQ Newbie
 
Registered: Jun 2014
Posts: 28

Rep: Reputation: Disabled
/bin/login and creating a login shell~


Hi all,

Not sure how /bin/login works, but i cant seems to enter the correct password


Code:
[alan~racnode1 ~]$ /bin/login
login: grid
Password: 
Login incorrect

login:
Yet when using su and the same login and password, i can login.

Code:
[alan~racnode1 ~]$ su - grid
Password: 
[grid~racnode1 ~]$
q1) Why ?

============

Been reading about login shell

Quote:
A login shell is one whose first character of argument zero is a -, or one started with the --login option.

The login process tells the shell to behave as a login shell with a convention: passing argument 0, which is normally the name of the shell executable, with a - character prepended. For example, for Bash shell it will be -bash.
q2) how do i simulate the creation of a login shell using the "-bash" method ?

Code:
[grid~racnode1 ~]$ /bin/login -bash
/bin/login: invalid option -- 'b'
usage: login [-fp] [username]
[grid~racnode1 ~]$ -bash
-bash: -bash: command not found
Regards,
Noob
 
Old 12-17-2014, 02:23 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
perl -e 'exec {"/bin/bash"} "-bash"'
 
1 members found this post helpful.
Old 12-17-2014, 02:49 PM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
I would say you misunderstood something. bash --login will start you a login shell, see the man page of bash.
login -bash will not work.
also see man page of login: login may be special to the shell and may not be invoked as a sub-process.
 
Old 12-18-2014, 01:24 AM   #4
szejiekoh
LQ Newbie
 
Registered: Jun 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I would say you misunderstood something. bash --login will start you a login shell, see the man page of bash.
login -bash will not work.
also see man page of login: login may be special to the shell and may not be invoked as a sub-process.
Hi Pan64, thanks for replying.

I tried bash --login, but it doesnt prompt me for any login or password entry and $0 doesnt return a login shell "-bash"

Code:
[alan@racnode1 ~]$ bash --login
[alan@racnode1 ~]$ echo $0
bash
[alan@racnode1 ~]$
When I do a su - user directly, it returned me a login shell.

Code:
[alan@racnode1 ~]$ su - alan
Password: 
[alan@racnode1 ~]$ echo $0
-bash
[alan@racnode1 ~]$
Am I missing something ? How does the login process works (when a user 1st connnect to the terminal) ?
is "login" process really invoking "bash --login" or "bash" is invoking "--login" to let user login into a login shell ?

Regards,
Noob
 
Old 12-18-2014, 07:31 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
http://comptechdoc.org/os/linux/howl...x_hllogin.html
http://www.linuxnix.com/2013/09/how-...-in-linux.html
 
1 members found this post helpful.
Old 12-18-2014, 02:06 PM   #6
szejiekoh
LQ Newbie
 
Registered: Jun 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thanks pan64.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:09 AM
Login Shell / Non-Login shell Clarification needed (RHEL 6.3) kingston Linux - Newbie 1 12-07-2012 01:51 AM
How to change the root shell /sbin/nologin to /bin/bash by login as user sunrised24 Linux - Server 9 02-05-2012 07:12 AM
Creating a login shell using sudoshell edcrozer Linux - Security 2 06-29-2007 12:20 AM
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 09:28 AM


All times are GMT -5. The time now is 08:33 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration