LinuxQuestions.org
Help answer threads with 0 replies.
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 05-21-2018, 07:35 AM   #1
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
Should I be using su or su - for software installation?


Since I started using Slackware I have been using su for package compiling/install. Should I be using su - instead?
 
Old 05-21-2018, 07:50 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Yes.

"su" by itself doesn't invoke root's environment. "su -" does.

Among other things, the PATH for root often has things it needs that regular users don't.
 
4 members found this post helpful.
Old 05-21-2018, 08:42 AM   #3
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
Quote:
Originally Posted by MensaWater View Post
Yes.

"su" by itself doesn't invoke root's environment. "su -" does.

Among other things, the PATH for root often has things it needs that regular users don't.
namely /sbin and /usr/sbin, that's all

if you add them to your user, you can compile even via fakeroot
and install via sudo or su, if wanted
 
Old 05-21-2018, 09:08 AM   #4
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178

Original Poster
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
As far as I can see it, su - is the same as su -l whereby the 'l' stands for login. So this gives a 'true' login shell as opposed to su which simulates a root environment without changing environmental variables. So su -l means the user is performing tasks as if they had logged in as root as a primary user.

As for PATH, so this is the variable that tells the OS where to locate a particular program. I have never had a problem launching a program from the command line after installing with su [mind you, I often don't launch via the command line].

Last edited by Lysander666; 05-21-2018 at 09:10 AM.
 
Old 05-21-2018, 09:57 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,630

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
I think you misinterpreted it a bit:
su will start a new shell which is owned by root (or owned by the user specified with -l <user>). It does not simulate anything, just start a new shell.
The difference between using and omitting - is: how the environment of the new shell will be set. Using - it will be reinitialized like a login shell, without - it will be just inherited from the parent process.
see man su:
Quote:
A mere - implies -l. If USER not given, assume root.
 
1 members found this post helpful.
Old 05-21-2018, 12:01 PM   #6
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by a4z View Post
namely /sbin and /usr/sbin, that's all

if you add them to your user, you can compile even via fakeroot
and install via sudo or su, if wanted
I listed PATH as only one example. There are often others one needs as root. Why take the risk of just doing "su" when you know "su -" will setup the environment the way it should be for root? Why put things in user environments that they may not need and/or shouldn't run even if they could?

In addition to things being in root's environment that may not be in the regular user's (that did the su) environment is the opposite issue. There may be things inherited from the regular user's environment that you don't want in root's if you only did "su".
 
Old 05-21-2018, 01:15 PM   #7
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
Quote:
Originally Posted by MensaWater View Post
I listed PATH as only one example. There are often others one needs as root.
not for building software, if there would be , than this is a problem in the software

Quote:
Originally Posted by MensaWater View Post
Why take the risk of just doing "su" when you know "su -" will setup the environment the way it should be for root? Why put things in user environments that they may not need and/or shouldn't run even if they could?

In addition to things being in root's environment that may not be in the regular user's (that did the su) environment is the opposite issue. There may be things inherited from the regular user's environment that you don't want in root's if you only did "su".
why take the risk and build software as root? because it has been done so 1993 and hasn't been charged since then?
and if /sbin and /usr/sbin are in your path, pkgtools are available and you can use su or su- or sudo , it doesn't matter, and this is a valid answer to the topic, see first post
 
Old 05-21-2018, 01:46 PM   #8
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Quote:
Originally Posted by a4z View Post
not for building software, if there would be , than this is a problem in the software

why take the risk and build software as root? because it has been done so 1993 and hasn't been charged since then?
and if /sbin and /usr/sbin are in your path, pkgtools are available and you can use su or su- or sudo , it doesn't matter, and this is a valid answer to the topic, see first post

Yeah but ...

Why bother with /sbin/ and /usr/sbin/ if they're going to be added to every mere mortal user's PATH ?

If a regular user can execute /sbin/makepkg within a proper fakeroot environment, then maybe /sbin/makepkg should be moved to /bin/ ?

Just wondering ...

-- kjh
 
Old 05-21-2018, 02:27 PM   #9
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,044

Rep: Reputation: Disabled
Quote:
Originally Posted by kjhambrick View Post
If a regular user can execute /sbin/makepkg within a proper fakeroot environment, then maybe /sbin/makepkg should be moved to /bin/ ?
No need for that. I always build packages using fakeroot (e.g. fakeroot sh something.SlackBuild). This just needs to call makepkg with its full path. Which is the case for all recent SlackBuilds provided by Slackware iirc, else just edit the SlackBuild and write /sbin/makepkg instead of makepkg.

And we still need to have all files in the package owned by root or specific system user, not a regular user.

Last edited by Didier Spaier; 05-21-2018 at 05:43 PM. Reason: Ugly typos fixed?
 
1 members found this post helpful.
Old 05-21-2018, 03:44 PM   #10
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178

Original Poster
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
Quote:
Originally Posted by pan64 View Post
I think you misinterpreted it a bit:
su will start a new shell which is owned by root (or owned by the user specified with -l <user>). It does not simulate anything, just start a new shell.
The difference between using and omitting - is: how the environment of the new shell will be set. Using - it will be reinitialized like a login shell, without - it will be just inherited from the parent process.
see man su:
Understood, thank you.

Slackware:

Code:
lysander@lyslackertest:~$ su
Password:
bash-4.3# exit
exit
lysander@lyslackertest:~$ su -
Password:

In the future, there will be fewer but better Russians.
        -- Joseph Stalin

root@lyslackertest:~#
Debian:

Code:
lysander@psychopig-xxxiii:~$ su
Password: 
root@psychopig-xxxiii:/home/lysander# exit
exit
lysander@psychopig-xxxiii:~$ su -
Password: 
root@psychopig-xxxiii:~#
Hmm something is not right in Slack since I'm getting bash-4.3. Maybe I need to edit bash.rc.

EDIT: Amusing Stalin quote.

Last edited by Lysander666; 05-21-2018 at 03:51 PM.
 
Old 05-21-2018, 05:11 PM   #11
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Quote:
Originally Posted by Didier Spaier View Post

<<snip>>

And we still need to have all files in the package owned by root or specific system user, not a regular user.
Hmmm ...

I gotta get with the `fakeroot.sh somepackage.SlackBuild` program here

I am going to experiment with that a tad.

Thanks for the tip Didier Spaier !

-- kjh

P.S. Back to Lysander666's original Q:

YMMV

I was taught 'way back when' to always invoke `su -` unless there was a good reason not to ...

One occasional good reason not to for me is: I use a simple `su` instead of `su -` when I need to invoke chmod root:root <<FileOrDirectory>> on a file or directory in-or-relative-to my current working directory.

Invoking `su` gives me root privileges but leaves me 'where-ever I am at', directory-wise ...

Anyhow, I learned all this before there were `sudo` or `fakeroot` commands ... so ...

YMMV
 
Old 05-21-2018, 05:29 PM   #12
TommyC7
Member
 
Registered: Mar 2012
Distribution: Slackware, CentOS, OpenBSD, FreeBSD
Posts: 528

Rep: Reputation: Disabled
Code:
sudo -i
is nice too. ^_^
 
Old 05-21-2018, 06:50 PM   #13
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,873

Rep: Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982Reputation: 4982
Quote:
Originally Posted by Didier Spaier View Post
No need for that. I always build packages using fakeroot (e.g. fakeroot sh something.SlackBuild). This just needs to call makepkg with its full path. Which is the case for all recent SlackBuilds provided by Slackware iirc, else just edit the SlackBuild and write /sbin/makepkg instead of makepkg.

And we still need to have all files in the package owned by root or specific system user, not a regular user.
All my buildscrips run as a non-root user. I wrote a wrapper around makepkg (which gets run via sudo) that does some of the common stuff that every slackbuild does (compress manpages, info files, remove the .la (recent change), etc.) so that I don't have to include them in my build scripts themselves.

I can remember reading some stuff about fakeroot's use of LD_LIBRARY_PATH/LD_PRELOAD causing issues with configure runs for some software, so I never really liked the idea of using it. Once in a while I find a makefile that needs fixing to run as non-root, but most things just build straight out of the tarball. Obviously, Pat's stock slackbuilds and SBo scripts can't be used by non-root users without something like fakeroot.


P.S. As for installing packages. I usually ctrl-alt-f1, login and install from there.
 
Old 05-22-2018, 02:01 AM   #14
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
Quote:
Originally Posted by kjhambrick View Post
Yeah but ...

Why bother with /sbin/ and /usr/sbin/ if they're going to be added to every mere mortal user's PATH ?

If a regular user can execute /sbin/makepkg within a proper fakeroot environment, then maybe /sbin/makepkg should be moved to /bin/ ?

Just wondering ...

-- kjh
fakeroot is, unfortunately, not part of Slackware and/or the Slackware philosophy, or whatever, there have been threads about this in the past.
however, if you have sudo rights, or you can su, than you a defacto admin, and not having everything in */sbin in you path is annoying anyway.
so extending you wheel group's users path is something that can be easy done, as installing fakeroot. without waiting for a change that will never come.
 
2 members found this post helpful.
Old 05-22-2018, 06:33 AM   #15
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,943

Rep: Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526Reputation: 1526
Quote:
Originally Posted by kjhambrick View Post
I was taught 'way back when' to always invoke `su -` unless there was a good reason not to ...

One occasional good reason not to for me is: I use a simple `su` instead of `su -` when I need to invoke chmod root:root <<FileOrDirectory>> on a file or directory in-or-relative-to my current working directory.

Invoking `su` gives me root privileges but leaves me 'where-ever I am at', directory-wise ...
I do the same thing. Occasionally as root I will issue a 'su chris' to do something as my self in the same directory.

I build my packages from su - or logged in as root. FYI you could also issue su - root, same result. To much extra typing

Last edited by chrisretusn; 05-22-2018 at 06:36 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
Software installation with parameters (installation time) BeeZone Linux - Software 1 09-12-2017 07:39 PM
seeking comprehensive guides to software sources and software installation guides geniuspenguis Linux - General 6 04-30-2015 06:14 AM
[SOLVED] Software installation problem in ubuntu 10.10 by software center Puneet Jindal Linux - Newbie 1 04-11-2011 06:17 AM
Adding an old software-RAID array to a software-RAID installation.. Boot problems GarethM Linux - Hardware 2 05-05-2008 03:16 PM
Installation Software for Custom Developed Java/Perl Software donkey123 Linux - Software 0 06-15-2005 05:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:11 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
Open Source Consulting | Domain Registration