Please do not cargo-cult stuff you found on the Internet, but try to understand what a command does before your enter it.
Your use of
sudo is unnecessary -- you are already logged in as the root user, and have full access.
The error message you were given indicates that the automatic file system check failed. With ext2, that happened often after a power outage, but with ext3 and ext4, one of which you are likely to be using if your system is newer than ten years, this generally does not happen unless there is faulty hardware involved.
The first command,
mount -o rw,remount / essentially tells the system "It is fine, there are no errors on this disk, and you can assume the file system to be consistent enough to write files." This is a bold statement, especially right after you received an error message stating that a file system check found problems that are so bad that the automated repairs would probably have to delete files in order to get the file system back into working shape.
The second command,
dpkg --configure -a then attempted to run the post-installation scripts for packages that are marked in the dpkg database as having their files unpacked, but the scripts not run yet. If this command attempted to do anything, this means that you will need to do that later on, but now is not the proper time. The dpkg tool exists all file systems to be mounted and error-free, you only have a root file system with errors, and all others are missing.
The way to resolve your situation is:
Go back to read-only mode using
mount -o ro,remount /. You do not want the kernel to change anything in the file system while the repair is under way.
Repair the root file system, using the fsck utility, which will then use the fsck.ext3 utility internally:
fsck -f /.
You can add the option
-C0 to get a progress indicator.
If you get messages about fsck being unable to read blocks because of I/O errors, you can interrupt with Ctrl-C and add the
-c option to scan for bad blocks beforehand. This will take ages, but the repair operation then does not attempt to rescue any files spread over defective sectors.
Most likely you will be asked if you agree to certain problems being fixed. Look up the error messages using your search engine of choice, there is ample documentation on the Internet. Most of these are about deleting files that are beyond repair, or moving them to the
After that is complete, you will most likely be asked to reboot, in capital letters. This is a good idea, just enter
sync first, give the disks a few seconds to write out the remaining data and then press Ctrl-Alt-Del. The reboot will be immediate, without unmounting file systems, but that is fine because the only file system mounted is read-only.
If after the reboot you are dropped back into the same prompt, another file system but the root file system is in need of repairs as well. Use the
fsck -A command to attempt an automated repair of all non-root file systems, and manually repair those that need it. This time around, you should not be asked to reboot, as this is only needed for file systems that are mounted while being checked.