When you forgot to sudo a command you may want to write,
sudo !!
That would execute the last command applying the sudo
command to it.
However sometimes seems I can't do that, for example inside /etc
folders. What am I missing?
EDIT:
dione@saturno:/etc$ echo testing > testfile
bash: testfile: Permiso denegado
dione@saturno:/etc$ sudo !!
sudo echo testing > testfile
bash: testfile: Permiso denegado
dione@saturno:/etc$
Now I guess that's because it's doing sudo echo, and the problem is that redirection is not affected.
sudo !!
does generally work. – Oli Sep 17 '14 at 18:44