LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 07-26-2003, 10:25 PM   #1
PapaNoHair
Member
 
Registered: May 2002
Location: Orlando
Distribution: Linspire 5.0
Posts: 82

Rep: Reputation: 15
Switching between root and user


I am running Slack 9.0 and I login at the command line. If I am in, say WindowMaker as user and desire to switch over to root (not su from command line) is there an easy way to switch over? Currently I am logging out, back to the prompt, then su to root, then reboot and reversing the process afterwards. There must be an easier way then this. Thanks in advance!
 
Old 07-27-2003, 12:07 AM   #2
jpbarto
Senior Member
 
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
why do you want to do as root that can't be done by 'su'ing at the command prompt?
 
Old 07-27-2003, 12:29 AM   #3
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 45
personnaly, want I need to do some task at root, without using SU (as example, renamming files on Fat32 partition I want to keep unwritable to users) I start a SECOND xfree session under root name. I mean I have both my users and root running each one an x.
 
Old 07-27-2003, 02:16 AM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
I must be missing something. Why aren't either of you using 'su' in an xterm?
 
Old 07-27-2003, 02:41 AM   #5
MasterC
Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
Here's my take on the 2 things...

I push for more administration in a CLI. This does 2 things:
Keeps you from really jackin up your system so easily (you have to know the commands to use to do things)
Sorta forces you to get to learn what's actually going on behind the curtain, this will help for further diagnostics later sometimes.

However, many people who know CLI (and those that don't of course) will do things in a GUI for whatever reason. That's fine, and that's part of what's nice about linux is that you can, sometimes.

So if someone wants to be in root's gui everytime they use root to do something, or if they want to use a graphical tool that requires root priv's to run, that's great! The downside (other than that mentioned by Half_Elf) is that you have to logout and backin as root, then out as root and back in as user each time you want to. There are other ways, such as typing:
xhost +
first, but that's really work around and doesn't open up root's GUI.

So anyway, to expand on Half_Elf's suggestion:
Assuming you startx to get to your graphical environments, do this:
CTRL ALT F1
Login as user
startx
Then
CTRL ALT F2
Login as root
startx -- :1
And X for root will now be accessible by:
CTRL ALT F8
And X for user will be on
CRLT ALT F7

HTH

Cool

<PS>
There is also, sudo which is highly recommended even over su AFAIK.
</PS>

Last edited by MasterC; 07-27-2003 at 02:42 AM.
 
Old 07-27-2003, 08:34 AM   #6
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 45
Quote:
So anyway, to expand on Half_Elf's suggestion: Assuming you startx to get to your graphical environments, do this:
my personnal script is better, try this instead :
First rename "/usr/X11/bin/startx" as "/usr/X11/bin/start"
then create "startx" and write this script in it :

Code:
#!/bin/sh

if [ $# -eq 0 ]      # check to see if arguements are given (color depth)
       then a=24    # default color depth
        else a=$1    # use given color depth
fi

if [ $a -ne 8 -a $a -ne 16 -a $a -ne 24 ]
        then
                echo "Invalid color depth. Use 8, 16, or 24."
        exit 1
fi

for display in 0 1 2 3 4 5    # checks for open display, starts X on next available
        {
        if [ ! -f "/tmp/.X$display-lock" ]
                then
                    `start -- :$display -depth $a 1>/tmp/X$display.log 2>/tmp/X$display.log &`
                exit 0;
        fi
        }
echo "No displays available."
exit 1
Then make sure the script (the new "startx") is executable (type chmod +x) and create X1.log, X2.log, X3.log, X4.log X5.log and X6.log in /tmp.

This little script allow you to start up to 6 X sessions and save it's log in a files so you don't loose your terminal.

Anyways have fun
 
Old 07-27-2003, 10:30 AM   #7
Tuttle
Senior Member
 
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,289

Rep: Reputation: 52
Very usefull, thanks people!
 
Old 07-27-2003, 11:52 AM   #8
PapaNoHair
Member
 
Registered: May 2002
Location: Orlando
Distribution: Linspire 5.0
Posts: 82

Original Poster
Rep: Reputation: 15
Switching between root and user

Quote:
Originally posted by MasterC
Here's my take on the 2 things...

I push for more administration in a CLI. This does 2 things:
Keeps you from really jackin up your system so easily (you have to know the commands to use to do things)
Sorta forces you to get to learn what's actually going on behind the curtain, this will help for further diagnostics later sometimes.

However, many people who know CLI (and those that don't of course) will do things in a GUI for whatever reason. That's fine, and that's part of what's nice about linux is that you can, sometimes.

So if someone wants to be in root's gui everytime they use root to do something, or if they want to use a graphical tool that requires root priv's to run, that's great! The downside (other than that mentioned by Half_Elf) is that you have to logout and backin as root, then out as root and back in as user each time you want to. There are other ways, such as typing:
xhost +
first, but that's really work around and doesn't open up root's GUI.

So anyway, to expand on Half_Elf's suggestion:
Assuming you startx to get to your graphical environments, do this:
CTRL ALT F1
Login as user
startx
Then
CTRL ALT F2
Login as root
startx -- :1
And X for root will now be accessible by:
CTRL ALT F8
And X for user will be on
CRLT ALT F7

HTH

Cool

<PS>
There is also, sudo which is highly recommended even over su AFAIK.
</PS>
Thanks very much to all of you - I learned a lot! To answer those about su'ing into cli: I have found some things that just do not seem to work unless I am logged in as root. Plus even though I use the cli more frequently than I would have thought a year or two ago, I still like the graphic interface. Thanks again!
 
Old 07-27-2003, 04:27 PM   #9
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 45
Quote:
I have found some things that just do not seem to work unless I am logged in as root.
Just make sure it's not a configuration problem 'bout these "things". You should never run anything at root under linux (but I agree some apps are badly made and you need to run them as root anyways).

If you use KDE, there's an option in property to "run as different user". It is probably safer to run a single program at root than all an X. Just right click on a program icon and select property (the same things exist in gnome I believe).

You may also want to know that it is possible to set a bit of permission to an executable to give the possibility to anyone to run it as a different user. Search about setuid and setgid (the first one tell that the program will run under owner name and the second, under group name. This is especially usefull for safe application that require a root right (like cdrecord and all burn cdrom apps).
 
Old 07-27-2003, 10:02 PM   #10
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
Re: Switching between root and user

Quote:
Originally posted by PapaNoHair
I have found some things that just do not seem to work unless I am logged in as root.
Is that also true if you do 'su -' from the command line, as opposed to just 'su'?

Last edited by itsjustme; 07-28-2003 at 12:49 PM.
 
Old 07-27-2003, 11:22 PM   #11
Locura
Member
 
Registered: May 2003
Distribution: Ubuntu 6.10 SE, Mac OS 10.4.8
Posts: 370

Rep: Reputation: 30
Quote:
Originally posted by Half_Elf
personnaly, want I need to do some task at root, without using SU (as example, renamming files on Fat32 partition I want to keep unwritable to users) I start a SECOND xfree session under root name. I mean I have both my users and root running each one an x.
There is simply no reason to EVER do that. Rename them via the CLI from a terminal, using su to become root.
 
Old 07-28-2003, 07:38 AM   #12
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 45
Quote:
There is simply no reason to EVER do that. Rename them via the CLI from a terminal, using su to become root.
Have you ever tried to rename 300 Mp3s that are all in the same folder? It's a damn pain in terminal!!!

And I often start a second X when I want to use wine to run some progs on my fat32 partition. First, my users can't write on my fat32 partition (and I wish to keep it like this), second wine is a beta progs, meaning there's some strange bugs, like it has some problem resizing windows. Mean that if I start something in my 1280x1024 resolution, wine will only use a small square of 640x480. Ugly. And don't tell me my wine config isn't good I have tried a lot of things, if wine start the progs in full screen, it creates different problems.

yes, there is EVER reasons to do that. and ANYWAYS it's not really dangerous to start an X at root, X isn't a major vulnerability, especially when it doesn't listen for external connection.
 
Old 07-28-2003, 09:53 AM   #13
PapaNoHair
Member
 
Registered: May 2002
Location: Orlando
Distribution: Linspire 5.0
Posts: 82

Original Poster
Rep: Reputation: 15
Re: Re: Switching between root and user

Quote:
Originally posted by itsjustme
Is that also true if you do 'su -' fom the command line, as opposed to just 'su'?
Hmmm - haven't tried it that way (su -); pardon my ignorance but what is the difference?
 
Old 07-28-2003, 10:25 AM   #14
Noryungi
Member
 
Registered: Jul 2003
Location: --> X <-- You are here.
Distribution: Slackware
Posts: 262

Rep: Reputation: 30
The difference between "su -" and "su" is, probably, that one will give you a "fully root" command line (with the options defined for user "root"), while the other will retain the options of the user entering "su".

Can't remember which is which, though... I use sudo myself...
 
Old 07-28-2003, 12:58 PM   #15
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
This is from the rute manual.

Quote:
11.7.2 The set user, su command

To temporarily become another user, you can use the su program:

su jack

This command prompts you for a password (unless you are the root user to begin with). It does nothing more than change the current user to have the access rights of jack. Most environment variables will remain the same. The HOME, LOGNAME, and USER environment variables will be set to jack, but all other environment variables will be inherited. su is, therefore, not the same as a normal login.

To get the equivalent of a login with su, run

su - jack


This will cause all initialization scripts (that are normally run when the user logs in) to be executed. [What actually happens is that the subsequent shell is started with a - in front of the zero'th argument. This makes the shell read the user's personal profile. The login command also does this.] Hence, after running su with the - option, you logged in as if with the login command.
And if you don't specify a username, then 'root' is assumed, for 'su -'.

regards...

Last edited by itsjustme; 07-31-2003 at 11:49 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
Fast User Switching Arrowx7 Linux - Software 3 08-03-2005 03:32 AM
kde user switching stefan_nicolau Linux - Software 7 06-17-2005 09:29 AM
switching between user and root without logging out redhat_marsi Linux - Newbie 7 06-13-2005 10:38 AM
Quickly switching to root artificialGekko Linux - Newbie 9 03-09-2005 06:44 AM
switching to root Stan the caddy Linux - Newbie 9 01-17-2004 02:54 AM


All times are GMT -5. The time now is 09:41 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration