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 03-11-2014, 05:20 PM   #1
cmunger
LQ Newbie
 
Registered: Mar 2014
Location: Dallas, TX
Distribution: RHEL 6.5
Posts: 15

Rep: Reputation: 0
Question How do I set another user to boot only in command line?


I am trying to configure a system where I (user1) can boot into the GUI, but user 2 can only boot a command line.

From what I know (which could be wrong) the system has to be runlevel 5 to allow all users access to a desktop GUI.
Admins want User2 to only have access to a command line.

Google has not helped, nor have the 4 books I have.


You guys are the reason I am going to pass the Red Hat exam. Thank you everyone.
 
Old 03-11-2014, 05:39 PM   #2
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 808

Rep: Reputation: 216Reputation: 216Reputation: 216
Just giving you my best guess, but I would first change the default runlevel on startup to 3 in /etc/inittab.

As a normal user you won't be allowed to change runlevels, so the user2 would be stuck at runlevel 3. However, the same would be true for you (user 1) so you would have to give yourself sudo rights to be able to change that... (and obviously make sure that user2 does not have sudo rights)
 
Old 03-11-2014, 05:47 PM   #3
cmunger
LQ Newbie
 
Registered: Mar 2014
Location: Dallas, TX
Distribution: RHEL 6.5
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by joe_2000 View Post
Just giving you my best guess, but I would first change the default runlevel on startup to 3 in /etc/inittab.

As a normal user you won't be allowed to change runlevels, so the user2 would be stuck at runlevel 3. However, the same would be true for you (user 1) so you would have to give yourself sudo rights to be able to change that... (and obviously make sure that user2 does not have sudo rights)
Let me clarify: I have root privledges. I can su - into root. Thats no problem. Higher ups want this config. But I wil definitely give it a try!
 
Old 03-11-2014, 06:11 PM   #4
cmunger
LQ Newbie
 
Registered: Mar 2014
Location: Dallas, TX
Distribution: RHEL 6.5
Posts: 15

Original Poster
Rep: Reputation: 0
Didnt work, User2 still sees the desktop.
 
Old 03-11-2014, 06:58 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
text boot for everyone
but only allow user1 to run startx or depending on the OS "telinit 5 "

for rhel 6 that is rather easy
telinit is in sbin

Last edited by John VV; 03-11-2014 at 07:00 PM.
 
Old 03-11-2014, 07:02 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,
Quote:
Originally Posted by cmunger View Post
Didnt work, User2 still sees the desktop.
What didn't work? What did you do?

Evo2.
 
Old 03-12-2014, 02:28 PM   #7
cmunger
LQ Newbie
 
Registered: Mar 2014
Location: Dallas, TX
Distribution: RHEL 6.5
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by John VV View Post
text boot for everyone
but only allow user1 to run startx or depending on the OS "telinit 5 "

for rhel 6 that is rather easy
telinit is in sbin
I cant figure out how to allow only user1 to run telinit 5 (RHEL 6.5). Nor can I find how to run everyone as text boot. Everything I have found keeps pointing me to booting in single user mode.
 
Old 03-12-2014, 02:31 PM   #8
cmunger
LQ Newbie
 
Registered: Mar 2014
Location: Dallas, TX
Distribution: RHEL 6.5
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by evo2 View Post
Hi,


What didn't work? What did you do?

Evo2.
Tried setting the runlevel to 3.

EDIT:
It brought me to text only this time, but it was for every user, not just user2 and I still cant figure out how to make only that user have text only.

Last edited by cmunger; 03-12-2014 at 02:34 PM.
 
Old 03-12-2014, 02:50 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,938

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Did you change /etc/inittab to id:3:initdefault: When the system is restarted it should boot to full multiuser mode with out the desktop. As stated you can then add a command to the user1's bash profile to run startx to start the desktop.

Last edited by michaelk; 03-12-2014 at 02:51 PM.
 
1 members found this post helpful.
Old 03-12-2014, 03:40 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,938

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Untested but I think this should prevent multiple instances of X running and only allow it to start on tty1 i.e. when you first login.

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
startx
fi

In addition user1 will first have to shutdown the desktop then logout via console.

Last edited by michaelk; 03-12-2014 at 03:43 PM.
 
Old 03-12-2014, 04:31 PM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
if you only want user 2 of N users
you might want to set up a custom boot line in grub
BUT every other user will also be able to use that custom bootline
 
Old 03-12-2014, 04:50 PM   #12
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 808

Rep: Reputation: 216Reputation: 216Reputation: 216
Quote:
Originally Posted by cmunger View Post
Tried setting the runlevel to 3.

EDIT:
It brought me to text only this time, but it was for every user, not just user2 and I still cant figure out how to make only that user have text only.
That behavior is by design. And it's in line by the approach I suggested. The runlevel is initialised before users log in. So you have to allow the users who want GUI to change runlevels, and disallow it to the ones you want to stay in commandline only.

Another thought would be to disable the display manager and somehow prevent user2 from running startx. But this somewhat feels like a hack, and probably could be circumvented somehow.

Yet another thought: Maybe you could install the x server into an encrypted partition that requires unlocking upon boot. But the idea seems awkward.

Maybe it would help if you gave us a bit more background on what you want to achieve and why. What type of misuse are you hoping to prevent by disallowing gui to user 2? I think actually the command line is the place where the most damage could be done... There might be better ways to achieve your goals... Do all users have to use the very same OS?
 
Old 03-17-2014, 05:06 PM   #13
cmunger
LQ Newbie
 
Registered: Mar 2014
Location: Dallas, TX
Distribution: RHEL 6.5
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by joe_2000 View Post
That behavior is by design. And it's in line by the approach I suggested. The runlevel is initialised before users log in. So you have to allow the users who want GUI to change runlevels, and disallow it to the ones you want to stay in commandline only.

Another thought would be to disable the display manager and somehow prevent user2 from running startx. But this somewhat feels like a hack, and probably could be circumvented somehow.

Yet another thought: Maybe you could install the x server into an encrypted partition that requires unlocking upon boot. But the idea seems awkward.

Maybe it would help if you gave us a bit more background on what you want to achieve and why. What type of misuse are you hoping to prevent by disallowing gui to user 2? I think actually the command line is the place where the most damage could be done... There might be better ways to achieve your goals... Do all users have to use the very same OS?
Thats just the point. I cant figure out the application for this either. It is an example exercise in a RHCSA review book. It is about as useful as writing a program to find the flea population on a dog (real program written by my mom when she was in college).

oh as an update, modifying the files in /home/.bash_* worked after Joe_2000's suggestion. Thank you everyone! Once the exam is over, I will try everyones suggestions at that time, but right now I just need it to work.
 
  


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
nano tip: set a variable in the boot command line to be used later Didier Spaier Slackware 2 03-12-2013 03:24 PM
[SOLVED] How-to set a parameter in the command line to be used later by a user-space script? Didier Spaier Linux - Kernel 5 03-02-2013 06:40 AM
[SOLVED] Get a variable from a user on command line, in the middle of a line mikejreading Linux - Software 4 11-22-2010 10:06 PM
how to set parameter at the boot command line? ufmale Linux - Newbie 2 08-20-2010 09:32 PM
How to set Gateway by command line vanhelsing Linux - Networking 1 07-17-2004 12:42 PM


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