现在的位置: 首页 > 综合 > 正文

What’s the Difference Between Sudo & Su?

2018年06月10日 ⁄ 综合 ⁄ 共 1207字 ⁄ 字号 评论关闭
文章目录

Sudo and su are two different ways to gain root privileges. Each functions in a different way, and different Linux distributions use different configurations by default.

The Root User

Both su and sudo are used to run commands with root permissions. The root user is basically equivalent to the administrator user on Windows – the root user has maximum permissions and can do anything to the system. Normal users on Linux run with reduced
permissions – for example, they can’t install software or write to system directories.

To do something that requires these permissions, you’ll have to acquire them with su or sudo.

Su vs. Sudo

The su command switches to the super user – or root user – when you execute it with no additional options. You’ll have to enter the root account’s password. This isn’t all the su command does, though – you can use it to switch to any user account. If you
execute the su bob command, you’ll be prompted to enter Bob’s password and the shell will switch to Bob’s user account.

Once you’re done running commands in the root shell, you should type exit to leave the root shell and go back to limited-privileges mode.

Sudo runs a single command with root privileges. When you execute sudo command, the system prompts you for your current user account’s password before running
command as the root user. By default, Ubuntu remembers the password for fifteen minutes and won’t ask for a password again until the fifteen minutes are up.

抱歉!评论已关闭.