How to zero out a logfiles

Ladner, Eric (Eric.Ladner) Eric.Ladner at
Tue May 25 05:25:34 EDT 2004

How about:

sudo cp /dev/null /var/adm/logfile

That avoids the whole problem with shell redirection and all.  The
problem with 'sudo echo > /var/adm/logfile' is the way that it gets
executed in the shell.  It really gets executed like this:

[ Sudo echo  (echo runs with root privleges, whoopie) ] then YOUR shell
tries to output that to the file /var/adm/logfile.  Since YOU can't
write the file, it gives you the permission denied message.


-----Original Message-----
From: sudo-users-bounces at [mailto:sudo-users-bounces at] On
Behalf Of Stephen Carville
Sent: Wednesday, March 31, 2004 7:53 PM
To: Sudo Users
Subject: Re: How to zero out a logfiles

On Wednesday March 31 2004 01:16 pm, Jim Horwath wrote:
> Hi all,
> I have been using sudo for a few months and I'm still learning the 
> ropes.  I need to zero a logfile with sudo, but I can't get the '>' 
> syntax just right.  I tried to search the archives but didn't find any

> hints.  I can't be the first (or last) person who wants to do this.
> For example:
> sudo echo > /var/adm/logfile
> or something similiar

The only way I know how is:

echo | sudo tee /var/log/admfile

Stephen Carville
UNIX and Network Administrator
stephen at
If you have been voting for politicians who promise to give you goodies
someone else's expense, then you have no right to complain when they
your money and give it to someone else, including themselves.
      --Thomas Sowell (1992)
sudo-users mailing list <sudo-users at>
For list information, options, or to unsubscribe, visit:

More information about the sudo-users mailing list