Author Topic: su and su - commands  (Read 955 times)

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10668
  • MLUs Forever!
su and su - commands
« on: July 15, 2011, 04:15:40 PM »
Quote
Just su to root and use the rest of the line.
Should not that be su - ?

If using one of the newer ISOs you may find that "su" is aliased to "su -" .......  you can find out what aliases are set up by typing in a terminal

alias

« Last Edit: July 17, 2011, 12:14:54 AM by old-polack »
MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline dvhenry

  • Full Member
  • ***
  • Posts: 106
Re: su and su - commands
« Reply #1 on: July 15, 2011, 05:25:07 PM »
On my system that alias is not set up, but I use a variety of distro's,  so will stick to my already formed habit of typing "su -".
« Last Edit: July 17, 2011, 03:32:06 AM by old-polack »

Offline johnmart

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1105
  • Make Love Not War
Re: su and su - commands
« Reply #2 on: July 15, 2011, 08:26:06 PM »
Excuse me for butting in with an off-topic question.
Is there a downside to using su -, instead of su?
I never use su - unless I am following someone's advice.
My concern is that the results of certain commands from root environment could cause an ownership issue later on.
But I am a dummy.  ;D
Unfounded concern?
« Last Edit: July 17, 2011, 12:30:09 AM by old-polack »
Acer Aspire, Intel core2 2.20GHz, ‎Graphics nVidia ‎G98M [GeForce G 105M], 2gb ram, Wireless Intel Link 5100

Why, any 5 year old child could understand this.
Somebody bring me a 5 year old.
Groucho

Offline jfdesign

  • Full Member
  • ***
  • Posts: 210
Re: su and su - commands
« Reply #3 on: July 16, 2011, 02:59:46 AM »
Quote
Just su to root and use the rest of the line.
Should not that be su - ?

If using one of the newer ISOs you may find that "su" is aliased to "su -" .......  you can find out what aliases are set up by typing in a terminal

alias



i'm not gonna install the new iso in near time because my system is in good shape, but i want that alias. may i know how tex set that alias ? if in .bash_profile ... what the syntax ?
tia
« Last Edit: July 17, 2011, 12:30:44 AM by old-polack »

Offline Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11591
  • ----IOFLU----
Re: su and su - commands
« Reply #4 on: July 16, 2011, 03:16:56 AM »
Quote
Just su to root and use the rest of the line.
Should not that be su - ?

If using one of the newer ISOs you may find that "su" is aliased to "su -" .......  you can find out what aliases are set up by typing in a terminal

alias



i'm not gonna install the new iso in near time because my system is in good shape, but i want that alias. may i know how tex set that alias ? if in .bash_profile ... what the syntax ?
tia

You can add a line to your ~/.bashrc;

alias su='su -'

Save the file and that's it.
« Last Edit: July 17, 2011, 12:31:15 AM by old-polack »
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10668
  • MLUs Forever!
Re: su and su - commands
« Reply #5 on: July 16, 2011, 03:20:33 AM »
Quote
Just su to root and use the rest of the line.
Should not that be su - ?


If using one of the newer ISOs you may find that "su" is aliased to "su -" .......  you can find out what aliases are set up by typing in a terminal

alias




i'm not gonna install the new iso in near time because my system is in good shape, but i want that alias. may i know how tex set that alias ? if in .bash_profile ... what the syntax ?
tia


http://www.mediacollege.com/linux/command/alias.html
« Last Edit: July 17, 2011, 12:31:32 AM by old-polack »
MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Online Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: su and su - commands
« Reply #6 on: July 16, 2011, 04:35:36 AM »
Excuse me for butting in with an off-topic question.
Is there a downside to using su -, instead of su?

Perhaps a few minor annoyances.

For instance: when you run "su" your current directory remains your current directory; but after running "su -" your current directory always becomes /root. So if you want to run a command on a file in what used to be your current directory, you have to specify the path to it, or cd back to it.

