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?
ainselybAsked:
Who is Participating?
 
omarfaridConnect With a Mentor Commented:
to change ownership:

chown -R nobody:nobody /dirname

to change permissions:

chmod -R 644 /dirname

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

       -R, --recursive
              change files and directories recursively

0
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.

 
http:// thevpn.guruCommented:
Example
#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

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

chown nobody:nobody /dirname/*
chmod 644 /dirname/*
0
 
omarfaridCommented:
No, the -R option means apply to files and subdirectories
0
 
juanolleConnect With a Mentor Commented:
...and in current directory this would be:

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

0
 
TintinCommented:
Using

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.



0
 
http:// thevpn.guruCommented:
thx
0
All Courses

From novice to tech pro — start learning today.