Cannot Remove Directory As Root User

Issue:

Cannot remove directory as root user.

Troubleshooting:

https://bbs.archlinux.org/viewtopic.php?id=170208


Terminal Output:

[[email protected] tmp]$ pwd
/var/tmp
[[email protected] tmp]$ ls -l
total 0
drwxrwxrwx 1 jedi jedi 0 Dec 19 16:00 pamac
drwxr-xr-x 1 jedi jedi 0 Dec 19 15:59 pamac-build-jedi
drwx------ 1 root root 6 Dec 28 00:53 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-colord.service-TdjbZd
drwx------ 1 root root 6 Dec 28 00:52 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-ModemManager.service-hfoVEu
drwx------ 1 root root 6 Dec 28 00:52 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-power-profiles-daemon.service-N2FMt2
drwx------ 1 root root 6 Dec 28 00:52 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-systemd-logind.service-EFl7Qa
drwx------ 1 root root 6 Dec 28 00:52 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-systemd-oomd.service-Hy23ht
drwx------ 1 root root 6 Dec 28 00:52 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-systemd-timesyncd.service-LyB1BM
drwx------ 1 root root 6 Dec 28 00:55 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-unbound.service-LqRZFE
drwx------ 1 root root 6 Dec 28 00:53 systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-upower.service-uMoAAm
[[email protected] tmp]$ rm -rv pamac/ pamac-build-jedi/ 
rm: cannot remove 'pamac/': Operation not permitted
rm: cannot remove 'pamac-build-jedi/': Operation not permitted
[[email protected] tmp]$ sudo rm -rv pamac/ pamac-build-jedi/
rm: cannot remove 'pamac/': Operation not permitted
rm: cannot remove 'pamac-build-jedi/': Operation not permitted
[[email protected] tmp]$ sudo rm -rf pamac/ pamac-build-jedi/
rm: cannot remove 'pamac/': Operation not permitted
rm: cannot remove 'pamac-build-jedi/': Operation not permitted
[[email protected] tmp]$ lsattr pamac
[[email protected] tmp]$ lsattr pamac-build-jedi/
[[email protected] tmp]$

System Info:

System:
  Kernel: 6.1.1-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=f8b64331-9f73-4b5e-8666-683f1b7a55e6 rw [email protected]
    nvidia-drm.modeset=1
    cryptdevice=UUID=2e774d55-b39d-4dc3-ab93-dd9d934dd845:luks-2e774d55-b39d-4dc3-ab93-dd9d934dd845
    root=/dev/mapper/luks-2e774d55-b39d-4dc3-ab93-dd9d934dd845 quiet splash
    nosgx rd.udev.log_priority=3 vt.global_cursor_default=0
    resume=/dev/mapper/luks-452ae4ef-dbd7-40fd-8185-ce7166dceb2c loglevel=3
    ibt=off
  Desktop: KDE Plasma v: 5.26.4 tk: Qt v: 5.15.7 wm: kwin_wayland vt: 2 dm:
    1: GDM v: 43.0 note: stopped 2: LightDM v: 1.32.0 note: stopped 3: SDDM
    Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Laptop System: Micro-Star product: GP63 Leopard 8RD v: REV:1.0
    serial: <superuser required> Chassis: type: 10 serial: <superuser required>
  Mobo: Micro-Star model: MS-16P6 v: REV:1.0 serial: <superuser required>
    UEFI: American Megatrends v: E16P6IMS.109 date: 05/22/2019
Battery:
  ID-1: BAT1 charge: 38.5 Wh (92.5%) condition: 41.6/53.4 Wh (77.8%)
    volts: 11.8 min: 10.9 model: MSI Corp. MS-16P6 type: Li-ion serial: N/A
    status: not charging
  Device-1: hidpp_battery_0 model: Logitech Wireless Touch Keyboard K400
    serial: <filter> charge: 55% (should be ignored) rechargeable: yes
    status: discharging
