1

I’m using Ubuntu 14.04. I’m having trouble clearing out a file. I’m getting permission denied even though I’m using sudo. Here’s what’s happening …

myuser@mymachine:~$ sudo chmod 755 /var/log/unicorn/unicorn.log
myuser@mymachine:~$ sudo echo '' > /var/log/unicorn/unicorn.log
-bash: /var/log/unicorn/unicorn.log: Permission denied
myuser@mymachine:~$ ls -al /var/log/unicorn/unicorn.log
-rwxr-xr-x 1 rails root 304746186 Dec 31 15:08 /var/log/unicorn/unicorn.log

What evil demonic possessions have taken over and how can I conquer this crazy file?

Dave
  • 2,014
  • 7
  • 20
  • 32
  • 5
    With `sudo echo '' > /var/log/unicorn/unicorn.log`, you're running the `echo` command as root but redirecting its output as your own (non-root) user. See [When using sudo with redirection, I get 'permission denied'](https://askubuntu.com/questions/230476/when-using-sudo-with-redirection-i-get-permission-denied). – Eliah Kagan Dec 31 '16 at 20:14

0 Answers0