Linux command for change owner and group of current directory

Can someone look at the following to see if I have this correct? I am new to Linux. Thanks.

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.
$ su
$ chown R nobody .
$chgrp -R nobody .
$chmod 644 .
$exit
ainselybAsked:
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.

jcullinsCommented:
i use the following command myself,

chown -R nobody:nobody <dirname>

so if you wanted to make your /var/www folder owned by user nobody and group nobody you would do

chown -R nobody:nobody /var/www
chmod 644 -R /var/www

0
TintinCommented:
Permissions on a directory should be 755, otherwise no one will be able to list the files.  Also, there's no need for the -R flag unless you really want the action to be recursive.
0
Michael WorshamStaff Infrastructure ArchitectCommented:
A quick site to keep in your favorites is the "CHMOD Calculator". It shows both the octal and symbolic file permissions setting.

http://www.ezau.com/latest/tools/chmod.html
1
Pétur Ingi EgilssonSoftware Engineer -- ConsultantCommented:
find . -type f -exec chown nobody:nobody {} \; <- will change owner of all files in . to nobody, and owner group to nobody
replace f with d so it will execute on all directories

find . -type d -exec chmod 755 {} \; <- will give owner full acces, group read\browse access, other read\browse access to all directories recursivly from your current directory.

0
Deepak KosarajuDevOps EngineerCommented:
u can use the below
chown -R nobody.nobody dirname
chmod -R 755 dirname
for example i created dir called test
the i use the following to change permission on it

chown -R nobody.nobody test
chmod -R 755 nobody

make sure u login as root if u r changing system directories if its the directory under u r home u can straight away use the above command without logging to root

good luck


0

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
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
Linux

From novice to tech pro — start learning today.