home.social

#shelltricks — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #shelltricks, aggregated by home.social.

fetched live
  1. @cR0w I especially like how ^old_string^new_string^ can be abbreviated to just ^old_string when you want to delete the string instead of replacing it.

    For example, when I've modified nftables rules, I run this to check the ruleset:

    nft -c -f /etc/sysconfig/nftables.conf

    and then to apply the changes, I can enter just this:

    ^-c

    to run the same command again but without the -c option - i.e. this:

    nft -f /etc/sysconfig/nftables.conf

    #ShellTricks

  2. @cR0w I especially like how ^old_string^new_string^ can be abbreviated to just ^old_string when you want to delete the string instead of replacing it.

    For example, when I've modified nftables rules, I run this to check the ruleset:

    nft -c -f /etc/sysconfig/nftables.conf

    and then to apply the changes, I can enter just this:

    ^-c

    to run the same command again but without the -c option - i.e. this:

    nft -f /etc/sysconfig/nftables.conf

    #ShellTricks

  3. @pa @darthnull @bruce @bob_zim @cR0w Might be worth noting it should be ctrl-r

    ctrl-R (capitalized) will go one entry "closer" to the current time, while ctrl-r will cycle back through all matching commands in reverse chronological order

    Great if you realize a second too late "Oh shit, I needed that"

    #shelltricks

  4. @pa @darthnull @bruce @bob_zim @cR0w Might be worth noting it should be ctrl-r

    ctrl-R (capitalized) will go one entry "closer" to the current time, while ctrl-r will cycle back through all matching commands in reverse chronological order

    Great if you realize a second too late "Oh shit, I needed that"

    #shelltricks

  5. redteamers take note, if your c2 can't handle moving whole directories very well.

    usually works like a champ in places where they don't look at the network stack much or at all, or employs folks who openly say networking doesnt matter

    #BashTricks #ShellTricks #ssh #postgresql

  6. redteamers take note, if your c2 can't handle moving whole directories very well.

    usually works like a champ in places where they don't look at the network stack much or at all, or employs folks who openly say networking doesnt matter

    #BashTricks #ShellTricks #ssh #postgresql

  7. Want to read in a password from stdin during a demo without exposing it? This is what I used in my latest talk: `stty -echo && read PASSWORD && stty echo`. #ShellTricks

  8. Want to read in a password from stdin during a demo without exposing it? This is what I used in my latest talk: `stty -echo && read PASSWORD && stty echo`. #ShellTricks

  9. Capture STDOUT, STDERR and return status in shell variables

    This second answer ( the one with the banana function ) shows how to capture all three to variables in bash without needing tmp files

    stackoverflow.com/questions/13

    ----
    banana() {
    echo "banana to stdout"
    echo >&2 "banana to stderr"
    return 42
    }
    ----

    ----
    . <({ berr=$({ bout=$(banana); bret=$?; } 2>&1; declare -p bout bret >&2); declare -p berr; } 2>&1)
    ----

    Then check values of $bout, $berr, $bret

    #ShellTricks #bash #FLOX