Become su in Terminal - HowTo

You may be asked to open a terminal and give the result of a command. Sometimes you will need to be su - This is just to show you how. Open a terminal, type su - (Notice the - ) and hit enter. It will request your root password, enter it (by default nothing displays as you type - but just type) hit enter and you should see the end of the prompt turn to # and probably the colour of the line will change.
http://thumbnails18.imagebam.com/5906/69215059051496.gif](http://www.imagebam.com/image/69215059051496)

Or in Dolphin you can have a Terminal Panel, it can be quicker than having to cd through directories.
http://thumbnails22.imagebam.com/5436/f858a754351492.gif](http://www.imagebam.com/image/f858a754351492)

No complaints please about this being too simple. It’s for Noobs;)

[EDIT] I have changed previously quoted su to su -
which after consulting the members, is the more accurate way. The right/correct way. Thanks. This is the benefit of the forum friends. I stand corrected.

not too simple for noob’s, but may I add …

When as a noob’s you are asked to post the results of su <command> output to us here in a forum, it can be helpful to describe an easy way to copy/paste the output to the forums. I use an arkayic method cause for some reason my copy paste doesn’t seem to work in a terminal.

sudo <command> >>$HOME/cmd.txt

then open open cmd.txt in editor and copy paste from there.

Copy and paste with the mouse not keyboard shortcuts.

If you create a launcher in the panel with the command kdesu konsole, then every time you need it just click and type your password. Simple and faster.:slight_smile:

True.
Only thing is, you’ll need to explain just how to do that first (not to me BTW).rotfl!

That will be a new howto:P
Or maybe add it in yast2rotfl!

caf4926 wrote:
> You may be asked to open a terminal

some n00bs need to be told what “open a terminal” means and/or how to
do that…

> type su and hit enter

i suggest it should read

type su - (don’t forget the dash) and press enter
or
type “su -” (without the quotes) and hit enter

> No complaints please about this being too simple. It’s for Noobs;)

you did good, except for misspelling color :wink:


palladium
Have a lot of fun…

You can also copy / paste in Konsole (KDE’s terminal) using shift ctrl c to copy and shift ctrl p to paste. It may work in other terminals too.

On Sun, 01 Nov 2009 09:08:20 +0000, palladium wrote:

>> type su and hit enter
>
> i suggest it should read
>
> type su - (don’t forget the dash) and press enter or type “su -”
> (without the quotes) and hit enter

Actually, either should work just fine. The difference between the two
is that adding “-” initiates a login shell, but I’ve never run into a
situation where the ‘-’ was absolutely required. That might be because
my paths for root and non-root tend to be the same, and I don’t care if
the system puts me in root’s home directory or not.

Jim

Jim Henderson
openSUSE Forums Moderator

Too funny! I’ve been copy pasting by piping to text file then copy pasting from there and now I see ‘shift’ + ctrl. Mouse method works with actual mouse but my touchpad won’t do copy paste even in text editor.

> That might be because my paths for root and non-root tend to be the same

which is the way mine is also…but the n00b with an as born newly
installed openSUSE will run into NOT finding any executable in /usr/sbin

so, there are lots of things that won’t run without the -

of course, the instructions could be changed to export that directory
to the user path, and then su…

but, it is a whole lot easier to just type

su -

ymmv


palladium
Have a lot of fun…

Really? :slight_smile:

neutrino@neutrino:~> **su**
Password:
neutrino:/home/neutrino # echo $PATH
/usr/lib64/mpi/gcc/openmpi/bin:/home/neutrino/bin:/usr/local/bin:/usr/bin:**/sbin**:**/usr/sbin**:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin:/opt/kde3/bin:/opt/kde3/bin
neutrino:/home/neutrino # **which iptables**
**/usr/sbin/iptables**
neutrino:/home/neutrino #

This is default and I’ve changed absolutely nothing

Trouble is there is always another or different approach -
Sod’s Law is if you mention One, a bunch of other folk will give better alternatives.

And Sturgeon’s Law is that virtually everything is crud :smiley:

On Mon, 02 Nov 2009 07:51:58 +0000, palladium wrote:

> ymmv

And indeed it does. :slight_smile:

Jim

Jim Henderson
openSUSE Forums Moderator

On Mon, 02 Nov 2009 11:06:01 +0000, caf4926 wrote:

> Trouble is there is always another or different approach - Sod’s Law is
> if you mention One, a bunch of other folk will give better alternatives.

Not always better, if it comes to that. I know one person who uses “sudo
su” - and I’ve never understood why. I should ask him someday.

Jim


Jim Henderson
openSUSE Forums Moderator

Well, I for one didn’t know about the Terminal being available Dolphin until today.
That’s what I get for not RTM.

> This is default and I’ve changed absolutely nothing

well, then i guess i’m wrong…but, i’ve not actually used 11.x past a
few days…so…

so, hmmmmmm…

