changing ownership of all files in the current directory and change the permissions so that the owner has read-write access, while group and other users have only read access.

Problem = Give commands for changing ownership of all files in the current directory to user and group nobody, and change the permissions so that the owner has read-write access, while group and other users have only read access.

I am little confused on how I can do this? I thought that in order to change the permissions on all the files in the directory, I would have to use the -R option?

Can anyone assist?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

to change ownership:

chown -R nobody:nobody /dirname

to change permissions:

chmod -R 644 /dirname


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ainselybAuthor Commented:
So by changing the permissions on the directory it will effectively change the permission on all the files it contains as well?
http:// thevpn.guruCommented:
No ..the -R switch does that

       -R, --recursive
              change files and directories recursively

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

http:// thevpn.guruCommented:
#create dir
mkdir dir
#create file in dir
touch dir/testFile
#change file to 777
chmod 777 dir/TestFile
#change dir to 666
chmod 666 dir

#dir is 666
root@alinux-laptop:~# ls -l | grep dir
drw-rw-rw- 2 root root  4096 2008-02-10 21:38 dir

#file is still 777 because -R was not used
root@alinux-laptop:~# ls -l dir/testFile
-rwxrwxrwx 1 root root 0 2008-02-10 21:38 dir/testFile

That would change the directory also. To change all file in directory You could use:

chown nobody:nobody /dirname/*
chmod 644 /dirname/*
No, the -R option means apply to files and subdirectories
...and in current directory this would be:

chown nobody:nobody ./*
chmod 644 ./*


chmod -R 644 /dirname

is not a good idea if there are any subdirectories and it effectively renders the permissions on the sub-directories as unusable.

http:// thevpn.guruCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.