![]() If you just use su, command will not be found because PATH variable has not been updated to include directory. ![]() Suppose you need to run a command that is located in a directory that is not in system's PATH variable. Example 1: Running a command with updated environment variables Let's take a look at some examples of when using su – can be more beneficial than just su. For example, if you need to run a process that requires more open files than current user account is allowed, you can use su – to switch to root account and have access to more resources. This can be useful if you need to run a command that requires more resources than current user account is allowed. When you use su –, new shell environment will also have target user's resource limits and ulimit values. For example, if you need to edit a file that is located in target user's home directory, it is easier to just use su – and have home directory already set as current working directory. This can be useful if you need to perform operations that require access to target user's home directory. When you use su –, new shell environment will have target user's home directory as its current working directory. However, if you use su –, new shell environment will have updated PATH variable, and command will be found. For example, let's say you need to run a command that is located in a directory that is not in system's PATH variable. This is useful if you need to run commands that rely on specific environment variables. Environment VariablesĪs mentioned above, su – creates a new shell environment with target user's environment variables. Let's explore some of these reasons below. There are several reasons why using su – can be more beneficial than just su. This means that any changes made to environment variables, such as PATH or HOME, will be applied to new shell. The su – command, on other hand, not only switches to target user account but also creates a new shell environment with that user's environment variables. Once you enter correct password, you are granted access to that user's account. When you type su followed by name of user you want to switch to, system prompts you for password of that user. The su command is used to switch to another user account on system, typically root account. In this article, we will explore reasons behind using su – and provide examples of how it can be beneficial. ![]() However, in some cases, it is recommended to use su – instead of just su. One of most common tasks performed by system administrators on Linux systems is to switch to root user account using su command. ![]() So, to wrap this up, when you pass only - to su it is basically ignoring the - and acting like you did not pass any option at all.The Linux operating system is a powerful tool that offers a wide range of features and functionalities to its users. This is true of many command-line tools ( ls -R will do a recursive ls whereas ls -R will perform an ls on a file or directory named -R. For example, if you run touch -R you'll receive an error saying that -R is not an option to touch, but if you run touch -R it will create a file named -R. Passing a double-hyphen to a command is typically used to mark the end of command-line flags and the beginning of non-flag arguments. This includes setting your directory to your home directory and setting a bunch of other environment variables. ![]() Provide an environment similar to what the user would expect had the user logged in directly. The man page for su describes the behavior as: Passing a single hyphen is identical to passing -l or -login. When you provide a double-hyphen the experience you will have is identical to if you had just executed sudo su without any hyphen. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |