rpm error - Can not run any package - linux

I try to install some package using yum, but there is a big problem, I don't know how to solve it. Please help me, thank so much!^^
This is yum error:
[root#localhost rpm]# yum
rpmdb: /var/lib/rpm/__db.001: Input/output error
error: db3 error(5) from dbenv->open: Input/output error
error: cannot open Packages index using db3 - Input/output error (5)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:
Error: rpmdb open failed
[root#localhost rpm]#
after that, I try to re-build rpmdb but:
[root#localhost rpm]# rm -rf /var/lib/rpm/__db.00*
rm: cannot remove `/var/lib/rpm/__db.001': Input/output error
rm: cannot remove `/var/lib/rpm/__db.002': Input/output error
rm: cannot remove `/var/lib/rpm/__db.003': Input/output error
rm: cannot remove `/var/lib/rpm/__db.004': Input/output error
[root#localhost rpm]#
And this is list file and permission:
[root#localhost rpm]# ls -l
ls: cannot access __db.001: Input/output error
ls: cannot access __db.004: Input/output error
ls: cannot access __db.002: Input/output error
ls: cannot access __db.003: Input/output error
total 52456
-rw-r--r-- 1 root root 2887680 May 26 2016 Basenames
-rw-r--r-- 1 root root 12288 May 26 2016 Conflictname
-????????? ? ? ? ? ? __db.001
-????????? ? ? ? ? ? __db.002
-????????? ? ? ? ? ? __db.003
-????????? ? ? ? ? ? __db.004
-rw-r--r-- 1 root root 1368064 May 26 2016 Dirnames
-rw-r--r-- 1 root root 5251072 May 26 2016 Filedigests
-rw-r--r-- 1 root root 16384 May 26 2016 Group
...
[root#localhost rpm]#

Related

Renaming messages but it shows "Operation not permitted" on linux system

I'm using Centos 8.0 and my kernel version:
4.18.0-147.5.1.x86_64
Backgroud:
The messages on my host not rotated for a long time,and when I use "logrotate -v -f" to force rotating messages, it shows "rename messages: Operation not permitted".So I try renaming the messages immediately.
-rw------- 1 root 15464299992 Jul 15 10:12 messages
-rw------- 1 root 11644353 Sep 7 2020 messages-20200907.gz
-rw------- 1 root 8834073 Sep 13 2020 messages-20200913.gz
renaming /var/log/messages to /var/log/messages-20210715
error: failed to rename /var/log/messages to /var/log/messages-20210715: Operation not permitted
Here is my operation and the terminal's output:
[root#node-5 log]# mv messages messages-20210715
mv: cannot move ‘messages’ to ‘messages-20210715’: Operation not permitted
[root#node-5 ~]# whoami
root
I login as root,why do I still come across such problem? How can I solve this?
#DavidC.Rankin
Thx for replying.Here is the ls -ald . for messages:
[root#node-5 log]# ls -ald
drwxr-xr-x. 30 root 8192 Jul 15 11:14 .
So I don't think this may be a problem about permissions.
I also used strace to follow the syscall:
stat("messages2", 0x7fff6c37aae0) = -1 ENOENT (No such file or directory)
lstat("messages", {st_mode=S_IFREG|0600, st_size=15464637645, ...}) = 0
lstat("messages2", 0x7fff6c37a790) = -1 ENOENT (No such file or directory)
renameat2(AT_FDCWD, "messages", AT_FDCWD, "messages2", 0) = -1 EPERM (Operation not permitted)
Unfortunately,there are too many branches in function do_renameat2 so I haven't found the exact exit yet.
The problem got solved:
Show the file attributes with lsattr, it seems that messages got an attribute 'a',so it can't be renamed.
---------------- ./maillog-20201004
-----a---------- ./messages
And with command chattr -a messages,messages can be renamed again.

How to change permission VM shared folder to 777 (drwxrwxrwx)?

I'm using Oracle Linux 5.7 x86 on Virtual Box 5.1.8 Window 10 x64. I have shared a host folder Temp with VM and can access it and trying to copy its contents to VM but stuck at;
[root#localhost ~]# cd /downloads
[root#localhost downloads]# cp /media/sf_Temp/*.zip
cp: target `/media/sf_Temp/V25347-01.zip' is not a directory
[root#localhost downloads]#
I guess I'll need to change the permissions of shared folder to 777 (drwxrwxrwx) but cannot. Is chmod 777 /media/sf_Temp right command for this?
[root#localhost sf_Temp]# ls -ld /media/sf_Temp
drwxrwx--- 1 root vboxsf 12288 Oct 25 20:46 /media/sf_Temp
[root#localhost sf_Temp]# ls -ld /downloads
drwxrwxrwx 2 root root 4096 Oct 26 19:14 /downloads
[root#localhost sf_Temp]#
You are already root, you don't need any other permissions.
cp command needs two arguments, one for target file/folder, one for destination.
cp origfile newfile
http://www.computerhope.com/unix/ucp.htm

sudo: effective uid is not 0, is sudo installed setuid root? (on mac os x 10.12)

So I'm a bit of a terminal noob so bear with me but I was trying to update brew to install something, so I ran: brew update and got Error: /usr/local must be writable!
Wasn't really sure what that was about so I tried running sudo brew update and got sudo: effective uid is not 0, is sudo installed setuid root?
Not sure if this helps but running ls -l $(which sudo) gave me:
ls: is: No such file or directory
ls: is: No such file or directory
ls: is: No such file or directory
ls: is: No such file or directory
ls: sudo: No such file or directory
ls: sudo: No such file or directory
ls: sudo: No such file or directory
ls: sudo: No such file or directory
-r-s--x--x 1 root wheel 369136 Sep 13 20:56 /usr/bin/sudo
-r-s--x--x 1 my_profile admin 168448 Jan 13 2016 /usr/local/bin/sudo
-r-s--x--x 1 my_profile admin 168448 Jan 13 2016 /usr/local/bin/sudo
-r-s--x--x 1 my_profile admin 168448 Jan 13 2016 /usr/local/bin/sudo
I tried the suggestion here (using Disk Utility and running First Aid) but it didn't seem to have any effect....
Can anyone tell me what's going on and what I need to do?
If you run ls -la /usr, the result most likely will be something like below:
total 0
drwxr-xr-x# 11 root wheel 374 Oct 14 14:35 .
drwxr-xr-x 32 root wheel 1156 Oct 26 09:49 ..
drwxr-xr-x 19 root wheel 646 Oct 10 18:51 local
... (some other files and directories)
Now it's obvious from the above that unless you are logged in as a root or your user is in the wheel group (which is most likely not), any command you issue with your user which needs write permission (such as brew update) will fail.
One of the possible solutions (and I am not claiming is the best one) would be to change permissions of /usr/local.
Like so:
sudo chown -R $(whoami) /usr/local
Interestingly enough, if you then run
brew update
all goes well and you get the following message:
=> Migrating HOMEBREW_REPOSITORY (please wait)...
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
sudo chown root:wheel /usr/local
Which I guess explains what happened in the first place.
Hope that helps.

find all files contains string in linux

How can I find all files contains specific string from root level?
I've looged with root & tried something like:
[root#ip-172-18-7-96 /]# grep -r 'log4j' /
grep: /proc/sys/fs/binfmt_misc/register: Invalid argument
grep: /proc/sys/net/ipv4/route/flush: Permission denied
I get just several permission denied (although I'm root).
As root, you can still chmod a-r file:
$ ls -la /proc/sys/net/ipv4/route/flush
--w------- 1 root root 0 Sep 4 15:59 /proc/sys/net/ipv4/route/flush

/var/run/dbus/system_bus_socket Permission denied

For some time, when trying to run dbus gives me the following error, even if I'm logged in as root:
gentoo herman # /etc/init.d/dbus start
* Starting D-BUS system messagebus ...
Failed to start message bus: Failed to bind socket "/var/run/dbus/system_bus_socket": Permission denied
* start-stop-daemon: failed to start `/usr/bin/dbus-daemon' [ !! ]
* ERROR: dbus failed to start
Listing directory:
gentoo herman # ls /var/run/dbus/ -all
ls: nie ma dostępu do /var/run/dbus/system_bus_socket: Brak dostępu
razem 1
drwxr-xr-x 2 root root 88 08-14 16:42 .
drwxr-xr-x 20 root root 824 08-16 16:45 ..
?????????? ? ? ? ? ? system_bus_socket
I tried to delete this file as root via the rm command, but displays the same error.
I have installed :
[ebuild R ] sys-apps/dbus-1.4.14 USE="X static-libs -debug -doc (-selinux) -test"
[ebuild R ] dev-libs/dbus-glib-0.94-r1 USE="static-libs -bash-completion -debug -doc -test"
uname -a :
Linux gentoo 2.6.38-gentoo #6 SMP Fri Jul 1 09:41:37 CEST 2011 x86_64 Intel(R) Core(TM)2 Duo CPU T9400 # 2.53GHz GenuineIntel GNU/Linux
Command "dmesg | grep dbus" nothing displays. Reinstalling dbus also in no way helped. Thanks for any help
Looks like you have corruption in your /var filesystem. Try fsck-ing the file-system.
Also, for a quick workaround you can rename the directory and create a new one, because you won't be able to delete the offending file.
Do as root:
# mv /var/run/dbus /var/run/dbus-broken
# mkdir /var/run/dbus
And start the daemon as usual.
But don't forget the fsck! If there is one error in the FS there may be others lurking around.

Resources