'change permissions on a not writable

UPDATE:

I moved my question to ask ubuntu community, but can not delete it from here... if you have an awenser, please share it on ubuntu community not here... Thanks


i want to make an change on a file but i cant do that because i have not correct permissions:

➜  ls -l pycharm64.vmoptions 
-rw-r--r-- 1 root root 427 Dec 28 18:33 pycharm64.vmoptions

i tried to change permisions by these two command:

sudo chmod a+w pycharm64.vmoptions

and

sudo chown user:user pycharm64.vmoptions

but in i get an erro both time:

Read-only file system

how can i make an change on my file? (honestly i dont care about the owner and groups of the file... i just want to change my file anyway)

P.S: my OS is UBUNTU



Solution 1:[1]

You can change a file on read only by setting the "immutable property"

chattr +i [fileName]

If you want to revert it just change the "+" for a "-"

chattr -i [fileName]

Solution 2:[2]

Your filesystem could be mounted as read only. You have to change first before you can write anything to it. Changing file permissions also requires writing on the filesystem.

You may be able to mount it as read write with command like:

sudo mount -o remount,rw /dev/foo /mount/destination/dir

In this command you spesify that you want to remount the filesystem with different options, adding the readwrite, rw capability.

If you successd in changing the filesystem to read write, then you should be able to change to file permissions with the commands you tried earlier.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matteo Violetto
Solution 2 StefanR