As we know if you are not a root user and as a user you do not have the read, write or execute permission on a file then you can do nothing.
If you even authorized to log in as root, but still it's a tire some job type do su - , type password
and after doing your job again exit back to user.
There is an short way to perform this, without going into long process.
Suppose you want to restart network service, so the long process to do such is
$su -
password:
#service network restart
And the shortest way to do so is
$ su -c "service network restart"
password: Enter your password here
YOU ARE DONE.
Take another example
You have a file myfile.txt whose owner is root and you only have read permission to it.
If you type $ vim myfile.txt, file will open in vim but you are ot able to save any changes you made into the file.
But if you type $ su - "vim myfile.txt", it will only ask for the root password and the file will open for read and write.
No comments:
Post a Comment