1

How should i do to undo this? I tried running fsck to solve my "Read only filesystem" before but it didn't help me much. It only solve the situation for a while and then it comes back again. So, i did this after reading a post.

Meanwhile, i am getting thousands of lines like this:

chown: changing group of '/usr/share/doc/distro-info-data': Read-only file system
chown: changing group of '/usr/share/doc/software-properties-common/copyright': Read-only file system
chown: changing group of '/usr/share/doc/software-properties-common/changelog.gz': Read-only file system
chown: changing group of '/usr/share/doc/software-properties-common': Read-only file system
chown: changing group of '/usr/share/doc/nmap/3rd-party-licenses.txt.gz': Read-only file system
chown: changing group of '/usr/share/doc/nmap/leet-nmap-ascii-art.txt': Read-only file system
chown: changing group of '/usr/share/doc/nmap/nmap.usage.txt.gz': Read-only file system
chown: changing group of '/usr/share/doc/nmap/device-types.txt.gz': Read-only file system
chown: changing group of '/usr/share/doc/nmap/committers.txt.gz': Read-only file system
chown: changing group of '/usr/share/doc/nmap/nmap_gpgkeys.txt.gz': Read-only file system
chown: changing group of '/usr/share/doc/nmap/style/lua-format.lua.gz': Read-only file system
chown: changing group of '/usr/share/doc/nmap/style/README': Read-only file system
Pranav
  • 1,200
  • A read-only file system is usually the result of a problem (such as file-system error where a fsck is the fix), so I don't know why you mentioned sudo chown .. as it would create other problems though wouldn't change anything on a read-only file system anyway. Look at your logs to see why the file system was mounted or remounted read-only, and go from there. – guiverc Jul 21 '19 at 09:10
  • But first, what should i do to undo this "sudo chown $pranav.pranav -R /" and then only filesystem error can be process. Because this can create big issues later. @guiverc – Pranav Jul 21 '19 at 09:14
  • 2
    @PrabeshBhattarai as the file system is read only, no changes are made. The fact that you're getting these error messages means that the file system is read only. Press Control-C to abort the running process. – vidarlo Jul 21 '19 at 09:39
  • @vidarlo thanks for that confirmation. Now my pc "seems" to be not in read-only state, can I check that for sure? Some commands to check will be very helpfull. –  Jul 21 '19 at 09:42
  • run mount | grep "/dev/" and check that the filesystems is indeed in ro mode, not rw. – vidarlo Jul 21 '19 at 09:43
  • @vidarlo can u look this screenshot because there are some "rw" in some places: https://imgur.com/n9npUPM – Pranav Jul 21 '19 at 09:56
  • According to that screenshot / is mounted in RW mode. That does not match with your post. Have you rebooted or similar after running the chown command? – vidarlo Jul 21 '19 at 09:59
  • Doesn'ts root partition need rw permission? @vidarlo – Pranav Jul 21 '19 at 10:02
  • For a normally functioning system, yes. But errors will typically lead to it being remounted RO. And your errors above clearly indicate that it was read only when you ran that command. That said; I believe you have a dying harddrive. Get a new one and reinstall. – vidarlo Jul 21 '19 at 10:04
  • @vidarlo this is probably because I did "linux /boot/vmlinuz-5.2-x86_64 root= rw quiet" to get this functioning again. As the accept answer says. – Pranav Jul 21 '19 at 10:13
  • If it's after reboot, then the screenshot doesn't say anything about the status when you ran the command. If your system works normally, I'd ignore what you attempted, given the error messages you got. – vidarlo Jul 21 '19 at 10:26

2 Answers2

0

In case it's your main filesystem ran as part of the kernel parameter using grub you should change the command line from (example):

linux   /boot/vmlinuz-5.2-x86_64 root=<uuid> ro  quiet

To:

linux   /boot/vmlinuz-5.2-x86_64 root=<uuid> rw  quiet

And reboot.

If this partition is being mounted after reboot or it's not the root partition you can remount it with rw, like this:

sudo mount -o remount,rw /dev/sdX

Replace sdX with the appropriate partition that matches your case.

Yaron
  • 544
  • 1
    your answer worked but I will probably run into this problem in the future again. If there is a permanent solution, I would be a big help. –  Jul 21 '19 at 09:44
  • 1
    If your system is frequently going read-only, then you should do additional investigation to find out why. Ubuntu is not designed to run on dying or faulty hardware, and cannot fix those for you. – user535733 Jul 21 '19 at 11:19
  • Change /etc/fstab to mount it the way you want it. – Yaron Jul 21 '19 at 12:44
  • In over 35 years of using Unix systems, it has never happened to me that a system filesystem changed by itself to r/o. You need to not issue commands in sudo without first understanding exactly what they will do and why you need to do what you are doing. It only takes one simple command as root to destroy a system - don't take such commands lightly. – jpezz Jul 21 '19 at 14:44
  • @Yaron 1 last question before i execute this if this repeat again in future, the command u said, "sudo mount -o remount,rw /dev/sdX" , the sdX should be a home or root partition? – Pranav Jul 22 '19 at 05:02
  • @PrabeshBhattarai it doesn't matter, it should work for both. – Yaron Jul 22 '19 at 07:21
0

The easiest way to solve this? The hard way: reinstall your system. All of it.

The root / should be owned by # root, not by a user (pranav). Your command meant changing all the files in your system to the group pranav. This is messy.

Don't worry, I did things worse than this (e.g. dd on my system's drive). But it's a good way to learn things the Linux way. :-)

Majal
  • 7,711
  • 3
    Since it was a read-only file system, the OP's unwise command did nothing. Had this been a writable file system, the OP's unwise command would have wrought tremendous damage, and this would be the best answer. – user535733 Jul 21 '19 at 11:15