Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I can warmly recommend making your own oneliners.txt over time, especially if you hop between boxes a lot. Some of the more hyper-specific entries in my own list has saved my bacon more times than I'd like to admit... https://ocv.me/doc/unix/oneliners/


Also related: bash_history is your best productivity tool; https://martinheinz.dev/blog/110

I have a weird story about that.

When I was a junior sysadmin I worked for a company providing a SaaS solution for e-commerce.

The environment I worked in was bare-metal (as was the style at the time), with a 2 tier network architecture, lots of internal tooling (mostly in Perl fwiw) and highly complex interactions between components (cache items recorded in MySQL, centralised job control through a pair of activeMQ servers that had a postgres proof of record etc).

During this time, I fancied myself the growing expert, and thus I created the most gnarly one-liners you could imagine. But they did everything. I annotated them with a “function parameter” comment at the end

    $ if []; then x; fi ## FUNCTIONDOES: THING
then I would control+R constantly from the bastion host to do my daily work. I had managed to automate a huge amount of common requests this way.

The existing team was disgruntled and started leaving, eventually making me the most senior in the team.

Of course, I also left.

I kept good contact with the team that onboarded as I was leaving, and one day while drinking I was told (off-handedly but in no uncertain terms) that I was the author of “the bash_history”.

After enquiring to what they meant, they indicated that after I resigned, someone found my bash_history file (because I had been onboarding them and they had seen my workflow) and it had been immortalised by:

A) Being copied to everyones profile and placed in /etc/skel

B) being chattr +i (immutable)

I was honoured. and horrified.


What is your definition of bare metal?


No virtual machines, zones/containers/jails.

Physical deployment with an operating system that ran on hardware directly.

The only management interface being the very anaemic out of band management controller.


If you don’t jump around a lot between boxes, having a large HISTSIZE can be sufficient: you can write inline comments after fancy one-liners, and use Ctrl-R to find keywords in the comments.

Another option is to make functions, aliases, or scripts as a way of saving those tricks. Not applicable to all tricks, but stuff like “embed all referenced fonts in a PDF file using `gs`” or “get me the ISO 8601 week using `date`” is way easier to use when you wrap it like this.


And if you spend some time answering questions on stackoverflow/reddit, it'll become interesting enough to publish books ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: