8/17/2023 0 Comments Sudo make me a sandwich text only![]() ![]() While we're talking productivity, along the same track as the "! !" operator in bash (repeat the previous command) is: bash_history. One useful alias down? maybe I should finally get around to adding one for gerp='grep'? To make this more permanent I added it to the ".bashrc" file in my home directory "(~/.bashrc) so that it will be available whenever I pull up a terminal. Now when I try to bring the interface back up and forget to use sudo I can just type "gah" in frustration: $(history -p \!\!) - Bash evaluated expression that will print out the last command that was run and all supplied arguments. ![]() sudo - Command that will allows us to execute the following command as a different user 5. ='COMMAND' - What to do when we run gah on the command line. gah - The name of the alias that we are creating 3. alias - Bash feature that allows us to map a string to a simple command 2. ![]() To make life easier, and to save a few keystrokes in the long run, it can pay dividends to make an alias that will do the equivalent of sudo !! Command Breakdown alias gah='sudo $(history -p \!\!)' 1. To be honest, accidentally running a command without sudo happens more often than I'd like to admit. Well it's no big issue, I just ran sudo !! to run the last command but this time as root. GAH! Why do I need root privileges to bring up or down an interface? Why do I need to be root in order to use dhclient to get assigned an IP address via DHCP? Sigh. The other day, while working on setting up a new virtual machine for testing purposes, I ran the following command to get my networking configured "ifconfig enp0s8" down only to be greeted with the following: Immediately apply the skills and techniques learned in SANS courses, ranges, and summits ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |