Installing Basic Tools

What you should do in this section
  1. Read the whole text carefully.
  2. Try the commands of Linux mentioned.
  3. Install all basic tools mentioned.
  4. Learn to use Vim as the text editor.
  5. Answer all the questions given in the quoting part.

After installing the Debian, we call only use several simple tools provided by the operating system, we cannot even edit a text file easily (maybe you can try vi?) so we should install some basic tools which is useful and tiny.

Preparation

Run the VM you created already, login as normally privileged account (which is pinyin of your name) then follow the instructions below:

Now you are going to install some tools from the Debian image for convinence. First "insert" the Debian image: Click Devices in the menu bar in the VM window, navigate to Optical Drives, click Choose disk image, then select the Debian image file. Then add the sources in the image to the APT's list by the following command:

apt-cdrom add

You will see the following prompt:

Please insert a Disc in the drive and press enter

Since you have already "inserted the Disc" just now, press the Enter key, and you will see some message is output. Read them, you will find an error labeled with "Permission denied". Switch to the root account and execute the above command again, you will find that the command is executed without errors. Now you can install the following tools.

Installing Tools from Debian Image

The image just provide us with some limited but essential stuffs, we will install them first and install more tools in the next section.

sudo

apt install sudo

sudo allows you to execute a command as another user (usually root). This means you do not need to switch to the root account to execute a system administration command or modify a file owned by root. But before you can use sudo, you should add your user account to the sudo group:

addgroup jack sudo

Replace "jack" above with your username. To let the above command go into effect, you should login the system again.

However, you will receive an error message:

-bash: addgroup: command not found

This error is due to the property of the su command - it can only switch your identity to root without the environment variables. So you should type:

su -

To switch to the root account completely. And then add your user account to the sudo group:

addgroup jack sudo

Type

exit

to go back to your user account. And exit again to logout, then login again. Now you can use sudo. If you find an operation requires root permission, append sudo before that operation. For example,

username@hostname:~$ sudo poweroff

Note that running sudo may require password. This password is your user account password, not the root one.

Why use 'sudo' instead of 'su'?

You may consider sudo unnecessary, because you can always perform all operations with the root account. But this may take your system at risk. Can you figure out why?

In fact, all operations related to system changing require root permission. If a malicious program obtains root permission, it can do very bad things, such as deleting system files, to destory your system! Therefore, if an operation can be performed without root permission, perform it without root permission.

vim

sudo apt install vim

vim is called 编辑器之神. You will use vim for coding in all PAs and Labs, as well as editing other files. Maybe some of you prefer to other editors requiring GUI environment (such Visual Studio). However, you can not use them in some situations, especially when you are accessing a physically remote server:

  • the remote server does not have GUI installed, or
  • the network condition is so bad that you can not use any GUI tools.

In these situations, vim is still a good choice. If you prefer to emacs, you can download and install emacsfrom network mirrors after the APT sources file is configured. We will lead you to configure vim later.

ssh

sudo apt install openssh-server

ssh is a tool for remote accessing. Using ssh in the experiment can take some advantage of the host system. For ssh configuration, we will explain it alter.

Learning Vim

You are going to be asked to modify a file using vim. For most of you, this is the first time to use vim. The operations in vim are quite different from other editors you have ever used. To learn vim, you need a tutorial. There are two ways to get tutorials:

  • Issue the vimtutor command in terminal. This will launch a tutorial for vim. This way is recommended, since you can read the tutorial and practice at the same time.

  • Search the Internet with keyword "vim 教程", and you will find a lot of tutorials about vim. Choose some of them to read, meanwhile you can practice with the a temporary file by

    vim test
    

PRACTICE IS VERY IMPORTANT. You can not learn anything by only reading the tutorials.

Some games operated with vim

Here are some games to help you master some basic operations in vim. Have fun!

Remove the Debian image as soon as you finished all items above to prevent entering installation when you boot the VM next time.


That's everything in PA0.3.

results matching ""

    No results matching ""