• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2113
  • Last Modified:

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 .
2 Solutions
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

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 WorshamInfrastructure / Solutions ArchitectCommented:
A quick site to keep in your favorites is the "CHMOD Calculator". It shows both the octal and symbolic file permissions setting.

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.

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


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now