![]() Note also that the Bash prompt changes as will with sudo -i but not with sudo -s: ls which sudo which sudo -s Here is an example, you can see that I have an application lsl in my ~/.bin/ directory which is accessible via sudo -s but not accessible with sudo -i. sudo -s gives you the user's environment, so your ~/.bashrc is respected.sudo -i gives you the root environment, i.e.The major difference between sudo -i and sudo -s is: This answer is a dupe of my answer on a dupe of this question, put here on the canonical answer so that people can find it! So, sudo su allows you to open a shell as another user (including root), if you're allowed super-user access by the /etc/sudoers file. Because su is invoked by root, it does not require you to enter the target user's password. The often-used sudo su combination works as follows: first sudo asks you for your password, and, if you're allowed to do so, invokes the next command ( su) as a super-user. user X is only able to run program Y etc. it's not possible to login as root directly.Īlso, /etc/sudoers allows to specify some additional options - i.e. This results in much cleaner management of privileges.Īs a result of this, in many Debian-based systems root user has no password set - i.e. To revoke admin privileges from a person, you just need to edit the config file (or remove the user from a group which is listed in that config). It uses a config file (/etc/sudoers) which lists which users have rights to specific actions (run commands as root, etc.) When invoked, it asks for the password of the user who started it - to ensure the person at the terminal is really the same "joe" who's listed in /etc/sudoers. what's the mnemonic? Super-User-DO?) is completely different. If you need to revoke admin permissions from one of the users, you need to change root password and tell it only to those people who need to keep access - messy. If there are several users on your machine who need to run commands as root, they all need to know root password - note that it'll be the same password. So, to become root, you need to know root password. To ensure you have the rights to do that, it asks you for the password of the target user. Su (which means "substitute user" or "switch user") - does exactly that, it starts another shell instance with privileges of the target user. Wasudox start notepad C:\Windows\System32\drivers\etc\hostsįor more details, visit the GitHub repro.The main difference between these commands is in the way they restrict access to their functions. Wsudo runs a program or an inline command with elevated rights in the current directory. Your system most likely already has PowerShell 5.x installed, otherwise you'll be offered to install it as a dependency. Instead, it uses a helper PowerShell 5.1 script that invokes "Start-Process -Wait -Verb runAs. This implementation doesn't depend on the legacy Windows Script Host ( CScript). Wsudo is a Linux sudo-like tool for Windows to invoke a program with elevated rights (as Administrator) from a non-admin shell command prompt and keeping its current directory. Installation choco install wsudoĬhocolatey must be already installed. I use it a lot for stuff like configuring build agents, admin things like sfc /scannow, dism /online /cleanup-image /restorehealth or simply for installing/updating my local Chocolatey packages. I've created wsudo, an open-source sudo-like CLI tool for Windows to run programs or commands with elevated right, in the context of the current directory. The /c is a cmd parameter for closing the window after the command is finished, and the /k is a cmd parameter for keeping the window open.Ĭredit to Adam Plocher for the staying in the current directory code. the
0 Comments
Leave a Reply. |