Knowing which sudo or su command to run is important. Jack Wallen demystifies these two Linux administration tools.
There are different ways to use sudo and su. Let’s remove the mystery.
If you issue the command su, you switch the user to root which then only runs the .bashrc file owned by root. Execute the command su – and you invoke a logon shell after switching users, which resets most environment variables and provides a clean base.
SEE: Linux file and directory management commands (TechRepublic Premium)
If you use only sudo, execute a command with administrator privileges. If you run the command sudo su – you want to switch to the root user who then runs all / etc / profile, .profile and .bashrc files by root, but only if the user running the command is defined in the / etc / sudoers file, and effectively becomes the root user, even if the root user is disabled, as it is in Ubuntu.
Finally, if you issue the command sudo su, you switch to the root user, without resetting the environment variables, so you have the root user rights, but not the environment. Often you just need to run the basics sudo or su commands. However, if it is a command, you must run it and it will fail with a minimum sudo command, either sudo – or sudo su – will always work.
Only use these commands with care so that you do not end up destroying the Linux desktop or server.
Subscribe to TechRepublics How To Make Tech Work on YouTube for all the latest technical advice for professional professionals from Jack Wallen.