1

I have very specific questions regarding permissions. I have delved into the FilePermissions Wiki - https://help.ubuntu.com/community/FilePermissions

Recently I installed an ecommerce open source software on my LAMP server. It needed some permissions to be given.These were the two lines I executed ,blindly, in the terminal for all the permissions it needed-

sudo chown www-data:www-data * -R
sudo usermod -a -G www-data $username

Please explain what these two lines of code did. The MAIN REASON I am posting this question is because now it has locked some of my folders How do I revert all those permissions back to normal? How would I know which folders' permission it has changed and what were their normal permissions? What is the difference between chmod and chown and which should be used here?

0

2 Answers 2

2
sudo chown www-data:www-data * -R

The above command has changed ownership of all directories, sub-directories and files of your home directory from default to www-data user and www-data group

sudo usermod -a -G www-data $username

This command has added a new user www-data and new group www-data.

You can revert changes back to normal by this command

sudo chown username:username * -R

Replace username with your actual user_name

chmod changes file and directory permissions whereas chown changes ownership.

2
  • @Faizen, I'm not entirely convinced that changing the ownership to the users name will revert things back to normal. Have you seen askubuntu.com/questions/386928/default-permissions-for-var-www ?
    – Elder Geek
    Apr 14, 2015 at 17:36
  • I second Elder Geek, altough if "blindly" in OP's question means "right after having opened the terminal" that might be the right solution. Not convinced of the second either tough.
    – kos
    Apr 14, 2015 at 17:49
1

Short answer:

usermod The usermod command modifies the system account files to reflect the changes that are specified on the command line. as outlined in man usermod

chown changes ownership as outlined in man chown

Long answer: chown -R operates recursively so sudo chown -R www-data:www-data *

changes ownership of every file from the current directory down through all it's subdirectories to be owned by user www-data and group www-data.

usermod -a -G www-data $username appends www-data to the groups to which $username belongs. Unless you have an environment variable that will be expanded you'll need to replace $username with the actual username.

To return the permissions to defaults please see default permissions for /var/www

Not the answer you're looking for? Browse other questions tagged .