Change ownership of folder and subfolders

How to change the owner/group of a file or directory recursively.

 bash | 
 
 copy code |
?

1
sudo chown -R newusername foldername

To change the group:

 bash | 
 
 copy code |
?

1
sudo chgrp -R newgroupname foldername