How to change rpm lock

**Getting below error when i try to install some rpm files in opensuse leap 15:

RPM failed: error: can’t create transaction lock on /var/lib/rpm/.rpm.lock (Read-only file system)

and /var/lib/rpm/.rpm.lock has below file permission:
-rw-r–r-- 1 root root 0 Nov 29 16:58 /var/lib/rpm/.rpm.lock

**
Tried many ways to change lock through command line and getting below error:
error: can’t create transaction lock on /usr/lib/sysimage/rpm/.rpm.lock (Read-only file system)

Please help in removing the lock manually or through command line

Hello,

Welcome to the openSUSE forums.

Let me please first give you important information on how to post computer commands with their ouput:
There is an important, but not easy to find feature on the forums.

Please in the future use CODE tags around copied/pasted computer text in a post. It is the # button in the tool bar of the post editor. When applicable copy/paste complete, that is including the prompt, the command, the output and the next prompt.

In your case that would look something like

henk@boven:~> ls -l /var/lib/rpm/.rpm.lock
-rw-r--r-- 1 root root 0  6 nov  2013 /var/lib/rpm/.rpm.lock
henk@boven:~>

That said, please note that the error messages say: (Read-only file system).
Thus they do not talk about the file permissions, but about the file system where the file is on.
You have to try to find out on which file system the file is on (posibly /var) and then to check if that file system is indeed mounted read-only. I think the command

mount | grep '/var'

will help here.

i have the same error.

i tried the command
mount | grep '/var'
it shows :

/dev/nvme0n1p2 on /var type btrfs (rw,relatime,ssd,space_cache,subvolid=257,subvol=/@/var)
/var/lib/snapd/snaps/pycharm-community_323.snap on /snap/pycharm-community/323 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
/var/lib/snapd/snaps/snapd_18933.snap on /snap/snapd/18933 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
/var/lib/snapd/snaps/snapd_18596.snap on /snap/snapd/18596 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
/var/lib/snapd/snaps/core18_2714.snap on /snap/core18/2714 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
/var/lib/snapd/snaps/pycharm-community_327.snap on /snap/pycharm-community/327 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
/var/lib/snapd/snaps/core18_2721.snap on /snap/core18/2721 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
/dev/nvme0n1p2 on /var/lib/docker/btrfs type btrfs (rw,relatime,ssd,space_cache,subvolid=257,subvol=/@/var)

i have found that the system use /var folder as rw only so can i change it rwx?
because i need to change the permission of /var/lib/rpm/.rpm.lock from : “-rw-r–r–” to------> " -rwxrwxrwx"

Please, this is a very old story which in itself lacks a lot of information. When you want to draw the attention of people then start a new thread with a good title.

Also please note that telling stories like “I have the same error” is technically useless. People here like to see the complete command and output (about as you did for he mount | grep, but then without the interruptions like “it shows:”). Best is also to include the prompts before and after. Example:

henk@boven:~> uname -r
5.14.21-150400.24.60-default
henk@boven:~> 

The same for whatever command created the error you do not show but point to.