Tech Tip: Use History Expansion To Save Time and Typing
Most shells maintain a history of the commands that you've typed and that history can be used to save time and typing. Most of us have probably used the up/down arrow keys already to move through the list of commands that we've already entered, but there are other ways to access the data in the history list.
Let's say you want to install a package (we'll use a Debian/Ubuntu-based system as an example), so you type:
$ apt-get install packagename
But wait a minute, you need 'sudo' to do that! So what do you do? Retype the entire command again? No, use history expansion and type:
$ sudo !!
This will run the entire last command with 'sudo' prepended to it!
Let's take another example, say you want to list a directory's contents before changing into it, so you use ls to see the directory:
$ ls /usr/share/doc
Now, rather than typing the entire path name again as an argument to cd command, you simply type:
$ cd !$
This takes the last argument from the the last command entered and inserts it in the new command (use !* to include all the arguments from the last command).
Most shells provide many more expansion features that can save time and typing, check your shell's documentation for more information. For bash search for "History Expansion" or "Event Designators".
-- Regards, Matthew Cengia
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Server Hardening
- BitTorrent Inc.'s Sync
- The Death of RoboVM
- EnterpriseDB's EDB Postgres Advanced Server and EDB Postgres Enterprise Manager
- The Humble Hacker?
- New Container Image Standard Promises More Portable Apps
- Open-Source Project Secretly Funded by CIA
- The US Government and Open-Source Software
- Canonical and BQ's Aquaris M10 Ubuntu Edition Tablet
- ACI Worldwide's UP Retail Payments
In modern computer systems, privacy and security are mandatory. However, connections from the outside over public networks automatically imply risks. One easily available solution to avoid eavesdroppers’ attempts is SSH. But, its wide adoption during the past 21 years has made it a target for attackers, so hardening your system properly is a must.
Additionally, in highly regulated markets, you must comply with specific operational requirements, proving that you conform to standards and even that you have included new mandatory authentication methods, such as two-factor authentication. In this ebook, I discuss SSH and how to configure and manage it to guarantee that your network is safe, your data is secure and that you comply with relevant regulations.Get the Guide