What is su command in linux




















If a username is specified, su defaults to the superuser root. Simply find the user you need and add it to the su command syntax. If you omit a username, it will default to the root account. Now, the logged-in user can run all system commands.

This will also change the home directory and path to executable files. Note : If you are having issues with authentication, you can change the root or sudo password in a couple of simple steps.

To run a specific command as a different user, use the —c option:. When you enter this example, the system will use the specified account to run the ls list directory contents command. You can keep the environment of the current user account with the —p option:. The sudo command grants a one-time or limited-time access to root functionality. It also logs all commands and arguments so there is a record of who used it for what, and when.

The sudo command also makes it easier to practice the principle of least privilege PoLP , which is a computer security concept that helps control system access and potential system exploits and compromises. For more information about the sudo command, visit A.

Lawrence's Using sudo page. The su command allows you to become another user. To use the su command on a per-command basis, enter:. Replace user with the name of the account which you'd like to run the command as, and command with the command you need to run as another user.

To switch users before running many commands, enter:. The user feature is optional; if you don't provide a user, the su command defaults to the root account, which in Unix is the system administrator account. If this command was terminated by a signal, su returns the number of this signal plus If su has to kill the command because it was asked to terminate, and the command did not terminate in time , su returns While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.

Home Linux Commands. Please re-enable javascript in your browser settings. Ubuntu Linux Commands bc cat chgrp chmod chown cp date df diff du free gawk awk grep gzip halt head kill ls man mkdir more mv passwd ps pwd reboot rm rsync sed shutdown su tail tar uptime vim vi wc which whoami. Linux: su command This Linux tutorial explains how to use the Linux su command with syntax and arguments. On Unix-like operating systems, the su command changes the current user ID to that of the superuser , or another specified user.

The su command, which is short for substitute user or switch user , enables the current user to act as another user during the current login session. If no username is specified, su defaults to becoming the superuser root.

Additional arguments may be provided after the username, in which case they are supplied to the user's login shell. In particular, an argument of -c causes the next argument to be treated as a command by most command interpreters. The optional argument " - " a dash may be used to provide an environment similar to what the user would expect had the user logged in directly.

You can use the " -- " argument to separate su options from the arguments supplied to the shell. The user will be prompted for a password , if appropriate. Invalid passwords produce an error message.



0コメント

  • 1000 / 1000