banner



How To Change Read Only File In Linux

Download Article

Download Article

If you lot want to delete a file that has read-only permissions in Linux, you have a few options. If the file belongs to you lot, you can either change the file's permissions or use the sudo control to delete the file equally root. But if you're trying to delete a file that has write permissions and nevertheless can't delete it (or you see a "Read Merely File Organization" error), you may demand to remount the bulldoze with proper permissions. We'll show you how to remove any read-only file on any Linux distribution, including Ubuntu and Linux Mint.

  1. ane

    Open up a last window. If a file you lot own is read-only, yous won't exist able to delete it unless you lot requite yourself write permission for that file. If you're using a window manager, press Ctrl + Alt + T to open a concluding window now.

    • Use this method if you're trying to delete a file that belongs to you lot but (e.g., you're the possessor or in a group that has access to read the file) but don't have permission to delete it.
    • If you're signed in remotely and already at a control prompt, just skip to the next stride.
  2. 2

    Apply cd to enter the directory of the file you desire to delete. For example, if the file you want to delete is inside a folder chosen documents in your home directory, you'd use cd documents or cd /home/username/documents.

    Advertisement

  3. 3

    Use ls -al to display the file permissions for the files in the directory. Using ls -fifty displays a list of files in the directory, along with the possessor of each file and its permissions. Adding the a to ls -l also shows hidden files and folders in the directory.

  4. iv

    Evaluate the permissions of the file you want to delete. The permissions for a file appear before its name like this: r--r--r--. The owner's name appears afterward it, followed by the group name.

    • r is read permissions, w is write permissions, and x is execute permissions.
    • The get-go three characters in the permissions (in this instance, r--), are the file possessor'south permissions. So, in this example, the owner of the file but has read permissions, which means they can't write to, execute, or delete the file.
    • The second 3 characters are group permissions. If you're a member of a group and that grouping has write permissions to the file, you'll be able to delete it even if you're not the owner.
    • The third three characters are world permissions, which is everyone else.
  5. 5

    Use chmod -five u+rw filename to give yourself read and write permissions. You can omit the r if you already have read permissions. Once you have write permissions, y'all'll be able to delete the file.

    • If you're not the file owner but have root admission to the system, you can utilize sudo chmod -v u+rw filename to give yourself the right permissions.
    • To run across the file's new permissions, run ls -al again.
  6. 6

    Apply rm filename to delete the file. Now that you have write permissions on the file, deleting information technology will be unproblematic.

    • If you lot aren't able to delete the file later on making information technology writable, its partition may be mounted read-only. Come across Fixing the Read But File System Error to troubleshoot.

    Advertisement

  1. 1

    Open a concluding window. You tin can use the sudo command to delete a read-simply file that you aren't able to delete with your user account. If you're using a window manager, printing Ctrl + Alt + T to open up a terminal window now.

    • Use this method if y'all are not the owner of the file y'all want to delete and you'd rather just delete the file instead of beginning changing its permissions.
    • If y'all're signed in remotely and already at a control prompt, merely skip to the side by side stride.
  2. ii

    Apply cd to enter the directory of the file you want to delete. For instance, if the file you want to delete a file inside a binder called documents in your home directory, you lot'd employ cd documents or cd /home/username/documents.

  3. three

    Use ls -al to view the contents of the directory. This command will display all of the files in the electric current directory, as well as each file's owner and permissions.

  4. 4

    Apply sudo rm filename to delete the file. Yous'll exist prompted to enter your password to obtain root-level permissions. One time your password is accepted, the read-simply file will be deleted.

    • If you aren't able to delete the file with sudo, its partition may be mounted read-but. Meet Fixing the Read Just File Organisation Error to troubleshoot.

    Advertisement

  1. one

    Open a last window. If you're trying to delete a file and getting an error that says rm: cannot remove '(filename)' : Read only file arrangement, there are a few possible causes. Start past pressing Ctrl + Alt + T to open up a last window if you're using a window managing director.

    • If you're signed in remotely, just move to the next step.
  2. 2

    Run df -h to view all mounted devices. You lot'll demand to know the exact mount point of the drive that's giving you trouble. This displays all mounted drives.

  3. three

    Run the command mountain . Replace mountain bespeak with the actual mount betoken, e.g., /media/usbdisk. If you're trying to delete a file on a removable disk or network bulldoze, such every bit an old backup, the disk where the file is stored might be mounted as read-simply.

    • If you see ro in the results, the file system is read-only. Remounting the drive should fix the fault. To exercise so, employ mount -o remount,rw mount betoken . You can and then delete the file.
    • If the permissions are rw, the disk is mounted with read-write permissions, which ways yous should exist able to delete files without issues. This ordinarily means at that place's a problem with the file system on the drive. Go on with this method.
    • If you see remount-ro, this ways the there's a trouble with the file system and the drive was remounted equally read-but to limit additional damage. This besides means at that place'southward a problem with the file organization on the bulldoze. Continue with this method.
  4. 4

    If the permissions are correct, unmount the bulldoze. To do this, run sudo umount device . Replace device with the device name, e.m., /dev/sdd1.

    • Since you can't unmount a root file organisation, you can't bank check the file system of the root partition unless you're booted into recovery mode. If the error is on the root file arrangement, kick into recovery mode first.
  5. 5

    Run sudo fsck -north device to check the drive. This checks the integrity of the drive without making any changes. If the bulldoze is okay, you'll run into "clean" in the results. If there are errors, you lot will see them.

    • If there are errors, back up the bulldoze before you continue in case the file system cannot be repaired.
  6. 6

    Run sudo fsck device to repair errors. If there are errors, you'll be prompted to correct them.

    • Even if you are able to correct errors, make a backup just in case the drive is dying.
  7. 7

    Remount the bulldoze once repaired. If you were able to repair the errors, remounting the bulldoze will make it so y'all can delete your files. Utilise mount -o remount,rw mount bespeak to ensure the drive is remounted with read and write permissions. You should and then exist able to change and delete files on the bulldoze.

    Advertisement

Ask a Question

200 characters left

Include your electronic mail address to get a message when this question is answered.

Submit

Advertisement

About This Article

Article Summary Ten

ane. Employ cd to enter the directory that contains the file.
2. Apply ls -al to view file owners and permission attributes.
iii. Use chmod -five u+rw filename to give yourself read and write permissions.
4. Use rm to delete the file.

Did this summary aid y'all?

Thanks to all authors for creating a page that has been read 13,608 times.

Is this commodity up to appointment?

Source: https://www.wikihow.com/Delete-Read-Only-Files-in-Linux

Posted by: millercallynnusers.blogspot.com

0 Response to "How To Change Read Only File In Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel