[Linux] Solve the problem that Vim cannot insert text and Putty connection fails in Ubuntu 16.04

1. Environment introduction

    Software and version number:

    VMware Workstation 14.1.1 build-7528167

    Ubuntu 16.04

    About how to install, I will not go into details here. For details, please refer to the Ubuntu 16.04 installation tutorial . This article mainly gives some solutions to the problems encountered in the process of using Ubuntu 16.04. (ps: don’t spray, $ means the prompt of ordinary users, # means the prompt of root user)

2. Unable to switch root user

    Description of the problem: The password verification fails when the Ubuntu system switches to the root user.

$ su root
Password:
su: Authentication failure

    This is an old-fashioned question, because the root user in the Ubuntu system is not activated by default. Here is how to activate the root user. First, enter sudo passwd root, and then enter the new root user password according to the prompt. After confirming the root user password again, it will prompt that the password has been successfully updated.

$ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
    Note: When performing the above operations, make sure that the current user is the system user instead of the guest user, otherwise the sudo passwd command will be invalid. (ps: Use the following two commands to view the current login user information)
$ whoami
$ who am i

    To switch users in su mode, you need to enter the password of the target user, while to switch users in sudo mode, you need to enter the password of the current user.

3. Vim text editor cannot insert text

    Problem description: After pressing i, the INSERT prompt is not displayed, and the input is extremely inconvenient.

    This is because vim-tiny is installed by default in Ubuntu 16.04 (ps: can be viewed through vim --version), which is a reduced version of vim, we need to install the full version of vim in Ubuntu 16.04.

    In fact, installing the full version of vim is very simple, just execute the following command,

$ sudo apt-get install vim

    However, the following error messages may appear, such as:
E: Unable to obtain lock /var/lib/dpkg/lock - open (11: The resource is temporarily unavailable)
E: Unable to lock the management directory (/var/lib/dpkg/), whether Is there another process using it?

    Two solutions are given below: 

a. To list the processes, use the following command,

$ ps -aux

If there are many processes, you can also use the following command to search for processes,

$ ps -aux | grep-apt

After finding the process containing apt-get, use the following command to kill the process (ps:PID refers to the process number, after the process is found, replace the PID).

$ sudo kill PID

b. Force unlock

$ sudo rm /var/cache/apt/archives/lock
$ sudo rm /var/lib/dpkg/lock

After completing a or b, just execute the following command again and wait for the installation to complete.

$ sudo apt-get install vim

4. Putty 0.67.0.0 fails to connect to Ubuntu 16.04

    Problem description: Putty fails to connect to Ubuntu using the SSH remote protocol.

    First, we confirm whether SSH is installed on the Ubuntu system (usually, it is installed by default in Ubuntu), which can be checked by the command:

$ dpkg -l | grep ssh

    It can be found that only openssh-client is installed in the system, but openssh-server is not installed . This means that SSH is not fully installed, and openssh-client and openssh-server need to be reinstalled .


    Here use the following command to install:

$ sudo apt-get install openssh-client
$ sudo apt-get install openssh-server

    However, the installation may be interrupted. Enter the following commands according to the prompt information:

$ sudo dpkg --configure -a

    Then follow the prompts and enter the following command to install:

$ sudo apt-get -f install
$ sudo apt-get install ssh

    After the installation is complete, enter the following command again to view the installation of SSH

$ dpkg -l | grep ssh

It can be found that openssh-client and openssh-server     are installed on the system .


    Finally, start the SSH service and execute the following commands:

$ sudo /etc/init.d/ssh start

    The system shows: [ ok ] Starting ssh (via systemctl): ssh.service.

    This means that the SSH service has been started , and you can use putty to log in to the Ubuntu system.

    If you want to stop the SSH service, you can execute the following command:

$ sudo /etc/init.d/ssh stop

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325465944&siteId=291194637