Trouble updating the system [ Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get) ]  [Solved]

Help for Current Versions of MX
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
GenesisHyperstrike
Posts: 14
Joined: Fri Oct 20, 2023 10:54 am

Trouble updating the system [ Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get) ]

#1 Post by GenesisHyperstrike »

Hello.

Just now I was trying to update system, but I got the error mentioned in the title. Then I tried to update system via terminal, and the following was the result :

E: Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get)
W: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/lib/apt/lists/



I think this issue came up after I changed the mirror, as the error before changing the mirror was saying that the mirror does not have release file.





On the first look, to me it seems that some process is going on and waiting might be the solution, but still I don't know what had triggered this issue.



Code: Select all

System:
  Kernel: 6.1.0-13-amd64 [6.1.55-1] arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.1.0-13-amd64 root=UUID=<filter> ro quiet splash
  Desktop: KDE Plasma v: 5.27.5 wm: kwin_x11 vt: 7 dm: SDDM Distro: MX-23.1_KDE_x64 Libretto
    October 15 2023 base: Debian GNU/Linux 12 (bookworm)
Machine:
  Type: Desktop System: LENOVO product: Lenovo H320 10044 v: Lenovo serial: <superuser required>
  Mobo: LENOVO model: N/A v: INVALID serial: <superuser required> BIOS: LENOVO v: D6KT11A
    date: 05/20/2010
CPU:
  Info: model: Intel Core i3 540 bits: 64 type: MT MCP arch: Westmere gen: core 1 level: v2
    built: 2010-11 process: Intel 32nm family: 6 model-id: 0x25 (37) stepping: 2 microcode: 0x11
  Topology: cpus: 1x cores: 2 tpc: 2 threads: 4 smt: enabled cache: L1: 128 KiB
    desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB L3: 4 MiB desc: 1x4 MiB
  Speed (MHz): avg: 1373 high: 1463 min/max: 1200/3067 scaling: driver: acpi-cpufreq
    governor: ondemand cores: 1: 1200 2: 1367 3: 1463 4: 1463 bogomips: 24471
  Flags: ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: gather_data_sampling status: Not affected
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds status: Vulnerable: Clear CPU buffers attempted, no microcode; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data status: Unknown: No mitigations
  Type: retbleed status: Not affected
  Type: spec_rstack_overflow status: Not affected
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW, STIBP: conditional, RSB
    filling, PBRSB-eIBRS: Not affected
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel Core Processor Integrated Graphics vendor: Lenovo driver: i915 v: kernel
    arch: Gen-5.75 process: Intel 45nm built: 2010 ports: active: VGA-1 empty: DP-1,HDMI-A-1
    bus-ID: 00:02.0 chip-ID: 8086:0042 class-ID: 0300
  Device-2: Logitech Webcam C270 type: USB driver: snd-usb-audio,uvcvideo bus-ID: 1-1.4:4
    chip-ID: 046d:0825 class-ID: 0102 serial: <filter>
  Display: x11 server: X.Org v: 1.21.1.7 with: Xwayland v: 22.1.9 compositor: kwin_x11 driver: X:
    loaded: intel dri: crocus gpu: i915 display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.21x7.99") s-diag: 414mm (16.31")
  Monitor-1: VGA-1 mapped: VGA1 model: Lenovo D185wA serial: <filter> built: 2010 res: 1366x768
    hz: 60 dpi: 84 gamma: 1.2 size: 413x234mm (16.26x9.21") diag: 475mm (18.7") ratio: 16:9 modes:
    max: 1366x768 min: 720x400
  API: OpenGL v: 2.1 Mesa 23.1.2-1~mx23ahs renderer: Mesa Intel HD Graphics (ILK)
    direct-render: Yes
Audio:
  Device-1: Intel 5 Series/3400 Series High Definition Audio vendor: Lenovo 5 driver: snd_hda_intel
    v: kernel bus-ID: 1-1.4:4 bus-ID: 00:1b.0 chip-ID: 046d:0825 class-ID: 0102 chip-ID: 8086:3b56
    serial: <filter> class-ID: 0403
  Device-2: Logitech Webcam C270 type: USB driver: snd-usb-audio,uvcvideo
  API: ALSA v: k6.1.0-13-amd64 status: kernel-api tools: alsamixer,amixer
  Server-1: PipeWire v: 0.3.65 status: active with: 1: pipewire-pulse status: active
    2: wireplumber status: active 3: pipewire-alsa type: plugin 4: pw-jack type: plugin
    tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Intel 82578DC Gigabit Network vendor: Lenovo driver: e1000e v: kernel port: e880
    bus-ID: 00:19.0 chip-ID: 8086:10f0 class-ID: 0200
  IF: eth0 state: down mac: <filter>
  IF-ID-1: usb0 state: unknown speed: -1 duplex: half mac: <filter>
Bluetooth:
  Device-1: Samsung Galaxy series misc. (tethering mode) type: USB driver: rndis_host v: kernel
    bus-ID: 2-1.2:7 chip-ID: 04e8:6863 class-ID: 0a00 serial: <filter>
