I understand the concept of managing permissions on Linux with chmod
using the first digit as the user, the second as the group and the third as other users as described on this answer in Understanding UNIX permissions and file types.
Let's say I have a Linux system with 5 users: admin
, usera
, userb
, userc
and guest
. By default, the users usera
, userb
and userc
will have execution permission on all files inside /usr/bin
, so these users can use the command line of the system executing the files in there as those files have 755 permission. So far it's completely ok. However, I'd like to forbid the user guest
from executing files on the folder /usr/bin
, I know I could achieve that by changing the permission of all files inside this folder to something like 750 with chmod
, but if I do that I'll mess up the permissions of the users usera
, userb
and userc
because they will be also forbidden to execute files.
On my computer, all the files in /usr/bin
belong to the group root
, so I know I could create a newgroup
, change the group of all those files to it and add usera
, userb
and userc
to newgroup
. But doing that sounds like way too much modification on the system's default settings. Does anyone know a smarter way of solving this problem?
How can I forbid a single user from using the command line (or executing any file on PATH
) without an overcomplicated solution that requires changing the permissions of too many files?
guest
won't even have a shell to start, because/usr/bin
and/bin
are identical in many modern distros. (My gut feeling would be to try and put them in a chroot jail; it's possible thatsystemd
even gives you nice automatisms for that, like it does for services.) – Ulrich Schwarz Mar 05 '20 at 08:42guest
just so he can port forward the system to have access to specific web applications. Even with the terminal dead for running the shell, applications running on ports by other users on the system will still work fine after port forwarding. – Rafael Muynarsk Mar 05 '20 at 17:00/var/empty
over/usr/bin
in a private filesystem namespace during login for the relevant user. Why do something that modifies the filesystem for everyone, when you can modify the filesystem only for the one user? – Charles Duffy Mar 05 '20 at 17:38man pam_namespace
+man namespace.conf
) – A.B Mar 05 '20 at 20:34chmod o= ...files...
to clear only the "other" field and leave u/g and the other bits like temp and set[ug]id alone. But to be very, very clear, doing that with/usr/bin
is a horrible idea. I really do recommend the bind-mount approach to leave the rest of the system alone while changing a single user's view of it. – Charles Duffy Mar 06 '20 at 00:58