well, i guess all i was going by was the ‘wise’ (?) advice of bunch of
old ‘main frame’ guys (see: <http://tinyurl.com/6ry6yd>)

maybe it is time i ‘let go’ of that old wives tale…i’ll drop it for
now…unless i find good reason to speak up again…


palladium
Have a lot of fun…

I don’t think it will magically change by itself the more you keep using the system :wink:
I’ve never had to change anything on various SUSE versions and it has always been like that so I never had problems with ‘su’ which would force me to use a login shell with ‘su -’

> unless i find good reason to speak up again…

below are a baker’s dozen quotes followed by a cite all from
opensuse.org sources (i’ll look outside our walls later, if i remember):

  1. “There is a problem starting YaST with the new Qt/KDE if you don’t
    have a login shell as root (in other words, if you do “su” instead of
    “su -” for example). The symptom is that YaST does not show any Qt UI
    (note the control center works, just launching any YaST module
    hangs).” <http://en.opensuse.org/KDE/KDE4>

  2. “I found out this:
    su
    yast2
    does not work.
    But:
    su - (please not the ‘minus’ sign)
    yast2
    does work.”
    <http://forums.opensuse.org/applications/422058-failed-attach-process.html#post2044599>

  3. “Not sure exactly what or why that extra hyphen works, but it did,
    so thank you!”
    <http://forums.opensuse.org/applications/407723-cant-launch-editor-root-2.html#post1944136>
    in reply to
    <http://forums.opensuse.org/applications/407723-cant-launch-editor-root-2.html#post1944110>

  4. “For ifconfig etc the reason is not that they cannot be run as
    root, but that their location /sbin or /usr/sbin is not in the default
    search path of ordinary users. And this search path doesn’t change if
    you do su. What you have to do is su - which goes through root’s
    normal login, then it will be in the search path.”
    <http://forums.opensuse.org/archives/sf-archives/archives-network-internet/324821-where-ifconfig-iwconfig.html#post1505686>

  5. @acecraft: Yes, there are SLES forums you should head to now, but
    I want point out that the reason you don’t find ifconfig or modprobe
    on your path is probably because you didn’t do su - instead of plain
    su. su - gets root’s environment as if logging in, which normally adds
    /sbin to the $PATH, where ifconfig and modprobe are.”
    <http://forums.opensuse.org/network-internet/417715-realtek-rtl8139-suse-enterprise-server-edition.html#post2009721>

  6. “Just open a konsole and su - to root user if there is mail you
    will get a notification in the konsole session.” <moderator
    malcolmlewis in
    http://forums.opensuse.org/applications/398214-how-get-cron-send-me-email-notifications.html#post1887437>

  7. “Did you try to open a terminal and type su - to get in the root
    environment? Unless you put the file holding these commands in your
    path, you have to type absolute path or do a su - to get it to work.
    The - is critical as it is what puts you in the users environment.
    Hope this helps you understand Linux a little more.”
    <http://forums.opensuse.org/network-internet/400760-opensuse-11-0-wired-network-problems-realtek-8186b.html#post1902381>

  8. "Well, to clarify su means SwitchUser and not SuperUser

so there is no difference between logging in as root and su’ing to
root with the “-” parameter.
So logging in as root is equal to:
su -

su just takes root as the default user to switch to, so “su -
username” is the correct syntax. The “-” just sets that the
environment of the user “username” is set."
<http://forums.opensuse.org/archives/sf-archives/archives-software/310512-superuser-vs-root.html#post1429524>

  1. “Thanks. Using “su -” worked great. I think it auto detected my
    card anyway. Thanks a lot.”
    <http://forums.opensuse.org/network-internet/392861-kiwi-ltsp-zimbra.html#post1857479>
    in response to "But have you tried su - instead of plain su? "
    <http://forums.opensuse.org/network-internet/392861-kiwi-ltsp-zimbra.html#post1857390>

  2. “With sudo you are still using your $PATH and will not get
    programs that are in /sbin and /usr/sbin as those are in root’s
    $PATH…What I often do on machines using the sudo method, e.g.
    *buntu, is: sudo su -”
    <http://forums.opensuse.org/applications/386424-cannot-start-gparted.html#post1821387>

  3. “The PATH is still “my” PATH. I do not know if this is correct (as
    said, I never realy studied sudo). But I always stick to
    Code: su -
    (mind the - ) or a real log in (as with the terminal) because it gives
    root its own environment. Much better for scurity. The user PATH can
    contain all sorts of places (like ./ ) where a program may have the
    same name as a tool you want to use as root!”
    <http://forums.opensuse.org/applications/405254-sudo-whatever-command-not-found-2.html#post1929115>

  4. “Make sure you are root. If you logged in as a normal user, make
    sure you became root using “su -” to get the full login environment.
    “su” alone misses some things.”
    <http://lists.opensuse.org/opensuse-security/2002-02/msg00391.html>

  5. “You need to be root user with roots environment, did you add the
    minus sign after the su command?”
    <http://forums.opensuse.org/install-boot-login/396020-display-settings-disappeared.html#post1875017>


palladium
Have a lot of fun…