Last Updated: February 25, 2016
·
235
· cipher

Apply command to a previous command in BASH

Sometimes you forget to add the main command to whatever you're doing in BASH, for example:

apt-get install pkg

Will tell you that you don't have root permissions to issue that command, this means you've to add sudo to the beginning of the command, so instead of rewriting the whole line or pressing the "up" button and going to the beginning and typing sudo, you can do

sudo !!

This will apply sudo to the previous line.