Installing Tools

In GNU/Linux, you can download and install a software by one command (which may be difficult to do in Windows). This is achieved by the package manager. Different GNU/Linux distribution has different package manager. In Ubuntu, the package manager is called apt.

You will download and install some tools needed for the PAs from the network mirrors. Before using the network mirrors, you should check whether the system can access the Internet.

Checking network state

Inside NJU, you should easily obtain an IPv6 address. To test this, try to ping a mirror host with IPv6 support:

ping mirrors.tuna.tsinghua.edu.cn -c 4

You should receive reply packets successfully:

PING mirrors.tuna.tsinghua.edu.cn(2402:f000:1:408:8100::1 (2402:f000:1:408:8100::1)) 56 bytes of data.
64 bytes from 2402:f000:1:408:8100::1 (2402:f000:1:408:8100::1): icmp_seq=1 ttl=54 time=1.56 ms
64 bytes from 2402:f000:1:408:8100::1 (2402:f000:1:408:8100::1): icmp_seq=2 ttl=54 time=1.07 ms
64 bytes from 2402:f000:1:408:8100::1 (2402:f000:1:408:8100::1): icmp_seq=3 ttl=54 time=1.07 ms
64 bytes from 2402:f000:1:408:8100::1 (2402:f000:1:408:8100::1): icmp_seq=4 ttl=54 time=1.24 ms

--- mirrors.tuna.tsinghua.edu.cn ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 1.071/1.237/1.563/0.203 ms

If you do not have an IPv6 address, you may access the Internet by IPv4 address. You can try to ping a host outside the university LAN:

ping www.baidu.com -c 4

If you can ping Baidu successfully, you should successfully ping the mirror host above, too.

Setting APT source file

如果你的系统不是Ubuntu 22.04, 请更换合适的源

使用与系统不相符的源会导致工具包版本冲突, 强行安装将会损坏系统. 如果你使用的系统不是Ubuntu 22.04, 请勿使用以下的源, 你需要自行搜索合适的源并更换.

Run the following commands to update the APT source file:

bash -c 'echo "deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list'

However, you will receive an error message:

bash: /etc/apt/sources.list: Permission denied

This is because the APT source file is owned by root, and you do not have the permission to modify it.

One solution is first switching to the root account. But to avoid switching, an alternative way is to use sudo. If you find an operation requires superuser permission, append sudo before that operation. Before using sudo, you should add your account to the sudo group. But first, you still need to switch to the root account.

su -
Password:

Enter the root password you set during the installation. Note that the password is not shown in the terminal to avoid password leaks. If the password is correct, you will see the prompt changes:

root@hostname:/home/username#

The last character is #, instead of $ before you executing su -. # is the indicator of root account. Now you can add your account to the sudo group.

adduser username sudo  # Change `username` to your user name
exit

To let the changes to take effect, you should log out or reboot. After that, try

whoami
sudo whoami

If it is the first time you run sudo, enter the password of your account. You should find that sudo whoami will output root.

Now you can use sudo to modify the APT source file. This time you should modify it successfully. To check this, you can output the file:

cat /etc/apt/sources.list

You should see it really outputs the line you just echoed.

Updating APT package information

Now you can tell apt to retrieve software information from the sources:

apt-get update

However, you will receive an error message:

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/

This is because apt-get requires superuser privilege to run. Run the command with superuser privilege. Since it requires Internet accessing, it may cost some time to finish.

Unmet dependencies问题

如果在运行apt-get update时报告Unmet dependencies的问题, 可尝试将上述阿里源更换成清华源:

bash -c 'echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list'

然后重新执行apt-get update.

若问题仍然出现, 可尝试搜索互联网并更换其他源.

Installing tools for PAs

The following tools are necessary for PAs:

apt-get install build-essential    # build-essential packages, include binary utilities, gcc, make, and so on
apt-get install man                # on-line reference manual
apt-get install gcc-doc            # on-line reference manual for gcc
apt-get install gdb                # GNU debugger
apt-get install git                # revision control system
apt-get install libreadline-dev    # a library used later
apt-get install libsdl2-dev        # a library used later
apt-get install llvm llvm-dev      # llvm project, which contains libraries used later
apt-get install llvm-11 llvm-11-dev # only for ubuntu20.04

The usage of these tools is explained later.

Installing Chinese input method

Search the Internet for how to install a Chinese input method in Ubuntu.

results matching ""

    No results matching ""