LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-17-2014, 01: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, 01:23 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
perl -e 'exec {"/bin/bash"} "-bash"'
 
1 members found this post helpful.
Old 12-17-2014, 01:49 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,840

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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, 12: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, 06:31 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,840

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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, 01:06 PM   #6
szejiekoh
LQ Newbie
 
Registered: Jun 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thanks pan64.
 
  


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

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