Command to change add permissions for a new user to all files in all subfolders and folders

Hi there!

I'm new to Unix and haven't done command line stuff since MS-Dos and Turbo Pascal (hah!),
I would love some help figuring out this basic command (what I assume is basic).

I'd like to add a User to the permissions of all files in a folder and all files in all subfolders, as well as the folders themselves.

What I've figure out is that if, as a root user, I run the command:

sudo chomod 755 *.* 

then it changes the permissions of all the files in the folder I'm in. Which kind of solves the problem but isn't exactly what I was after.

Any thoughts at all?

Add the user to the group(s) that are associated with the directories you want the user to be able to create files in.

1 Like

Thank you Don!
Can I ask you ... how to do that?

The ls -ld directory... command will show you the group IDs associated with the directories you name. The users who are assigned to the various groups on your system are maintained in the file /etc/groups on most UNIX systems. Any editor can be used to update that file, but be sure that you make backups before editing that file. :wink:

1 Like

Ok I will try that, thank you so much!!

Hi,

If you would like to be more restrictive, this can be done in a more granular fashion using setfacl where you can give individual users the level of access required on individual file. Certainly in Linux, Solaris and AIX from memory.

Regards

Gull04

1 Like

Hi there everyone, I'd like to ask some more clarifications please as I'm still not getting very far with this.

So, ok, maybe it's best if I describe the problem.

I'm using Mac OS X. I re-formatted my hard drive and re-installed an older version of OSX that's more compatible with my hardware. Instead of using the Mac 'Migration Assistant' to restore my user and files from my Backup drive (created using 'TimeMachine'), I just copied things over (as I was copying to an older OSX than was used to create the backups).
I did that to create a clean start because I've had that backup drive for like 8 years and wanted to get reformat that drive too, getting rid of a heap of old, useless backups.

My issue is that all the files / folder and subfolders with files no longer have the correct User and correct permissions.
I can add a user with permissions to the files or a folder individually using OSX Finder, however doing that does not change permissions recursively in subfolders and files. So I have to do it all file by file. Which is pretty damn tedious.

So, I'm searching for a way to add a user to a bunch of files, folders, subfolders and their files and their subfolders and files, etc, with read/write permissions, in 'Terminal'. I also need to remove a user named 'Fetching...', ie an invalid user from my pervious installation of OSX.

I'm attaching an image of the issue from the file or folder information tab in OSX Finder, to make this clearer.

I would really, really appreciate help here. I no longer have the old backups at all, only one copy on my internal hard drive. So I can't just revert unfortunately. And unfortunately I only realized this problem after it was all done....

Ah well!!! :frowning:

Well I managed to figure it out.

(run as root user)
sudo chown -R (insert username) (filename)

very easy, not that easy if you don't know it... very ease once you do...

Honestly, I did not figure out your challenge from your first post.
Regarding chown, it resolves a symlink (unless it is compatible with traditional BSD Unix).
For ex, if there is a symlink xxx -> /etc/passwd the chown will change the target /etc/passwd.
It is safer to use chown -h -R

1 Like
Moderator comments were removed during original forum migration.