Wednesday 31 May 2023

Create user Ubuntu with the command and directory restriction

 Create User:

    sudo useradd -m user_name -s /bin/rbash

    sudo passwd user_name

    Enter password


Make Directory and grant permission  

    sudo mkdir /home/user_name/bin

    sudo chown root. /home/user_name/.profile

    sudo chmod 755 /home/user_name/.profile


Restrict Directory and access


sudo vim /home/user_name/.profile


################ADD BELOW IN FILE#######

# if running bash

if [ -n "$BASH_VERSION" ]; then

    # include .bashrc if it exists

    if [ -f "$HOME/.bashrc" ]; then

. "$HOME/.bashrc"

    fi

fi


# set PATH so it includes user's private bin if it exists

PATH=$HOME/bin


export PATH

#########################################


Assign Commands

sudo ln -s /bin/grep /home/user_name/bin/tail

sudo ln -s /bin/cat /home/user_name/bin/cat

sudo ln -s /bin/echo /home/user_name/bin/more

No comments:

Post a Comment

Enable 'HTML Manager'- Apache Tomcat

 Enable 'HTML Manager'- Apache Tomcat Go to Apache-tomcat's home directory and edit the tomcat-users.xml ${apache_home}/conf/tom...