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 01-08-2016, 11:50 AM   #1
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Rep: Reputation: 147Reputation: 147
Slackware switch user, how to?


Hello, I have been spending some time configuring my Slackware install.
I added another user account, to avoid using root, for security reasons.
This is probably an easy solution, but how do I switch users from the command line? Also when I use the switch user option in the GUI, I see the option to logout but not the option to enter a new user. When I did logout as root it still didn't give me any more options. What am I missing?
Thankyou.
 
Old 01-08-2016, 12:25 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,076
Blog Entries: 1

Rep: Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146
In a shell you can switch user with the su command.

See man su for details, but one key thing to know when using it to become root is to use the '-' option...

Code:
su -
... which also takes on the root environment just as if you had logged in as root. Otherwise you become root but retain the non-root user's environment which can result in missing PATHs, etc. leading to some things not working as expected.

Alternatively, you can configure sudo to allow a non-root user to perform functions which require root permission. By default on a Slackware system, there are no users with sudo access, but see man sudo to get oriented then we can figure out how you might want to use it.

You cannot switch users of your X session - it is already running many processes as the logged in user and is itself owned by the logged in user. You must log out then login as another user.

And you should not run X as root as that can lead to a great many security and therefore stability issues.
 
Old 01-08-2016, 12:26 PM   #3
GNU/Linux
Member
 
Registered: Sep 2012
Distribution: Slackware-14
Posts: 118

Rep: Reputation: Disabled
What GUI? What Desktop Environment are you running? KDE, Gnome, Xfce? From command line you can use 'su' (man su).
 
Old 01-08-2016, 12:48 PM   #4
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Original Poster
Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by GNU/Linux View Post
What GUI? What Desktop Environment are you running? KDE, Gnome, Xfce? From command line you can use 'su' (man su).
My apologies for not mentioning KDE.

If I logout from the X session, logically I would expect to see an option to switch user, I must have missed something.

Last edited by offgridguy; 01-08-2016 at 01:00 PM.
 
Old 01-08-2016, 12:57 PM   #5
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Original Poster
Rep: Reputation: 147Reputation: 147
Smile

Quote:
Originally Posted by astrogeek View Post
In a shell you can switch user with the su command.

See man su for details, but one key thing to know when using it to become root is to use the '-' option...

Code:
su -
... which also takes on the root environment just as if you had logged in as root. Otherwise you become root but retain the non-root user's environment which can result in missing PATHs, etc. leading to some things not working as expected.

Alternatively, you can configure sudo to allow a non-root user to perform functions which require root permission. By default on a Slackware system, there are no users with sudo access, but see man sudo to get oriented then we can figure out how you might want to use it.

You cannot switch users of your X session - it is already running many processes as the logged in user and is itself owned by the logged in user. You must log out then login as another user.

And you should not run X as root as that can lead to a great many security and therefore stability issues.
Thank you for this. I appreciate everyone's patience. I know very little about the command line, but that is why I have Slackware, it is literally forcing me to learn new things.
Quote:
And you should not run X as root as that can lead to a great many security and therefore stability issues.
After reading some articles and threads in other places, I agree with you, which is why I created another user account, but I didn't realize this new account doesn't have sudo access, I did set it up with it's own bash shell though.
Thanks for this info.
 
Old 01-08-2016, 01:58 PM   #6
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Original Poster
Rep: Reputation: 147Reputation: 147
After some experimenting i find I can open a terminal and login as root for administrative tasks.
When I logout of the X session as a regular user, it takes me to a black screen with only a mouse pointer, and hangs there, is this normal? I did find that I could log back in by searching through my virtual consoles, F3 had the login prompt for user, F1 had the login prompt for root. One more thing I have found is that I cannot shut down as regular user, I have to login as root and then halt, to effect shutdown. Is this also normal.
If it makes a difference, I boot directly to the virtual console and start the X session from there usually as regular user. I do know how to set it to default graphical login as I did use it that way for awhile. Should I switch back to that? Is this part of my problem?
 
Old 01-08-2016, 04:35 PM   #7
Hasek39
Member
 
Registered: Jul 2015
Location: Moscow, Russia
Distribution: Slackware
Posts: 93

Rep: Reputation: Disabled
When you logging out and see "black screen" -- this is console. If you want to start you graphical session again just type "startx". If you want to be able using sudo you should edit /etc/sudoers file by visudo command from root. I suggest to add your user to the wheel group and than enable wheel group at sudoers file. After that you will be able to run all commands with the sudo prefix, for example "sudo shutdown -h now" for shutting down your computer from non-root user. You said that you know how to set graphical login so it may be better to you set it because as I understood you want to be able switch users from GUI.

Ask me if this is something unclear in my post and I will try to explain it more carefully.
 
