This question is associated with Where is core file with abrt-hook-cpp installed? .
While I was trying to generate a core file for an intentionally-crashing program, at first core file generation seemed to be stymied by abrt-ccpp. So I tried to manually editing /proc/sys/kernel/core_pattern with vim:
> sudo vim /proc/sys/kernel/core_pattern
When I tried to save the file, vim reported this error:
"/proc/sys/kernel/core_pattern" E667: Fsync failed
I thought this was a permission problem, so I tried to change permissions:
> sudo chmod 666 /proc/sys/kernel/core_pattern
chmod: changing permissions of '/proc/sys/kernel/core_pattern\': Operation not permitted
Finally, based on this post, I tried this:
>sudo bash -c 'echo /home/user/foo/core.%e.%p > /proc/sys/kernel/core_pattern'
This worked.
Based on the working solution, I also tried these, which failed:
> echo "/home/user/foo/core.%e.%p" > /proc/sys/kernel/core_pattern
-bash: /proc/sys/kernel/core_pattern: Permission denied
>
> sudo echo "/home/user/foo/core.%e.%p" > /proc/sys/kernel/core_pattern
-bash: /proc/sys/kernel/core_pattern: Permission denied
Question:
Why is it that editing, chmoding, and redirecting echo output to the file /proc/sys/kernel/core_pattern all failed, and only the noted invocation of sudo bash... was able to overwrite/edit the file?
Question:
Specifically, wrt the attempts to invoke sudo in the failed attempts above: why did they fail? I thought sudo executed the subsequent command with root privilege, which I thought let you do anything in Linux.