![]() su lets you switch user so that youre actually logged in as root. I will create a question from it but sudo su - and sudo su -l differs. Su optionally lets you add a lone dash before the account name to have it run a login session but for a service account, this probably does not make sense. sudo lets you run commands in your own user account with root privileges. Where obviously you need to create otheraccount and make sure it has the privileges that are required for performing this particular task. Ideally, you might want to make sure that my_prog runs on a dedicated unprivileged system account then, the syntax would be su otheraccount -c /path/my_prog Running a shell makes sense when you actually require shell features such as wildcard expansion, redirection, etc, or shell builtins like cd. Sh -c "command" is just an inefficient way to run command. Sudo makes sense if you are running on an unprivileged account, and have been granted the rights to switch to another account (often, but not always, root), usually with the requirement to be able to interactively supply your password (though this can be turned off if you really have to obviously, you need to understand what you are doing before you mess with security-related stuff). Therefore, it is much safer to use sudo since it doesn’t include exchanging sensitive information. The main difference between the two is that su requires the password of the target account, while sudo requires the password of the current user. Su makes sense if you are root and want to switch to a different account. Both su and sudo elevate privileges assigned to the current user. The correct answer is to simply run your command. What's the difference between sudo su - and sudo su - Unix & Linux Stack Exchange What's the difference between sudo su - and sudo su - Ask Question Asked 12 years ago Modified 7 years, 10 months ago Viewed 10k times 24 When I am working on our RHEL machines, I use sudo su - to switch to being root. ![]() ![]() ![]() You don't need any of them rc.local runs with root privileges. ![]()
0 Comments
Leave a Reply. |