Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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?
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.
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.
Sorry for slow reply, I have been otherwise occupied today...
Quote:
Originally Posted by offgridguy
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
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.