CPU:
  Info: model: Intel Core i7-8750H bits: 64 type: MT MCP arch: Coffee Lake
    gen: core 8 level: v3 note: check built: 2018 process: Intel 14nm family: 6
    model-id: 0x9E (158) stepping: 0xA (10) microcode: 0xF0
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 1.5 MiB desc: 6x256 KiB
    L3: 9 MiB desc: 1x9 MiB
  Speed (MHz): avg: 2358 high: 4100 min/max: 800/4100 scaling:
    driver: intel_pstate governor: powersave cores: 1: 2200 2: 2200 3: 2200
    4: 2200 5: 2200 6: 2200 7: 2200 8: 2200 9: 2200 10: 2200 11: 4100 12: 2200
    bogomips: 52799
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT
    vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: retbleed mitigation: IBRS
  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: IBRS, IBPB: conditional, RSB filling,
    PBRSB-eIBRS: Not affected
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] vendor: Micro-Star MSI
    driver: i915 v: kernel arch: Gen-9.5 process: Intel 14nm built: 2016-20
    ports: active: HDMI-A-2 off: eDP-1 empty: DP-1,HDMI-A-1 bus-ID: 00:02.0
    chip-ID: 8086:3e9b class-ID: 0300
  Device-2: NVIDIA GP107M [GeForce GTX 1050 Ti Mobile]
    vendor: Micro-Star MSI driver: nvidia v: 525.60.11
    alternate: nouveau,nvidia_drm non-free: 525.xx+
    status: current (as of 2022-12) arch: Pascal code: GP10x
    process: TSMC 16nm built: 2016-21 pcie: gen: 1 speed: 2.5 GT/s lanes: 16
    link-max: gen: 3 speed: 8 GT/s bus-ID: 01:00.0 chip-ID: 10de:1c8c
    class-ID: 0302
  Device-3: Acer HD Webcam type: USB driver: uvcvideo bus-ID: 1-13:7
    chip-ID: 5986:211b class-ID: 0e02
  Display: wayland server: X.org v: 1.21.1.6 with: Xwayland v: 22.1.7
    compositor: kwin_wayland driver: X: loaded: modesetting,nvidia dri: iris
    gpu: i915,nvidia display-ID: 0
  Monitor-1: HDMI-A-2 res: 1360x768 size: N/A modes: N/A
  API: OpenGL v: 4.6 Mesa 22.3.1 renderer: Mesa Intel UHD Graphics 630 (CFL
    GT2) direct render: Yes
Audio:
  Device-1: Intel Cannon Lake PCH cAVS vendor: Micro-Star MSI
    driver: snd_hda_intel v: kernel alternate: snd_soc_skl,snd_sof_pci_intel_cnl
    bus-ID: 00:1f.3 chip-ID: 8086:a348 class-ID: 0403
  Sound API: ALSA v: k6.1.1-zen1-1-zen running: yes
  Sound Interface: sndio v: N/A running: no
  Sound Server-1: PulseAudio v: 16.1 running: no
  Sound Server-2: PipeWire v: 0.3.63 running: yes
Network:
  Device-1: Intel Cannon Lake PCH CNVi WiFi driver: iwlwifi v: kernel
    bus-ID: 00:14.3 chip-ID: 8086:a370 class-ID: 0280
  IF: wlan0 state: down mac: <filter>
  Device-2: Qualcomm Atheros Killer E2400 Gigabit Ethernet
    vendor: Micro-Star MSI driver: alx v: kernel pcie: gen: 1 speed: 2.5 GT/s
    lanes: 1 port: 3000 bus-ID: 03:00.0 chip-ID: 1969:e0a1 class-ID: 0200
  IF: enp3s0 state: up speed: 100 Mbps duplex: full mac: <filter>
Bluetooth:
  Device-1: Intel Bluetooth 9460/9560 Jefferson Peak (JfP) type: USB
    driver: btusb v: 0.8 bus-ID: 1-14:8 chip-ID: 8087:0aaa class-ID: e001
  Report: bt-adapter note: tool can't run ID: hci0 rfk-id: 0 state: down
    bt-service: disabled rfk-block: hardware: no software: no address: N/A
