-1

I have created a user.

useradd -M -d /usr/my_user my_user chown -R my_user. /usr/my_user 

Now as a root I can type:

su - my_user -c /usr/my_user/some_dir/script.sh 

but if I want to do more complicated things, for example navigate between my_user folders I have to type the su - my_user pattern every time. Otherwise it states that I do not have permissions.

How can I make my life easier and not type the su every time?

1
  • 8
    Why would you create a user and not log in as that user? Set a password for my_user and log in. Doing everything as root like you suggest is never a good idea. Commented Oct 5, 2016 at 18:42

2 Answers 2

0

It sounds like you can use a group.

groupadd my_group usermod -G my_group my_self usermod -G my_group my_user chown -R my_user:my_group /usr/my_user chmod -R g+w /usr/my_user 

Then you can login as my_selfand have access to /usr/my_user in the same way my_user can.

0

In order to fully switch context between users you have to provide following command

su my_user 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.