ubuntu system encountered a problem

Newly installed ubuntu system does not have built-in ssh service
when using sudo apt-get install to install, the following case

E: Could not Lock GET / var / lib / dpkg / Lock - Open (11: Resource temporarily. It is unavailable Sign of the)
E: Unable to lock the administration directory (/ var / lib / dpkg /), is another process using it?

cause of the problem: mainly because of apt is still running, or another program.

Solution: Kill all apt processes and delete all locked files.
1: Find all related processes apt, and with orders to kill.


root@root-Lenovo-G405:~$ ps afx|grep apt
 3284 pts/0    S+     0:00          \_ grep --color=auto apt
 2869 ?        Ss     0:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
 2873 ?        S      0:00  \_ /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install

root@root-Lenovo-G405:~$ sudo kill -9 2873
root@root-Lenovo-G405:~$ sudo kill -9 2869


2: delete locked file
locked file blocks access to certain files or data Linux system, this concept also exists in Windows or other operating systems.
Once you run the command apt-get or apt, locked files will be created in / var / lib / apt / lists /, / var / lib / dpkg /, / var / cache / apt / archives / in.
This helps run the apt-get or apt process can be avoided by other users or system processes need to use the same files interrupted. When this process is finished, the lock file will be deleted.

    Therefore:

      1: lock file is removed in the corresponding directory:

      2: Force reconfiguration packages:

      3: Source file update package:

1.root@root-Lenovo-G405: ~ $ the sudo RM / var / lib / dpkg / Lock
2.root@root-Lenovo-G405: ~ $ sudo dpkg --configure -a
3.root@root-Lenovo-G405: ~ $ sudo APT Update
    
after performing the first two commands, I found that there is again installed another document is also still locked, so continue to delete, but then I can not delete finished, regardless of the implementation of the second order, exception details as follows:
     dpkg Status Database IS locked by another Process

sudo RM / var / lib / dpkg / Lock

sudo dpkg --configure -a

But after deleting all the files again, still can not be configured, so I direct restart, you can use them later.


  3: problem solving, execution apt install command is successful.

 

安装ssh
apt-get install openssh-server

Ssh After installation is complete, using the root login found not
to modify the configuration file
vi / etc / ssh / sshd_config
description of
# the Authentication:
LoginGraceTime 120
the PermitRootLogin the prohibit-password
StrictModes Yes

modified
# the Authentication:
#LoginGraceTime 2M
#PermitRootLogin the prohibit-password
the PermitRootLogin Yes
StrictModes Yes
restart the service
service sshd restart

 

Guess you like

Origin www.cnblogs.com/bruze/p/11329704.html