Running the Previous Command

You can rerun the previous command with the up arrow and Enter. You can also rerun it with !! (referred to as “bang bang”). This is especially useful for those moments when you typed the command correctly, but forgot to preface it with sudo:

matthew@seymour:~$ apt-get updateE: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)E: Unable to lock directory /var/lib/apt/lists/E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?matthew@seymour:~$ sudo !!

This will run sudo apt-get update.

Get Ubuntu Unleashed 2015 Edition: Covering 14.10 and 15.04, Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.