dapper sudo
Alexander Skwar
listen at alexander.skwar.name
Wed Jul 5 08:30:04 UTC 2006
Jack Bowling wrote:
> On Tue, Jul 04, 2006 at 02:44:14PM +0100, Toby Kelsey wrote:
>> boricua wrote:
>> >how come dapper does not allow me to do this
>> >
>> > sudo cat /dev/null > /var/log/apache2/error.log
>> >
>>
>> Because the sudo only applies to the command 'cat', not the redirection.
>>
>> Try
>> sudo dd of=/var/log/apache2/error.log < /dev/null
>> or
>> sudo tee /var/log/apache2/error.log < /dev/null
>>
>>
>> It is a bug that there is no obvious command to truncate a file.
>
>
> Could somebody tell me if there is any difference between the above cat
> command and
>
> [sudo] echo "" > /var/log/apache2/error.log
>
> assuming one has sudo'ed to a root shell?
That assumption is the difference. So, yes, there IS a *HUGE* difference
between
sudo -s
echo > /var/log/apache2/error.log
(BTW: No need for the "echo" here, unless you're really after an empty
line).
and
sudo tee /var/log/apache2/error.log < /dev/null
The difference is, that the shell "executing" "> /var/log/apache2/error.log"
is run with root rights. That's actually more-or-less the same as doing
sudo sh -c " > /var/log/apache2/error.log"
Alexander Skwar
--
The more laws and order are made prominent, the more thieves and
robbers there will be.
-- Lao Tsu
More information about the ubuntu-users
mailing list