I recently started trying openSUSE 12.3 after having used Ubuntu for a few years. I'm still getting used to openSUSE's treatment of
sudo) vs. Ubuntu's use of
sudo. I've been reading the openSUSE manual, but can't figure out answers to two related questions:
1) In a previous question at http://askubuntu.com/questions/236859/are-there-adverse-effects-from-or-a-better-way-than-writing-to-run-or-dev-sh, I asked about writing a decrypted
gpg file temporarily to
/run using the
gpg --output flag so that the decrypted file would never touch the hard disk. In order to write to
/run, however, I needed to use
sudo in Ubuntu (i.e.,
sudo gpg --output '/run/temporary_file_name' etc.).
When I try to do the same thing in openSUSE (using either
su), I get an error message from
gpg, presumably because the root user cannot see my user account's gpg keys. Can this use of
`sudo from Ubuntu, in which
sudo seems to use the same preferences / gpg keys as the regular user, be replicated in openSUSE? I could use
gpg etc. | tee etc., I suppose, but that seems unwieldy compared to Ubuntu's way of doing things.
2) I have several bash scripts from Ubuntu that require root privileges for some, but not all, lines (e.g., copying files that I don't want to get owned by root, but then installing new software, which requires root privileges). In Ubuntu, I could just have some lines start with
sudo some_command doesn't always seem to work in openSUSE, though. Is the best way to adapt these scripts for openSUSE to use
su -c 'command' on those lines of the script? If I use
su by itself in the script, the script stops working after I enter the root password.
Please note that, while I'm asking about openSUSE specifically, this question presumably applied to many non-Ubuntu distros.