How to create restricted user in Linux

Introduction

Restricted users are made to run only specific commands allowed by the administrator to execute in terminal. So in order to restrict user following is the procedure.

Step 1: Copy bash shell

Copy bash shell from /bin/bash and paste it as new restricted bash shell.

# cp /bin/bash /bin/rbash
# chmod o+x /bin/rbash

useradd -s /bin/rbash testuser
mkdir /home/testuser/commands
passwd testuser

chown testuser:testuser /home/testuser/commands/
cp /usr/bin/free /home/testuser/commands/
cp /usr/bin/grep /home/testuser/commands/
chmod 755 /home/testuser/commands/free
chmod 755 /home/testuser/commands/top

cd ~testuser/
vi .bash_profile
PATH=$HOME/commands
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × 1 =