Linux (for users and su / sudo commands)

Here is a brief description of the user. ・ General users </ b> ・ root user </ b> Please understand.

The root user is simply an administrator. You can change the user's password and change important files. I don't think it's usually used. It is a recognition that is used when it is needed for some reason.

On the contrary, general users will use it when working on a daily basis. This is where I usually use it.

At the prompt, you can distinguish as follows.

For root


#

For general users


$

For the time being, there is no problem if you think that there are general users and root users. For the time being, reasoning is important for doing lpic101 (it's hard to remember)

From here, I will explain the command su </ b> / sudo </ b>. The su command is the command used to switch users.

For example, when you want to switch from the general user neko to the root user If you enter the root user password after entering the su command as shown below The switch to the root user is performed.

neko     $  su
password:  

After entering the password, you will be prompted as root.

neko     $  su
password:
root     #

When switching from a general user to a general user with a different pattern su Enter the user name and enter the password.

neko     $   su inu
password:

Inu will return a prompt.

neko     $   su inu
password:
inu      $

Next is the sudo command. You can temporarily use the command with root privileges.

You must edit visudo to use this command. If you are not root, you cannot edit. Use the su command to switch to the root user.

root   # visudo

I wrote a lot in English Enter the user name ALL = (ALL) ALL in the last line If you save and close it, you can use the sudo command.

  • An editor is used when editing files. I will explain about this at another time. Press the o key to start input, and then press the Esc key →: wq to save and close the file.

Although it is a sudo command For example, when you want to execute the ls command while having root privileges Just type sudo ls and you're done.

・ About general users and root users ・ About su and sudo

was.

Next → About adding / deleting users

Recommended Posts