Note that if you su to root and a program needs root's envirenment, you don't have to exit and start again with "su -" and root's password; just type "su -" as root and you'll get the whole environment.

Quote
I never use su - unless I am following someone's advice.
My concern is that the results of certain commands from root environment could cause an ownership issue later on.
But I am a dummy.  ;D
Unfounded concern?

If you create a file or a folder as root that file or folder will be owned by root regardless of whether you've run "su" or "su -" to become root.
« Last Edit: July 17, 2011, 12:31:52 AM by old-polack »
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline jfdesign

  • Full Member
  • ***
  • Posts: 210
Re: su and su - commands
« Reply #7 on: July 16, 2011, 06:52:45 AM »
thank you old_polack and just19 for the help.  ;D
« Last Edit: July 17, 2011, 12:32:16 AM by old-polack »

Offline dvhenry

  • Full Member
  • ***
  • Posts: 106
Re: su and su - commands
« Reply #8 on: July 16, 2011, 06:35:18 PM »
A discussion on "su" verses "su -" that may be of interest to some is http://forums.opensuse.org/new-user-how-faq-read-only/unreviewed-how-faq/424498-become-su-terminal-howto.html
The discussion starts at post #7, and gets more interesting and detailed around post #20.
 It is from the openSUSE forums, but contains relevant info.
« Last Edit: July 17, 2011, 12:32:31 AM by old-polack »

Offline johnmart

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1105
  • Make Love Not War
Re: su and su - commands
« Reply #9 on: July 16, 2011, 08:00:34 PM »
Thanks BaldBrick. Cleared it up for me.  :)
Thanks too dvhenry. I'll give that a look. Haven't been there since suse.6, or was it 9?  :)
« Last Edit: July 17, 2011, 12:32:47 AM by old-polack »
Acer Aspire, Intel core2 2.20GHz, ‎Graphics nVidia ‎G98M [GeForce G 105M], 2gb ram, Wireless Intel Link 5100

Why, any 5 year old child could understand this.
Somebody bring me a 5 year old.
Groucho

Offline dvhenry

  • Full Member
  • ***
  • Posts: 106
Re: su and su - commands
« Reply #10 on: July 16, 2011, 11:06:23 PM »
Quote
Thanks too dvhenry. I'll give that a look. Haven't been there since suse.6, or was it 9?

It's an interesting read, and worth a look.

At this point, might I suggest that a moderator move posts from reply #15 on, to a separate thread with an appropriate title, as this has become 2 subjects.
Those interested in variations of the "su" command are not likely to start looking in a thread about UUIDs.
« Last Edit: July 17, 2011, 12:33:02 AM by old-polack »

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: su and su - commands
« Reply #11 on: August 01, 2011, 01:05:39 AM »
Where are these new set of aliases hardcoded??

I've looked in the .bashrc, /etc/profile, /etc/profile.d/60alias.sh ... and can't seem to find it.
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: su and su - commands
« Reply #12 on: August 01, 2011, 02:03:10 AM »
Where are these new set of aliases hardcoded??

I've looked in the .bashrc, /etc/profile, /etc/profile.d/60alias.sh ... and can't seem to find it.

/home/<user>/.bashrc

'su=su -' alias has been added in recent PCLinuxOS versions (kde-2011-06, -kde-minime-2011-07, ...),
you can't find it in your installation if you are rolling up from previous releases   ;)

AS

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: su and su - commands
« Reply #13 on: August 01, 2011, 02:31:03 AM »
Thanks, AS.

I must be getting blind. I was expecting a whole bunch of aliases, i.e. .bash_aliases ... and thanks to you, I found it at the end of the .bashrc line.   :-X   LOL.

Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline Vorteggs

  • Hero Member
  • *****
  • Posts: 2413
Re: su and su - commands
« Reply #14 on: August 01, 2011, 09:07:13 AM »
There's a related command unalias for those interested in. ;)