Drives:
  Local Storage: total: 584.77 GiB used: 12.56 GiB (2.1%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/sda maj-min: 8:0 vendor: Western Digital model: WD5000AZRX-00L4HB0 size: 465.76 GiB
    block-size: physical: 4096 B logical: 512 B speed: 3.0 Gb/s type: HDD rpm: 5400 serial: <filter>
    rev: 1A01 scheme: MBR
  ID-2: /dev/sdb maj-min: 8:16 vendor: OSC model: SSD 120GB size: 111.79 GiB block-size:
    physical: 512 B logical: 512 B speed: 3.0 Gb/s type: SSD serial: <filter> rev: 0A0 scheme: MBR
  ID-3: /dev/sdc maj-min: 8:32 type: USB vendor: Sony model: Storage Media size: 7.22 GiB
    block-size: physical: 512 B logical: 512 B type: N/A serial: <filter> rev: PMAP scheme: MBR
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
Partition:
  ID-1: / raw-size: 111.79 GiB size: 109.47 GiB (97.93%) used: 12.56 GiB (11.5%) fs: ext4
    dev: /dev/sdb1 maj-min: 8:17
Swap:
  Kernel: swappiness: 15 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: file size: 2 GiB used: 505.2 MiB (24.7%) priority: -2 file: /swap/swap
Sensors:
  System Temperatures: cpu: 31.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Repos:
  Packages: pm: dpkg pkgs: 2422 libs: 1331 tools: apt,apt-get,aptitude,nala pm: rpm pkgs: 0
    pm: flatpak pkgs: 0
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/debian-stable-updates.list
    1: deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/debian.list
    1: deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
    2: deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/mx.list
    1: deb https://quantum-mirror.hu/mirrors/pub/mx-linux/packages/mx/repo/ bookworm main non-free
    2: deb https://quantum-mirror.hu/mirrors/pub/mx-linux/packages/mx/repo/ bookworm ahs
Info:
  Processes: 211 Uptime: 25m wakeups: 1 Memory: 2.65 GiB used: 1.9 GiB (71.8%) Init: SysVinit
  v: 3.06 runlevel: 5 default: graphical tool: systemctl Compilers: gcc: 12 Client: shell wrapper
  v: 5.2.15-release inxi: 3.3.26
Boot Mode: BIOS (legacy, CSM, MBR)

User avatar
CharlesV
Global Moderator
Posts: 7652
Joined: Sun Jul 07, 2019 5:11 pm

Re: Trouble updating the system [ Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get) ]  [Solved]

#2 Post by CharlesV »

A number of programs may hold a lock like this, typically MX Installer or any application touching the update (mx updater) and then apt-get.

Try closing all open apps and try again, and if it continues then reboot.
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

User avatar
DukeComposed
Posts: 1454
Joined: Thu Mar 16, 2023 1:57 pm

Re: Trouble updating the system [ Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get) ]

#3 Post by DukeComposed »

GenesisHyperstrike wrote: Wed Oct 25, 2023 9:34 pm Just now I was trying to update system, but I got the error mentioned in the title. Then I tried to update system via terminal, and the following was the result :

E: Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get)
W: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/lib/apt/lists/

On the first look, to me it seems that some process is going on and waiting might be the solution, but still I don't know what had triggered this issue.
You can figure out which process has the lock file open with lsof.

Code: Select all

sudo lsof +d '/var/lib/apt/lists/'
should do it. It's likely to be an apt-get or dpkg process, or something that invoked those programs. You can close the program if it's still open, kill it with "kill -TERM 1234", where you replace 1234 with the process ID of the program that is holding the lock, or, if all else fails, restart the machine as CharlesV suggests.

GenesisHyperstrike
Posts: 14
Joined: Fri Oct 20, 2023 10:54 am

Re: Trouble updating the system [ Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get) ]

#4 Post by GenesisHyperstrike »

CharlesV wrote: Wed Oct 25, 2023 9:49 pm A number of programs may hold a lock like this, typically MX Installer or any application touching the update (mx updater) and then apt-get.

Try closing all open apps and try again, and if it continues then reboot.
Thanks for the quick info. It means that some process might be going under the hood. But why did this provoked when I changed the mirror via MX Repo Manager ?


And slightly off-topic, both the mirrors for India are outdated, as the last activity there was long time ago, therefore one is needed to select the different mirror.
But since mirror is not updated, then why those mirrors are getting selected ?








And thank you @DukeComposed for that quick command. I will take a note of it.

User avatar
CharlesV
Global Moderator
Posts: 7652
Joined: Sun Jul 07, 2019 5:11 pm

Re: Trouble updating the system [ Could not get lock /var/lib/apt/lists/lock. It is held by process 6445 (apt-get) ]

#5 Post by CharlesV »

They are probably selected by location - your choice at install.
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

Post Reply

Return to “MX Help”