1

I am creating some files by sudoing as a user u1.

sudo -u u1 touch file1.txt. The files are created with g-w permission. When I login as u1 and create a file, the file gets created with g+s permission.

How can I create the files with g+s permission using sudo -u command ? The umask value for u1 is 002.

Thanks

Varun
  • 51
  • 1
  • 5
  • the umask is being set by one of the login scripts, you need to invoke the login scripts to ensure that the variable is set. This is not a programming question. – Anya Shenanigans Jul 31 '14 at 12:05

1 Answers1

0

How can I create the files with g+s permission using sudo -u command ?

sudo -u u1 sh -c 'touch file1.txt && chmod g+s file1.txt'
Armali
  • 18,255
  • 14
  • 57
  • 171