We help IT Professionals succeed at work.

Linux command for change owner and group of current directory

ainselyb
ainselyb asked
on
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
Comment
Watch Question

Commented:
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

CERTIFIED EXPERT
Top Expert 2007
Commented:
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.
Michael WorshamCloud/Infrastructure Solutions Architect
CERTIFIED EXPERT

Commented:
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
PĂ©tur Ingi EgilssonSoftware Engineer -- Consultant

Commented:
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.

DevOps Engineer
Commented:
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