0

I want to change ownership, group membership and access rights in a script by a sequence of commands.

Some of them need root permissions.

I first did sudo su in a terminal and then ran all the necessary commands once in a row. I found out that after sudo su all macro definitions abc=<...> have to be put after sudo su, because it seems that root does not know about macros existing in the other context.

After all my commands worked as expected, I called histoy, removed the line numbers and framed the relevant part of it in sudo su ... exit.

I can paste this sequence of commands into a terminal and it runs fine.

However if I prepend it with a line #!/bin/bash and store it as a file and make that executable, that does not work:

I get prompted for the password, but then I end up at a command line level, with the prompt ending in #, which shows me that sudo su has worked. But the rest of my command sequence has not worked.

How can I achieve the other commands to be executed?

Being a command line newbie, I guess I haven't understood something important yet. Please explain how to do it and why.

Adalbert Hanßen
  • 823
  • 15
  • 31

0 Answers0