First Step into Linux
Note: in each section of the remaining part of PA0, we will describe our specified items firstly and then quote mixed version of original text published by NJU for introduction with some modifications.
TODO
- Read the whole text carefully.
- Try the commands of Linux mentioned.
- Answer all the questions given in the quoting part.
In the last section we have installed the Debian operating system in the VM, after booting the system, you will see the prompt to ask you to log in the system:
Debian GNU/Linux 9 debian tty1
debian login: _
Enter your username and password which is set in the process of installation. Note that when you typing the password, the screen will not display what you've typed so don't worry about it.
As you logged in successfully, you will see the prompt below:
yourname@debian:~$ _
We call this working environment terminal. The prompt is consist of 4 parts, the normal format is:
Username@Hostname:Workingpath$/# (your command)
- Current username: telling you which user the command will be executed as.
- Hostname: the name of the machine which is set in the installation.
- Current working path: telling you the current path and the command you executed will be based on this path. Working path is an important part of your command, please check it before you execute a command.
- Privilege identifier: telling you the command you typed in will be executed as administration privilege (
#
) or normal privilege ($
).
Where
Many of you always use operating system with GUI, such as Windows. The Debian you just installed is without GUI. It is completely with CLI (Command Line Interface). As you logging in the system, you may feel empty, depress, and then panic...
Calm down yourself. Have you wondered if there is something that you can do it in CLI, but can not in GUI? Have no idea? If you are asked to count how many lines of code you have coded during the 程序设计基础 course, what will you do?
If you stick to Visual Studio, you will never understand why vim
is called 编辑器之神. If you stick to Windows, you will never know what is Unix Philosophy. If you stick to GUI, you can only do what it can; but in CLI, it can do what you want. One of the most important spirits of young people like you is to try new things to bade farewell to the past.
GUI wins when you do something requires high definition displaying, such as watching movies. But in our experiments, GUI is unnecessary. Here are two articles discussing the comparisons between GUI and CLI:
Now you can see how much disk space Debian occupies. Type the following command (every command is issued by pressing the Enter
key):
df -h
You can see that Debian is quite "slim".
Why
Installing a Windows operating system usually requires much more disk space as well as memory. Can you figure out why the Debian operating system you installed can be so "slim"?
To shut down the VM, it is recommended to issue command instead of closing the VM window rudely (just like you shut down Windows by the start menu, instead of unplugging the power):
poweroff
However, you will receive an error message:
-bash: poweroff: command not found
This error is due to the property of the poweroff
command - it is a system administration command. Execute this command requires superuser privilege.
{% panel style="success", title="Why executing the 'poweroff' command requires superuser privilege?" %}
Can you provide a scene where bad thing will happen if the poweroff
command does not require superuser privilege?
{% endpanel %}
Therefore, to shut down the VM, you should first switch to the root account:
su
Enter the root password you set during the installation. You will see the prompt changes:
root@hostname:~#
The last character is #
, instead of $
before you executing su
. #
is the indicator of root account. Now execute poweroff
command again, you will find that the command is executed successfully.
{% panel style="danger", title="不要强制关闭虚拟机!!!" %}
你务必通过 poweroff
命令关闭虚拟机, 如果你通过点击窗口右上角的 X
按钮强制关闭虚拟机, 可能会造成虚拟机中文件损坏的现象. 往届有若干学长因此而影响了实验进度, 甚至由于损坏了实验相关的文件而影响了分数, 请大家引以为鉴, 不要贪图方便, 否则后果自负!
{% endpanel %}
That's everything in PA0.2.