Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How To Gain Access To Locked Files & Folders?

  1. #1
    Join Date
    Mar 2011
    Location
    BD
    Beans
    125
    Distro
    Ubuntu 12.04 Precise Pangolin

    How To Gain Access To Locked Files & Folders?

    i recently used an app called photorec to recover files from a deleted partitioned pen drive. the files were restored randomly (couldent get what i wanted, back :'( ) and now i cant delete those files from the home folder. a lock icon appears over the folder icon. btw i am able to read the files but not write it...

    how can i gain access to these files?

  2. #2
    Join Date
    Mar 2011
    Beans
    370

    Re: How To Gain Access To Locked Files & Folders?

    run the following to change the ownership of the files to your user
    Code:
    sudo chown -R $USER: /path/to/folder/
    and change the read only permissions to read+write;
    Code:
    chmod -R u+wr  /path/to/folder/
    edit: do not run it directly on your home folder (which seem to be the recovery directory here!), as it may cause some problems as described in the next post.
    Last edited by ~Plue; April 24th, 2011 at 04:04 PM.

  3. #3
    Join Date
    Mar 2010
    Beans
    Hidden!

    Re: How To Gain Access To Locked Files & Folders?

    Quote Originally Posted by rez182 View Post
    i recently used an app called photorec to recover files from a deleted partitioned pen drive. the files were restored randomly (couldent get what i wanted, back :'( ) and now i cant delete those files from the home folder. a lock icon appears over the folder icon. btw i am able to read the files but not write it...

    how can i gain access to these files?
    The command photorec needs sudo before it if I recall correctly and though the files are saved to your home folder they will be owned by root. I would normally suggest a root browser but the files will remain in root's trash taking up disk space. So I will suggest a terminal method instead.

    Firstly open a terminal, and type in "sudo rm" (without the quotes) and press the spacebar ONCE.

    Now in your home folder highlight all the files you need to remove (hold down the CTRL key while clicking the files to make a multiple selection). When you have selected all you need, drag the multiple selection into the terminal. Then hit enter. You will have to enter your user password but note it won't show as you do so (a security feature of Ubuntu). Press enter again.

    All the root owned files should then dissapear (deleted).

    Edit: I should note the "sudo rm" command can be danderous if you select and delete the wrong file/s, TAKE CARE WITH IT. You don't get second chances to recover a file if you make a mistake. It is permanent.

    If you don't feel comfortable with using it, use ~Plue's method to change ownership of the files to yourself, then delete them as usual.

    @ Plue, your second command may change the permissions on the file .ICEauthority from 600 to 644 if that command is run directly on the home folder which may not be a good thing, Please check again as hidden files and folders are in the home folder and may be affected adversly.
    Last edited by yetiman64; April 24th, 2011 at 03:56 PM. Reason: Added a warning about the command given

  4. #4
    Join Date
    Mar 2011
    Location
    BD
    Beans
    125
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How To Gain Access To Locked Files & Folders?

    @yetiman64, thanks for making it so easy, but it didnt work, it says:
    rm: cannot remove `/home/rez/recup_dir.1': Is a directory
    rm: cannot remove `/home/rez/recup_dir.2': Is a directory
    rm: cannot remove `/home/rez/recup_dir.3': Is a directory
    rm: cannot remove `/home/rez/recup_dir.4': Is a directory
    rm: cannot remove `/home/rez/recup_dir.5': Is a directory
    @~Plue, can i use the click and drag for your solution?
    EDIT: Drag n' Drop**

  5. #5
    Join Date
    Mar 2010
    Beans
    Hidden!

    Re: How To Gain Access To Locked Files & Folders?

    Quote Originally Posted by rez182 View Post
    @yetiman64, thanks for making it so easy, but it didnt work, it says:
    @~Plue, can i use the click and drag for your solution?
    EDIT: Drag n' Drop**
    Change the command to "sudo rm -r " and highlight and drag the folders in to the terminal. I assumed you were deleting files from your first post not directories. Use the same method though and be very careful.
    Last edited by yetiman64; April 24th, 2011 at 04:10 PM. Reason: removed the -f switch as not necessary

  6. #6
    Join Date
    Mar 2011
    Beans
    370

    Re: How To Gain Access To Locked Files & Folders?

    Quote Originally Posted by rez182 View Post
    @~Plue, can i use the click and drag for your solution?
    EDIT: Drag n' Drop**
    you could, but its not a good idea to use the second one it as i didn't take into account that the home folder could be the recovery directory. some files there need to retain their permissions. and since you've already deleted the files, it would be a lot simpler to use yetiman's method instead
    Last edited by ~Plue; April 24th, 2011 at 04:16 PM.

  7. #7
    Join Date
    Feb 2010
    Location
    Washington, DC Area
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How To Gain Access To Locked Files & Folders?

    If you have the files in Trash already, try this command to empty the trash bin.
    Code:
    sudo rm -rf /home/yourusername/.local/share/Trash/*
    If you have them some where else, try.
    Code:
    gksu nautilus /path/to/directory
    Put in your password, and nautilus will open, so that you can delete those files in the directory that you specified. Then close nautilus. WARNING! Be care of what you delete as the administrator in nautilus
    Last edited by dcsoldschool53; April 24th, 2011 at 05:13 PM. Reason: adding more info

  8. #8
    Join Date
    Mar 2011
    Location
    BD
    Beans
    125
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How To Gain Access To Locked Files & Folders?

    @~Plue, im sorry im a little confused now, i still didnt delete anything, so should i be worried using drag and drop method, even if i do it carefully making sure i dont delete anything else but those folders?

    EDIT: what method should i use to permanently delete those folders from my home folder? (so many options)
    Last edited by rez182; April 24th, 2011 at 04:23 PM.

  9. #9
    Join Date
    Mar 2010
    Beans
    Hidden!

    Re: How To Gain Access To Locked Files & Folders?

    Quote Originally Posted by dcsoldschool53 View Post
    If you have the files in Trash already, try this command to empty the trash bin.
    Code:
    sudo rm -rf ‘/home/username/.local/share/Trash
    If you have them some where else, try.
    Code:
    gksu nautilus /path/to/directory
    delete those files in the directory that you specified. Then close nautilus. WARNING! Be care of what you delete as the administrator in nautilus

    @ dcsoldschool53, your first command will remove the trash directory itself not just the contents and you don't need sudo to delete files or folders in a users home directory plus the -f or force switch is totally unnecessary. Please reconsider it.

    OP if you follow my first post but change the command to "sudo rm -r" (recursive switch for directories) those folders and their contents will be removed.
    Last edited by yetiman64; April 24th, 2011 at 04:24 PM. Reason: more info

  10. #10
    Join Date
    Mar 2011
    Location
    BD
    Beans
    125
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How To Gain Access To Locked Files & Folders?

    thanks alot yetiman and plue, it worked

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •