Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1
denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are
you root?
matthew@seymour:~$ sudo !!

This runs sudo apt-get update.


Running Any Previous Command


You found a neat trick and ran it, but you can’t remember it. That is
frustrating. You know you can use the up and down arrows to search through
your command history and try to find it, but you last ran it earlier in the week,
and you aren’t sure how long that will take. No worries. You can search your
command history.


Type Ctrl+R at the command line to start what is called a “reverse-i search”
and begin typing. Whatever you type will be matched to previously run
commands, so if you know it was a cool combination of commands piped
together that had sort in the middle, start typing “sort” and watch as the
displayed commands from your history appear. When you find it, press Enter
and run it again.


Running a Previous Command that Started with


Specific Letters


Say that you are listing the contents of a directory that is several layers deep,
and you last ran it about nine commands ago, but you don’t feel like scrolling.
No sweat. Use ! (exclamation point) and the letters that make up that
command or its beginning, as shown here:


Click here to view code image
matthew@seymour:~$ !ls


This runs the most recently run command that started with ls.


Running the Same Thing You Just Ran with a


Different First Word


Say that you just used ls to list a file, and you have confirmed that it is
present. Now you want to use nano to edit the file. Use !* (exclamation
point asterisk):

Free download pdf