I dont know if it is a problem with grep or the kernel, but if i run “grep -r test” on / with the root-account my system crashes. I dont think this is wanted behavior, because i juat want to search the whole system for a string.
I use:
System:
Kernel: 5.15.7-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0
parameters: BOOT_IMAGE=/boot/vmlinuz-5.15-x86_64
root=UUID=54231697-5e51-4616-a830-8707a2d002fa rw quiet
resume=UUID=5ca77906-d9d7-47a9-a28d-7ae0d804c2a1 udev.log_priority=3
Desktop: KDE Plasma 5.23.4 tk: Qt 5.15.2 wm: kwin_x11 vt: 1 dm: SDDM
Distro: Manjaro Linux base: Arch Linux
Can you give some more info on your crash? Does it just hang, or crash to a black screen etc.
also can you please advise your system specs?
the output from inxi --full --filter --width --no-host
would be great
1 Like
I would give the link below a go. Apparently grep will search device files too if you search from / which could definitely cause it to hang up.
https://stackoverflow.com/questions/7971089/why-does-grep-hang-when-run-against-the-directory
Command below should work:
grep -Dr test
@akin2silver it does just hang, no black screen, but nothing moves. And there was some kind of graphical glitch, just mixed pixels on a part of the display.
Here is the output of the inxi command:
System:
Kernel: 5.15.7-1-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.23.4
Distro: Manjaro Linux
Machine:
Type: Laptop System: Micro-Star product: Alpha 15 A3DDK v: REV:1.0
serial: <superuser required>
Mobo: Micro-Star model: MS-16U6 v: REV:1.0 serial: <superuser required>
UEFI: American Megatrends v: E16U6AMS.112 date: 07/23/2020
Battery:
ID-1: BAT1 charge: 40.0 Wh (100.0%) condition: 40.0/53.4 Wh (74.9%)
CPU:
Info: quad core model: AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx
bits: 64 type: MT MCP cache: L2: 2 MiB
Speed (MHz): avg: 1234 min/max: 1400/2300 cores: 1: 1176 2: 1185 3: 1361
4: 1269 5: 1222 6: 1221 7: 1221 8: 1218
Graphics:
Device-1: AMD Navi 14 [Radeon RX 5500/5500M / Pro 5500M] driver: amdgpu
v: kernel
Device-2: AMD Picasso driver: amdgpu v: kernel
Device-3: Chicony HD Webcam type: USB driver: uvcvideo
Display: x11 server: X.org 1.21.1.2 driver: loaded: amdgpu,ati
unloaded: modesetting,radeon resolution: <missing: xdpyinfo>
Message: Unable to show advanced data. Required tool glxinfo missing.
Audio:
Device-1: AMD Navi 10 HDMI Audio driver: snd_hda_intel
Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor
driver: snd_pci_acp3x
Device-3: AMD Family 17h HD Audio driver: snd_hda_intel
Sound Server-1: ALSA v: k5.15.7-1-MANJARO running: yes
Sound Server-2: PulseAudio v: 15.0 running: yes
Network:
Device-1: Realtek RTL8822CE 802.11ac PCIe Wireless Network Adapter
driver: rtw_8822ce
IF: wlo1 state: up mac: <filter>
Device-2: Realtek driver: r8169
IF: enp6s0 state: down mac: <filter>
Bluetooth:
Device-1: IMC Networks Bluetooth Radio type: USB driver: btusb
Report: rfkill ID: hci0 state: up address: see --recommends
Drives:
Local Storage: total: 1.38 TiB used: 7.49 GiB (0.5%)
ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLQ512HALU-00000
size: 476.94 GiB
ID-2: /dev/sda vendor: SanDisk model: SSD PLUS 1000GB size: 931.52 GiB
Partition:
ID-1: / size: 906.86 GiB used: 7.49 GiB (0.8%) fs: ext4 dev: /dev/sda2
ID-2: /boot/efi size: 299.4 MiB used: 292 KiB (0.1%) fs: vfat
dev: /dev/sda1
Swap:
ID-1: swap-1 type: partition size: 8.8 GiB used: 0 KiB (0.0%) dev: /dev/sda3
Sensors:
System Temperatures: cpu: 77.0 C mobo: N/A
Fan Speeds (RPM): N/A
GPU: device: amdgpu temp: 49.0 C fan: 65535 device: amdgpu temp: 74.0 C
Info:
Processes: 253 Uptime: 2h 40m Memory: 13.64 GiB used: 2.72 GiB (19.9%)
Shell: Bash inxi: 3.3.11
@Sierrafox i tried the same on Kubuntu 21.10 and grep does not finish, maybe because it reads /dev/zero, but a system-crash does not happen, but i will try your suggested command and use it from now on its more secure that way (i think)
@Sierrafox okay it did not work for me.
I run
grep -D skip -r test
in / and this time i got a black screen. Something in the system just crashed
Can you try using the same kernel as Kubuntu temporarily? Also, I would compare the grep version to the Kubuntu version. Maybe try downgrading to whatever version of grep Kubuntu is using to troubleshoot. Do you think maybe your hard drive or ram is failing? Have you tested this same command on Kubuntu since you experienced the crash on Manjaro?
Just tossing what I can think of out there. Good luck!
I made some tests:
Grep has the same version, but i think ubuntu lightly modified it, because in the package-manager it has “-0ubuntu1” behind the version and the sha is not the same.
The kernel is different, but the version of the kubuntu-kernel is not available in the manjaro-gui, so i just took the lts, i mean it should also be stable and the “bug” appeared there as well.
i testet my ram with memtest and there are no problems, the ssd should also be fine
I tested the same command on kubuntu again, but i was sure i already used it without problems, thats also a reason why i wrote this report.
I also copied the grep file from one to another system but couldnt run it, because they use different libraries or expect them to be in another place. So maybe both grep-programms work in different ways. Thats enough for today
There is nothing wrong with grep - whether you run it as root in the root or anywhere else.
cd /
su
grep -r test
An issue could be in the /sys
or /proc
tree as you are trying to read from system processes which may not respond very well to command at hand.
e.g.
grep: proc/sys/vm/numa_zonelist_order: Cannot allocate memory
grep: proc/sys/vm/oom_dump_tasks: Cannot allocate memory
grep: proc/sys/vm/oom_kill_allocating_task: Cannot allocate memory
grep: proc/sys/vm/overcommit_kbytes: Cannot allocate memory
grep: proc/sys/vm/overcommit_memory: Cannot allocate memory
grep: proc/sys/vm/overcommit_ratio: Cannot allocate memory
grep: proc/sys/vm/page-cluster: Cannot allocate memory
grep: proc/sys/vm/page_lock_unfairness: Cannot allocate memory
grep: proc/sys/vm/panic_on_oom: Cannot allocate memory
grep: proc/sys/vm/percpu_pagelist_high_fraction: Cannot allocate memory
grep: proc/sys/vm/stat_interval: Cannot allocate memory
grep: proc/sys/vm/stat_refresh: Cannot allocate memory
grep: proc/sys/vm/swappiness: Cannot allocate memory
grep: proc/sys/vm/unprivileged_userfaultfd: Cannot allocate memory
grep: proc/sys/vm/user_reserve_kbytes: Cannot allocate memory
grep: proc/sys/vm/vfs_cache_pressure: Cannot allocate memory
grep: proc/sys/vm/watermark_boost_factor: Cannot allocate memory
grep: proc/sys/vm/watermark_scale_factor: Cannot allocate memory
grep: proc/sys/vm/zone_reclaim_mode: Cannot allocate memory
proc/kmsg:<6>[ 6.625320] rodata_test: all tests were successful
grep: proc/kmsg: Resource temporarily unavailable
1 Like
i would suggest running grep only on parts of the filesystem where the string may be found. This depends on what you are searching for.
If you search for something
you created as any user or user configuration
in any programm you installed
anywhere in the logs
anywhere in system configuration
your boot files
there are also
/tmp /mnt /media /root /run/media
and if you have a lot of time
/.snapshots /home/.snapshots
But please don’t search in:
/dev /proc /run /sys
it may not end ever, or even crash
Please have a look at: Filesystem, Permissions:
Difficulty: ★★★☆☆
Note: This post is meant as a tutorial. Please do not post on this thread regarding any problems you’re having with permissions, but start a new thread instead. Thank you.
PREAMBLE: THE HISTORICAL BACKGROUND
If you are new to the world of GNU/Linux ─ and especially if you come from the Microsoft Windows ecosystem ─ then you will undoubtedly already have noticed that GNU/Linux handles permissions and storage volumes quite differently from what you might be used to…
But there may be also infos for you in:
https://man.archlinux.org/man/file-hierarchy.7
If you had told us what you are searching for, maybe someone would have been able to help you searching in the right place.
I do think using grep -r in / is bad practice
3 Likes
system
Closed
December 30, 2021, 9:16pm
10
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.