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.
Written by Mohammed Attia
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Linux
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#