Skip to content

Creating and removing

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

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

Chapters

Transcript
Two commands make things. 有两条命令负责"造东西"。
M k d i r makes a directory — a folder. mkdir 造一个目录——也就是文件夹。
Touch makes a file. touch 造一个文件。
And note what kind of file: touch makes it empty, zero bytes, but it exists and has a name, so you can write into it afterwards. 注意造出来的是什么样的文件:touch 造出的是空的,零字节, 但它存在、有名字,所以你之后可以往里写东西。
Notice the second line too: notes slash todo dot txt puts the new file inside the folder you just made. 也注意第二行:notes/todo.txt 把这个新文件放进了你刚造的那个文件夹里。
C p copies and m v moves, and the difference is what is left behind. cp 是复制,mv 是移动,而区别在于"留下了什么"。
After a copy there are two files: the original and the new one. 复制之后有两个文件:原来的那个和新的那个。
After a move there is only one copy — the original name is gone, and the file is at its new place. 移动之后只有一份——原来的名字没了,文件在它的新位置上。
The greyed line here is not there any more. 这里那一行灰掉的,已经不在了。
Now something that is not guessable, so learn it as a fact: there is no rename command on Linux. 现在说一件猜不到的事,所以就当作一个事实记住: Linux 上没有"重命名"这条命令。
You do not need one. 你也不需要一条。
Moving a file to a new name in the same folder is a rename — m v todo dot txt done dot txt, and the file has a new name. 把一个文件移动到同一个文件夹里的一个新名字,就是重命名—— mv todo.txt done.txt,这个文件就换了名字。
Same command, same idea, and one fewer thing to remember. 同一条命令,同一个道理,要记的东西还少了一样。
And the dangerous one. 然后是危险的那一条。
R m removes a file, at once. rm 移除一个文件,立刻。
R m dash r removes a folder and everything inside it, however deep. rm -r 移除一个文件夹以及它里面的一切,不管有多深。
Here is the part to take seriously: there is no recycle bin on the command line, no undo, and no confirmation. 下面这部分要认真对待: 命令行上没有回收站,没有撤销,也没有确认。
The file is gone the instant you press Enter. 在你按下回车的那一瞬间,文件就没了。
The protection is a habit, not a flag. 保护你的是一个习惯,不是某个选项。
Before you delete a folder, list it and read what is actually in there. 在删掉一个文件夹之前,先列一下它,看清楚里面到底有什么。
Then remove it. 然后再删。
Ten seconds, and it is the difference between deleting a scratch folder and deleting your coursework. 十秒钟的事,而它就是"删掉一个草稿文件夹"和"删掉你的作业"之间的区别。
And if you only mean to remove an empty folder, r m d i r does exactly that and refuses if it is not already empty. 而如果你只打算删一个空文件夹,rmdir 正好只做这件事, 如果它不是空的,rmdir 会拒绝。
Four things to take with you. 带走四点。
One: m k d i r makes a folder and touch makes an empty file. 第一:mkdir 造文件夹,touch 造一个空文件。
Two: c p leaves two copies and mv leaves one. 第二:cp 留下两份,mv 只留一份。
Three: moving a file to a new name is how you rename. 第三:把文件移动到一个新名字,就是重命名的做法。
Four: r m is permanent — there is no recycle bin. 第四:rm 是永久的——没有回收站。
Now type the tasks into the terminal below. 现在把下面那些题目敲进终端里。

Log in or create account

IGCSE, A-Level & AP