9

I had Windows installed before and I downloaded some files while using it.Then I installed Backtrack 5 R3 as dual boot and copied the files on windows to BT when BT was booted, and it was successful. (Also I always logged in as root on BT) Then I deleted Windows and installed Ubuntu 14.04 as dual boot and copied the files on BT to Ubuntu.

The problem is that when I want to open or access the files on Ubuntu when Ubuntu is booted, i can't; I get the error message

You do not have the permissions necessary to view the contents of “files”

I can however use the ls command with sudo to sudo ls files but can't use cd; when I try I get sudo: cd: command not found.

The way I found that worked was to log in as root on terminal and open/access the files that way. But it wasn't efficient; I still couldn't open the files via graphical file manager. Then I looked it up on many threads and only thing i found that worked was sudo chmod go+rx files but the problem with this is that it makes only the files folder accessible, not the subfolders, and if I try using the same command to the subfolders one by one it works but I've got hundreds of subfolders which also have subfolders in them.

So I'm asking if there's a more practical way of doing it.

Zanna
  • 70,465

3 Answers3

7

Just add the -R option to recursively change all the permissions of each files and directories under a specified directory. An example, recursively add read and write permissions for the owner and group on foldername:

sudo chmod -R ug+rw foldername

Read more about permissions ...

αғsнιη
  • 35,660
3

Instead of giving the whole directory structure insecure permissions that allow any user to write whatever they like to any file in it, make yourself the owner (recursively, using the -R flag):

sudo chown -R $USER: files

There's probably no need for chmod at all, but if you still have problems, check that the owner does have read, write and execute permissions on the directories, and read and write permissions on the files, by using find from the parent directory:

find files -type d ! -perm -u=rwx

If you find something, add an -exec to change the mode:

find files -type d ! -perm -u=rwx -exec chmod u+rwx {} +

Then for the regular files:

find files -type f ! -perm -u=rw

If you find something:

find -type f ! -perm -u=rw -exec chmod u+rw {} +    

This is arguably better than using the -R flag with chmod because we don't want to give files and directories the same permissions.

Zanna
  • 70,465
0

If you install the nautilus-admin addon from the repositories you can open (right click) any file or folder and change the permissions in the Properties tab.

It's a GUI solution to the problem for those who prefer it.