Hey guys first of all I searched a lot on this site but didnt get any exact answer to my questions.
Dont know something happened automatically and all the folders permissions changed automatically and there came a lock icon on all of my folders and files.
Then I searched on this site and got the solution as this command
sudo chown 777 -R $USER:$USER $HOME
It solved my problem half way, it removed the lock icon but now all folders permissions are read only so please guide me how to reset all the folder permissions as it was previously?
I'm using ubuntu 12.10
Thanks
Best Answer
DONT DO THIS!
You have written that you have done
sudo chown 777 -R ${USER}:${USER} ${HOME}
1. Problem
Your are using
sudo
to do an operation which should normally change resources you're controlling with your current user. This is extremely unsafe.2. Problem
You are using sudo and environment variables. This may lead you in to an error situation. For illustration try the following.
sudo echo $USER
--> e.g. shivamsudo echo '$USER'
--> root3. Problem
chown
will change the ownership of a file. Luckily you have add a failure. The parameter777
would be identified as user name that is not existing and the file ${USER}:${USER} is not found.The command
chmod
is responsible for changing file or directory permissions.Fixing the permissions of all folders below a distinct directory.
Use the following to change the folder permissions below a distinct directory:
In your case replace
BASEDIR
with~
. For the bash~
will be replaced with the home directory of the current user.This will process only directories (not files) and set the read, write and enter (aka execute) permissions for the owner of the directory.
For more informations please read
man chmod
Notes:
-R
because it will process all directories and files below the given directory.u+rwx
, because it is easier to understand.sudo
if you`re not realy need it.Check that your filesystem is mounted correctly
Ensure that the partition containing the problematic home directory is mounted read-write.
This should give an similar output:
If the rw option is not shown, then the partition is mounted for some reasons (e.g. inconsistency) read only. If this is the case invoke a file system check. This is normally also invoked during the boot of your computer.