![]() If you run the command sudo su – you will switch to the root user which will then execute all /etc/profile. If you use just sudo, you execute a command with admin privileges. SEE: Linux file and directory management commands (TechRepublic Premium) Execute the command su – and you invoke a login shell after switching the user, which resets most environment variables, providing a clean base. If you issue the command su, you switch your user to root, which then executes only the. There are different ways to use sudo and su. New Malware Targets 97 Browser Variants, 76 Crypto Wallets & 19 Password Managers How Generative AI is a Game Changer for Cloud Security Must-read security coverageĨ Best Penetration Testing Tools and Software for 2023Ħ Best Cybersecurity Certifications of 2023 Even though most every Linux distribution uses sudo, some of them (such as Fedora and openSUSE) allow you to su (switch user) to the super user account–otherwise known as root. Sudo stands for “super user do” and allows standard users to take admin-level actions, such as installing software. Always remember to use these commands with caution, as they can provide you with the power to make significant changes to your system.If you’re a new Linux admin, you probably at least know about sudo. Understanding the differences between these commands and how they affect your environment is crucial for managing Unix-like systems effectively. However, there are situations where using su or sudo su may be necessary, such as when becoming another user in one-off situations or when repairing a system from a live CD/USB. In general, it is recommended to use sudo instead of su for most tasks, as it provides better management of privileges and allows for more granular control over user access through the /etc/sudoers file. However, because it uses su, it does not require an entry in the /etc/sudoers file for the second part of the command. Like sudo -s, it does not change your environment variables to match the root’s. When you run sudo su, it asks for your password and, if you have the necessary permissions, gives you a root shell. ![]() It first uses sudo to become root and then uses su to open a new shell as root. The sudo su command is a combination of sudo and su. This means that your environment will be the same as if you had logged in as root directly. However, unlike su and sudo -s, sudo -i sets the working directory to the root’s home directory ( /root) and sources the root’s. When you run sudo -i, it asks for your password and, if you have the necessary permissions, gives you a root shell. The sudo -i command is similar to sudo -s, but it simulates an initial login, which changes the environment variables to those of the target user. This means that your home directory and other settings will remain the same as your original user. Similar to su, sudo -s does not change your environment variables. The -s option stands for shell and it opens a new shell session. Instead, it asks for your own password and, if you have the necessary permissions as defined in the /etc/sudoers file, it grants you root access. Unlike su, sudo -s does not require the root password. ![]() The sudo -s command runs a shell with root privileges. This means that your home directory, for example, will still point to the original user’s home directory. However, it does not change the environment variables to match the target user’s. When you run su, it starts a new shell instance with the privileges of the target user. To use this command, you need to know the password of the account you’re switching to. By default, without specifying a username, su will switch to the root account. The su command, short for “substitute user,” allows you to switch to another user’s account. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |