sudo vi fails with "Permission denied" after hardening RHEL
1
vote
3
answers
276
views
I recently hardened my RHEL system, and after that,
sudo vi
stopped working. When I try to run:
sudo vi test.sh
I get the following error:
/bin/vi: line 23: /usr/libexec/vi: Permission denied
/bin/vi: line 23: /usr/libexec/vi: Success
### **What I Have Checked So Far**
1. **vi Works Without sudo**
- Running vi test.sh
as a normal user works.
- Only sudo vi test.sh
fails.
2. **Checked File Permissions**
- /usr/libexec/vi has the following permissions:
rwxr-xr-x 1 root root 1452384 Aug 5 2024 /usr/libexec/vi
- /bin/vi is:
rwxr-xr-x 1 root root 691 Aug 5 2024 /bin/vi
3. **SELinux Check**
- Running setenforce 0
and then sudo vi test.sh
still fails.
- restorecon -Rv /usr/bin/sudo /bin/vi /usr/libexec/vi
did not help.
### **Question**
Why does sudo vi
fail with "Permission denied" while vi
works normally?
How can I restore sudo vi
to work correctly?
Asked by RPE
(11 rep)
Feb 20, 2025, 09:01 AM
Last activity: Feb 27, 2025, 07:06 AM
Last activity: Feb 27, 2025, 07:06 AM