Leave it as a memo for yourself.
Now, I understand, but when I first operate the Linux OS, "Why is sudo su depressed?" "Why is there no su behind sudo this time?" "Well, this time. There is a- (hyphen) behind su? "And I was confused. There is a feeling of renewal now, but if you are a windows user, you will be asked "What is sudo su after all?", So I tried to summarize it in the sense of knowing the command properly.
To execute the command following sudo as superuser (= root). In other words, only at that moment, you will have root privileges and execute commands. In summary, it will be "Execute the XX command with administrator privileges." It may be a little different, but is it like UAC on Windows?
#Use if you have a command you want to run as an administrator
sudo command
The "su" that often follows sudo is a command. So what happens when you run the su command? The su command is a command to switch users. When this su command is executed, the subsequent operations will be performed by the switched user. If you compare it with windows, I think that you can switch users with Alt + F4 while the desktop is displayed. I think the su command is similar to that because it does not log off the currently signed account and signs in with another account (strictly speaking, it's completely different, but it's a rough concept. I think it's like that ...)
#Use when you want to switch users.
su Switch account name
#(Omitting the account name implicitly handles user switching as root (important))
The su command may or may not have a- (hyphen). This is simple and when hyphenated, the option is to move the current directory to the switched user's home directory when switching accounts. Therefore, if you do not want to switch the current directory, do not add a hyphen.
#Switch user + move to the home directory of the switched user
su -Account name to switch
that's all.
Recommended Posts