-1

When I run sudo -i -u www-data -g www-data env

I get sudo: unable to change directory to /var/www: No such file or directory

This must be coming from script somewhere, but I don't know where. How would I find this out and fix it? Is there a standard list of areas to check?

Thank you in advance!

Cenoc
  • 217
  • 1
  • 12

2 Answers2

1

What does "Must coming from a script" means? The message is clear: The home directory defined (most likely) in /etc/passwd for the user www-data doesn't exist (see getent passwd www-data).

What do you want to do anyway with this command?

Sven
  • 98,649
  • 14
  • 180
  • 226
  • The command is there to make sure the stuff that should be accessible to the server is created with www-data:www-data, the -i is to get the environment loaded properly for rbenv to work. If you see holes in that, your opinion would be appreciated. As for coming from a script, I mean there must be something that is trying to change directory to www-data - that was the issue though. Thank you! – Cenoc Oct 26 '15 at 19:14
1

From the sudo man page

-i, --login Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's -c option. If no command is specified, an interactive shell is executed. sudo attempts to change to that user's home directory before running the shell. The command is run with an environment similar to the one a user would receive at log in. The Command environment section in the sudoers(5) manual documents how the -i option affects the environment in which a command is run when the sudoers policy is in use.

So it seems likely that this will be coming from something to do with the www-data account.

I would start by looking in the passwd file for the www-data user entry and working on from there.

user9517
  • 115,471
  • 20
  • 215
  • 297