Drives:
  Local Storage: total: 1.84 TiB used: 828.52 GiB (43.9%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung model: SSD 970 EVO 1TB
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
    lanes: 4 type: SSD serial: <filter> rev: 2B2QEXE7 temp: 40.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 model: SATA SSD size: 953.87 GiB block-size:
    physical: 512 B logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter>
    rev: 61.3 temp: 33 C scheme: MBR
Partition:
  ID-1: / raw-size: 914.2 GiB size: 914.2 GiB (100.00%)
    used: 400.75 GiB (43.8%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-2e774d55-b39d-4dc3-ab93-dd9d934dd845
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 752 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 914.2 GiB size: 914.2 GiB (100.00%)
    used: 400.75 GiB (43.8%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-2e774d55-b39d-4dc3-ab93-dd9d934dd845
  ID-4: /var/log raw-size: 914.2 GiB size: 914.2 GiB (100.00%)
    used: 400.75 GiB (43.8%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-2e774d55-b39d-4dc3-ab93-dd9d934dd845
  ID-5: /var/tmp raw-size: 914.2 GiB size: 914.2 GiB (100.00%)
    used: 400.75 GiB (43.8%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-2e774d55-b39d-4dc3-ab93-dd9d934dd845
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 15.47 GiB used: 0 KiB (0.0%) priority: 100
    dev: /dev/zram0
  ID-2: swap-2 type: partition size: 17.01 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/dm-1 maj-min: 254:1
    mapped: luks-452ae4ef-dbd7-40fd-8185-ce7166dceb2c
Sensors:
  System Temperatures: cpu: 50.0 C pch: 63.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 358 Uptime: 14h 21m wakeups: 27 Memory: 15.47 GiB
  used: 4.42 GiB (28.6%) Init: systemd v: 252 default: graphical
  tool: systemctl Compilers: gcc: 12.2.0 clang: 14.0.6 Packages: pm: pacman
  pkgs: 2386 libs: 570 tools: cylon,gnome-software,paru,trizen,yay pm: flatpak
  pkgs: 0 Shell: Bash v: 5.1.16 running-in: gnome-terminal inxi: 3.3.24
Garuda (2.6.12-1):
  System install date:     2022-12-17
  Last full system update: 2022-12-28 ↻
  Is partially upgraded:   No
  Relevant software:       NetworkManager
  Windows dual boot:       No/Undetected
  Snapshots:               Snapper
  Failed units:  
  1. Reboot

Use sudo.

I tried that. Same issue.

Do those directories contain anything not owned by jedi? Files in the /tmp directory often have the sticky bit applied and cannot be manipulated except by the file owner.

Elevating with sudo might not be enough; try switching to the root user with su or sudo su, then try rm -rf again.

2 Likes

My friend, you might want to check that the 'immutable' flag is not set in the extended filesystem attributes.

Bust a 'sudo -s' to get a root shell, then do a 'lsattr [filepath and filename]' on it. If you see an 'i', do a chattr -i [filepath and filename]'.

F.

4 Likes
[[email protected] ~]$ cd /var/tmp/ ; ls -l
total 0
drwxrwxrwx 1 jedi jedi 0 Dec 19 16:00 pamac
drwxr-xr-x 1 jedi jedi 0 Dec 19 15:59 pamac-build-jedi
[[email protected] tmp]$ sudo su
[[email protected] tmp]# whoami
root
[[email protected] tmp]# rm -rf pamac
rm: cannot remove 'pamac': Operation not permitted
[[email protected] tmp]# lsattr pamac
[[email protected] tmp]# cd pamac
[[email protected] pamac]# ls -l
total 0
[[email protected] pamac]# 

This is crazy. Pamac has lost its mind. I might have to give it the old nuke and pave treatment. I even removed Pamac and still it lives. Or maybe I can just ignore it since there is no data in the folders.

I think you might be on to something, this could be caused by Pamac weirdness. Check out this thread on the Manjaro forum: Cp: cannot create regular file '/var/tmp/pamac/dbs/sync/community.db': Permission denied - #4 by BlackBaroness - Support - Manjaro Linux Forum

Obviously a different issue than yours, but similar in that the files in /var/tmp/pamac cannot be properly modified or deleted. It appears to be a mixture of Pamac trying to sync stuff, and general bugginess.

There are quite a few issues on the Pamac GitLab page that mention similar permission-related weirdness in /var/tmp/pamac as well: 1283, 1250, 1306.

2 Likes

Thank you for sharing this. Very helpful. I'm glad this is not just a me issue. It seems that those bug reports are still unresolved and are pointing fingers and closing with no resolutions. I see why Garuda does not ship this OOTB. Not a major issue but very concerning that not even the root user can remove these directories.

tl;dr: Don't use Manjaro tools.

4 Likes
Oh I'm so dumb.

pamac  pamac-build-jedi  systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-unbound.service-iW9Ik6
[[email protected] tmp]$ pwd
/var/tmp
[[email protected] tmp]$ sudo lsattr
----i----------------- ./pamac
----i----------------- ./pamac-build-jedi
---------------------- ./systemd-private-e15286b0b13545f9a08aba7fcf9f02bb-unbound.service-iW9Ik6
[[email protected] tmp]$ sudo chattr -i pamac pamac-build-jedi/
[[email protected] tmp]$ sudo rm -rv pamac pamac-build-jedi/
removed directory 'pamac'
removed directory 'pamac-build-jedi/'
[[email protected] tmp]$

Hmm, I thought you already tried that?

I wonder why you didn't get output the first few times you tried it. :thinking:

Anyway, I'm glad the nightmare is over. If nothing else, perhaps a cautionary tale to other users:

:no_entry_sign: Stay away from Pamac :no_entry_sign:

:rofl:

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.