Score:0

How do I configure users on my ubuntu system without shell and execute only one command?

eg flag

I need to build a Ubuntu server where users will be logged in but I dont want them to give a shell access. As soon as the user logs in one custom command will be executed and it will be allow certain options.

I do not allow user to log in on shell or run any other commands.

Can you please suggest?

TIA Blaon R

Zareh Kasparian avatar
us flag
please explain more about the command you need to be executed.
Blason R avatar
eg flag
This is a custom bash script that I am going to write with case/esac stattement. May be by now we can take this script ``` #!/bin/bash echo -n "Tell me your name: " read resp echo $resp ```
Zareh Kasparian avatar
us flag
you just need to run the command ? no need to login ?
Blason R avatar
eg flag
That is correct - I mean once user logs in directly that command will be executed and option will be given. I do not want any shell access to be given for any user
Score:0
us flag

you just create your script as you said and place it in the user's home directory path(create the user with adduser command).

So for you case I written your script in shell-command.sh file.

#!/bin/bash
echo -n "Tell me your name: "
read resp
echo $resp

make the script executable.

 chmod a+x shell-command.sh

Open the /etc/passwd file and edit your desired user shell after his/her home directory path as below.

testuser:x:1001:1001:test user,,,:/home/testuser:/home/testuser/shell-command.sh

Done.

Blason R avatar
eg flag
Thats great - Ididnt know that- Thanks though let me test it out
Blason R avatar
eg flag
Well this works but output does not stay on console. As soon as the command is entered the output disappears
Zareh Kasparian avatar
us flag
what do you mean by saying console? are sshing to the remote server? or what ?
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.