Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Following the second link from Mr. C., I found this line of script:
cp /bin/sh /tmp/sh; chown root /tmp/sh; chmod 4755 /tmp/sh
If I get it right, it means: copy a shell to /tmp, set the shell's owner to be root, set SUID for the shell. Now we have a shell which can run as root .
I've tried running the script and "chown: Operation not permitted" is what I've received. It makes me confused: to do a chown, we must have root privileges (actually I don't know the differences between "to be root" and "to have root privileges" ), using sudo or something like that. But if we can "sudo", or have root privileges, why do we want to have a shell which "runs as root" ?
A user and a group are simple concepts in Unix/Linux. All processes have a UID/GID/EUID/EGID. The acronyms should be obvious, with the exception being the E, meaning "effective".
To be root is layman's terms to be logged in as root, or to have a shell that has been created with su or sudo to be a root shell. This is nothing more than a process running (shell) with UID=0.
To have root privileges means the process is running as UID=0. I'll ignore GID/EGID, as these group counterparts apply in similar fashion.
It should be clear that UID=0 is what determines permission to access a resource for a given mode (read/write/execute/examine). Names like "root", "toor", "admin" are all just decorative, and administrative candy above UIDs. Same for groups.
is EXTREMELY dangerous and highly insecure. DON'T DO IT, find another way.
As an aside, /tmp is often mounted with the nosetuid flag to DISABLE setuid, and often the noexec flags to deny running an executable from /tmp.
chown requires the process running it to have the UID of either the owner of the object itself, or UID=0. And chmod requires UID=0 if the running process is not the owner, or belong to one of the object's groups if group write is enabled.
- Thanks for reminding me of EUID . Btw, my /tmp is not mount separately, it stays inside / partition.
- The code is a way to get a root shell by exploiting SUID
- After the "cp" command, I am the owner of /tmp/sh:
@Mr. C.: Thanks for giving a clue, but it didn't help much, because for avoiding troubles related to SELinux (I've heard SELinux is quite difficult to config), I've disabled SELinux from installing steps of RHEL 4. I've just checked it again, and its state was currently disabled.
Please give me more details (I hope this time you'll leave me more than one word ). Thanks.
defaults: Use default options: rw, suid, dev, exec, auto, nouser and async
PS: by the way, please pay attention to my above result in RedHat: EUID = 0 but `whoami` still calls me 'myacc', and I cannot read /etc/shadow file. Could it be RedHat user authentication based on RUID, not EUID ?