Skip to content

Users and sudo

Linux & the command line Lesson 12 2:00 English narration · English + 中文 subtitles burned in

space play · ←/→ 5s · j/l 10s · f fullscreen · ,/. speed

Chapters

Transcript
Linux was built from the start for many people to share one machine safely. Linux 从一开始就是为"很多人安全地共用一台机器"设计的。
Each person gets an account, and your files are yours: you cannot read or change someone else's account's files unless they allow it. 每个人有一个账号,而你的文件是你的: 除非对方允许,你读不了也改不了别人账号里的文件。
That is what all those permission letters in the last lesson were for. 上一课那些权限字母,就是为这件事而存在的。
Whoami tells you which one you are at the moment. whoami 告诉你此刻你是哪一个。
There is one exception, and it is total. 有一个例外,而且是彻底的例外。
The user called root can do anything: change any file belonging to anyone, install software, create and delete accounts. 那个叫 root 的用户什么都能做: 修改属于任何人的任何文件、安装软件、创建和删除账号。
And the last item on that list is not a joke — one wrong command typed as root can leave the machine unable to start. 而那个清单上的最后一项不是开玩笑—— 以 root 身份敲错一条命令,可以让这台机器起不来。
So you do not work as root. 所以你不以 root 身份工作。
You work as yourself and borrow root's power for one command at a time, which is what sudo does — super user, do this. 你以自己的身份工作,一次借用 root 的权力执行一条命令, 而 sudo 做的就是这件事——super user, do(超级用户,去做)。
It asks for your password, runs that single command with full power, and the moment it finishes you are an ordinary user again. 它问你要密码,用完整权限运行那一条命令, 而它一结束,你就又是一个普通用户了。
Nothing stays elevated. 没有任何东西会一直保持在提权状态。
Which brings the rule this lesson exists for. 这就引出了这一课存在的那条规则。
Installing software or changing a system service genuinely needs root. 安装软件、或者改动某个系统服务,确实需要 root。
Listing a folder, reading a file, anything inside your own home — none of that does not need it. 列出一个文件夹、读一个文件、你自己家目录里的任何事情——都不需要。
If you find yourself typing sudo in front of everything, something else is wrong. 如果你发现自己在什么命令前面都加 sudo,那说明别的地方出了问题。
And before you press Enter on a sudo line, read it twice: that is the one moment nothing will stop you. 而在一条 sudo 命令上按回车之前,读两遍: 那是唯一一个没有任何东西会拦住你的时刻。
Four things to take with you. 带走四点。
One: Linux gives every person their own account. 第一:Linux 给每个人各自的账号。
Two: whoami tells you which one you are. 第二:whoami 告诉你你是哪一个。
Three: root can do anything, which is exactly the danger. 第三:root 什么都能做,而这正是危险所在。
Four: sudo runs one command as root, and then you are you again. 第四:sudo 以 root 身份运行一条命令,之后你又是你自己。
Now type the tasks into the terminal below. 现在把下面那些题目敲进终端里。

Log in or create account

IGCSE, A-Level & AP