Score:0

Block commands to a user

pm flag

is there a way to block all terminal commands on user leo on ubuntu 22.04 except cd, ls and pm2 restart?

I tried adding 8Th09x34VEhh ALL=(ALL) NOPASSWD: /usr/bin/pm2 restart RjbRTmVw in visudo but it asks for leo's password. I would like to ask the root one or "permission denied"

raj avatar
cn flag
raj
I'm not sure why did you use `visudo` as using this method, you can only restrict what commands can be executed if the user in question runs `sudo` or someone else runs `sudo` to that user's account. It doesn't restrict commands available to the user after "normal" login in any way. You can do the later by giving the user a restricted shell and modifying appropriately their `PATH` variable to point to a directory where only a few available commands exist, but restricted shell by itself disables the use of `cd` command, so you cannot fully achieve what you want.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.