Old 01-08-2016, 06:30 PM   #8
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Original Poster
Rep: Reputation: 147Reputation: 147
Smile

Quote:
Originally Posted by Hasek39 View Post
When you logging out and see "black screen" -- this is console. If you want to start you graphical session again just type "startx". If you want to be able using sudo you should edit /etc/sudoers file by visudo command from root. I suggest to add your user to the wheel group and than enable wheel group at sudoers file. After that you will be able to run all commands with the sudo prefix, for example "sudo shutdown -h now" for shutting down your computer from non-root user. You said that you know how to set graphical login so it may be better to you set it because as I understood you want to be able switch users from GUI.

Ask me if this is something unclear in my post and I will try to explain it more carefully.
Thank you for the help. Let me see if I understand this.
-first I should edit/etc/sudoers file, using vi text editor, is this correct?
I do have some understanding of vi (vim).
But before I do that I should actually read /etc/sudoers file, to familiarize myself with it.
Would I view this file, using the cat command? or open the file with vi in the terminal?
To open the file in a terminal with vi, would I use [ vi /etc/sudoers] ?
To use the cat command, is this [cat sudoers] ?

If I can use sudo command as user, it is not important to use graphical login as I would be able to shutdown from my user account.

Do I understand this correctly?
 
Old 01-08-2016, 06:46 PM   #9
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,076
Blog Entries: 1

Rep: Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146
Sorry for slow reply, I have been otherwise occupied today...

Quote:
Originally Posted by offgridguy View Post
After some experimenting i find I can open a terminal and login as root for administrative tasks.
When I logout of the X session as a regular user, it takes me to a black screen with only a mouse pointer, and hangs there, is this normal?
I am not sure I understand what you are describing.

Is it a blank screen with an X shaped mouse pointer and nothing else? If so then it might be your window manager is shutting down but leaving the X server running which would be strange, but likely the result of a configuration problem. It might also be video driver related, but less likley I think.

On the other hand, if it is a blank console screen with a login: prompt then that is normal.

Quote:
Originally Posted by offgridguy View Post
I did find that I could log back in by searching through my virtual consoles, F3 had the login prompt for user, F1 had the login prompt for root. One more thing I have found is that I cannot shut down as regular user, I have to login as root and then halt, to effect shutdown. Is this also normal.
Yes that is normal. You can add a line to your sudoers file to allow a normal user to shutdown without a password too, very convenient.

Quote:
Originally Posted by offgridguy View Post
If it makes a difference, I boot directly to the virtual console and start the X session from there usually as regular user. I do know how to set it to default graphical login as I did use it that way for awhile. Should I switch back to that? Is this part of my problem?
No, that should not be part of the problem - unless you have misconfigured it some way...

If you can switch consoles with Fx then your problem is less likely to be driver related as well in my experience.

I would suggest that you boot to the console login for now and use startx until we know what is happening, otherwise you might mask a configuration problem that will just show up again later.

So let's get some additional info: What Wm or DE are you using?
Did you edit any startup files such as ~/.xinitrc?
What video chip or driver do you have?
Maybe the output of lspci would help us see what you have too.
 
Old 01-08-2016, 07:18 PM   #10
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Original Poster
Rep: Reputation: 147Reputation: 147
I haven't edited any files yet, I use KDE.
I find I can switch users in the console using the [su username] not sure why I was having trouble with that before.
My main concern now is being able to able to add sudo to my user account, so I don't have to log back in as root in order to shutdown.

And thank you for the input.
 
Old 01-08-2016, 08:17 PM   #11
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,076
Blog Entries: 1

Rep: Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146
To add your user to allow shutdown without password...

Code:
as root...

visudo

then add the following line replacing username with your user...

username ALL = NOPASSWD: /sbin/shutdown *
(Writing this on the fly from memory, please check man sudoers if it complains).
 
Old 01-08-2016, 09:28 PM   #12
offgridguy
Senior Member
 
Registered: Nov 2015
Location: Alberta Canada
Distribution: Windows10, Debian
Posts: 1,111

Original Poster
Rep: Reputation: 147Reputation: 147
Thumbs up

Thank you astrogeek, this seemed to work, at least there were no complaints.

Success! I can now shut down from the X session as user without a password,
very convenient indeed. I am very happy to mark this thread solved.

Last edited by offgridguy; 01-09-2016 at 09:38 AM.
 
  


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
[SOLVED] I want to switch to Linux?And become an expert slackware user. greentiger2 Linux - Newbie 6 06-12-2014 01:46 AM
Slackware user looking for opinions on a possible switch arobinson74 Debian 21 06-25-2006 08:46 AM


All times are GMT -5. The time now is 09:30 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