i have several centos-7 installations. on most of them, if i try doing "sudo su;", i get a nasty warning message. however, on those installations i can just do "su;" and log in as root. this is what happens when i use my play centos-7 on virtualbox.
however, when i try the same thing on my google-cloud centos-7 installation, i can indeed do sudo su; in addition to everything else that sudo allows me to do.
i am thinking the best way to determine the difference is something like this:
Code: Select all
if [ '${$(groups)/sudo}' ] ;
then SUDO='sudo' ;
elif [ '${$(whoami)/root' ] ;
echo SUDO='nice'; ## 'nice' looks prettier than an empty string ''
else
echo 'you either need to be have sudo or be logged in as root!';
exit;
fi;
## initial installation:
${SUDO} yum -y update; ## a good idea to start out with.