sudo - Unix, Linux Command

About sudo

Linux sudo command
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service , privacy policy and cookie policy , and that your continued use of the website is subject to these policies. To combat this, some system-specific environment variables are removed from the environment that is passed on to the commands that are executed. If the directory does not exist or if it is not really a directory, the entry is ignored and no error is printed. This timestamp can be renewed if the user issues sudo with the -v flag. The -- flag indicates that sudo should stop processing command line arguments.

Description


If you need all changes to the files to be logged, use a version control system like cvs, svn, or git: If you omit the " userY " part, then userX will be allowed to edit the file with root-like access.

You'll need to find the exact commands required to install that software, and allow them as in 3. If httpd requires root permissions to run e. Without the "sudo" prefix, the non-root user will run the command as himself, without root permissions.

Without root permissions, httpd will not be able to open port 80 nor its log files, and it will fail. No such file or directory. This means the home directory of user "john" has not been created, i. But that should not be a problem for sudo Hmm, your previous message indicated your sudoers file has at least lines, so this is probably caused by something else in your configuration you have not shown me For example, do you have something like this in your sudoers file:.

If your sudoers configuration is very complex lines can be very complex indeed! I have a sh script that needs to be run as root, however it is run by the end user using sudo. You can use eval as follows:. To test out, I created this script:. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service , privacy policy and cookie policy , and that your continued use of the website is subject to these policies.

Get users home directory when they run a script as root Ask Question. Peter-W 1 7 You can use eval as follows: Try to avoid eval. See my answer without eval. You don't need the eval here. I'm determined to figure this out. Adding the -s option along -c did the trick. Thanks for the effort. Unfundednut 5, 4 19 That produces an authentication error on Ubuntu. I have never had an issue for me. For OP it would, certainly, as he doesn't doesn't have a proper root account. Interesting, I am on a fresh install of Ubuntu, I never 'setup' a root user yet I can simply sudo - and bam I am god of the system.

Yeah, I just get an authentication error. For me a combination of sudo and screen worked out: This is full of wrong. What does GDM have to do with anything?

OP wants to 'cd' to a dir readable only by root. No one should ever log in as root via GDM. I didn't fully read what I was pasting there.

Your Answer

Thus sudo -s preserves HOME on Ubuntu, while on Debian HOME is erased and sudo then sets it to the home directory of the target user. You can override this behavior in the sudoers file. Run visudo to edit the sudoers file. I setup an autofs to mount over top of /home; the mount does not include a folder for the sudo user. I can't log in to the machines to change the sudo user's home directory, nor add a different user (who does have a /home directory to the sudo group). sudo will check the ownership of its timestamp directory (/var/run/sudo by default) and ignore the directory's contents if it is not owned by root and only writable by root. On systems that allow non-root users to give away files via chown, if the timestamp directory is located in a directory writable by anyone (e.g.: /tmp), it is possible.