Thursday, December 29, 2016

Copy folder in linux without changing the existing permission.

 Sometimes we need to copy some folders without changing its permissions. But when we copy a folder to a new location, the new copy will have the copying person's permission. (Ex: If the copying person is 'root' then the new folder will have the permission only for root.
 One can copy the folder and then change the permission back to the original user. But this will difficult it the folder contains different permissions for different files or folders.
 So the solution for this is use "-pdR" options while copying.

> cp -pdR <file folder_name> <new_location>

Wednesday, December 7, 2016

Give root privileges for user on centos

By adding the user into 'wheel' group can give the root permission. Use the following command to add the user into wheel group. For this you should be login as root. Replace "username" with your one.

usermod -aG wheel username

Now switch to new user account from root.

> su - username

Check whether it works using a command which needs root privileges.

> sudo ls -ls /root

For the first time it will ask the user accounts password.

[sudo] password for username:

If the password is correct the command should execute with root privileges.

BUT if you receive a message like this.

username is not in the sudoers file. This incident will be reported.

That means the "wheel" group doesn't activated. To activate the group login as a root and check 'sudoers' file.

> visudo

That will open the 'sudoers' file. Go to the bottom and uncomment this line.

# %wheel        ALL=(ALL)       ALL

Now you can use root privileges.... ;)