2

I moved my files from Windows 7 PC to another Ubuntu 16.1 PC over LAN cable.

Now when I try to delete my files in the Ubuntu PC it says access denied?

total 28
-rwxr--r--  1 nobody nogroup  889 Jun 16  2016 Android Book Links.txt
-rwxr--r--  1 nobody nogroup    0 Mar  7  2009 AUTOEXEC.BAT
drwxr-xr-x  2 nobody nogroup 4096 Mar 11 03:22 Book
-rwxr--r--  1 nobody nogroup    0 Mar  7  2009 CONFIG.SYS
drwxr-xr-x  6 nobody nogroup 4096 Mar 11 03:33 Documents and Settings
drwxr-xr-x  2 nobody nogroup 4096 Mar 11 03:33 i386
drwxr-xr-x 13 nobody nogroup 4096 Mar 12 09:59 My Documents
drwxr-xr-x 11 nobody nogroup 4096 Mar 11 23:25 TCWIN45
drwxr-xr-x  3 nobody nogroup 4096 Mar 11 23:25 VALUEADD

  • 2
    Can you open a terminal in the folder with the files and post the result of ls -l? How did you copy the files? They probably have the wrong owner. – Sethos II May 8 '17 at 5:00
  • If you didn't understand @SethosII comment, go to the folder which contains the files you want to delete, right click and select open in terminal option, then type ls -l in terminal and you'll get an output, update your question with that output – Sumeet Deshmukh May 8 '17 at 5:10
  • @Sethos I selected my files from my Windows PC, then I CUT them and open the folder of the Ubuntu PC from the Windows PC using Windows file explorer and paste it into the drive of the Ubuntu PC by the help of LAN cable. It has some kind of Owner issue – Anant_infinity May 8 '17 at 6:44
  • @Anant_infinity yes it can be, update your question with the output of ls -l – Sumeet Deshmukh May 8 '17 at 7:55
  • askubuntu.com/a/175083/665251 you can even see the permission using gui – Sumeet Deshmukh May 8 '17 at 7:56
2

Linux's permissions system is very different from that of Windows. For a crash course, each permission has a few facets assigned to it. Namely, there are three octal bits (u, g, and o) that control who can access the file and to what degree. There is also a concept called a file "owner", which is a pair of a user and a group that has control over a single file (and are controlled by the u and g bits). For a more detailed look into how Linux permissions work, check out this excellent writeup over on the Arch Wiki.

In your case, the files are owned by the nobody user and the nogroup group, and the permissions are set such that the nobody user can read, write, and execute files while the nogroup group can only read and execute. Similarly, everyone else can only read or execute the files.

That said, there are about three solutions to this problem. You can become the nobody user, you can become root, or you can change ownership of these files. The first one is really not recommended, as the nobody user is a special account that shouldn't really get used.

If you just want to delete the files and be done with it, you're going to need to use the terminal. Just run the below command to delete any specific file:

sudo rm /path/to/file/you/want/gone

If you want to delete a folder, you need to use a different command:

sudo rm -rf /path/to/the/folder/you/want/gone

Before pressing ENTER, make sure your command is free of typos or other errors. These commands are very dangerous, and can have unintended side effects if a command is typed improperly.

Alternatively (and probably the better way), you can take ownership of the files, giving you full control over them. Linux has something called the chown command for exactly this purpose. I'd assume you want to change the ownership of everything, so use this command:

sudo chown -R $USER:$USER /path/to/your/folder

If you only want to change the ownership of a single file, it's this command:

sudo chown $USER:$USER /path/to/your/file

For more information into how chown works, run the man chown command in your terminal to pull up its manual. Once again, be very careful with typographical errors -- they can and will bite you in unexpected ways.

  • Commands that operate on folders are particularly dangerous: sudo chown -R $USER:$USER /path/to/your/folder ; sudo rm -rf /path/to/the/folder/you/want/gone – sudodus May 8 '17 at 16:39
  • Thanks, I will try to change the ownership and see what happens will let you know then. – Anant_infinity May 8 '17 at 17:23
  • I really worked I changed the ownership of the folder – Anant_infinity May 31 '17 at 12:28
0

Open up a terminal window and use the following command:

sudo rm /path/to/the/file.txt

where /path/to/the/ is the file path and file.txt is the file to be deleted.

You will be asked to enter your password and the file will be deleted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.