<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>bash on BrainBit Latest Articles</title><link>https://brainbit.uk/tags/bash/</link><description>Recent content in bash on BrainBit Latest Articles</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Tue, 28 Jul 2020 19:23:37 +0000</lastBuildDate><atom:link href="https://brainbit.uk/tags/bash/index.xml" rel="self" type="application/rss+xml"/><item><title>Bash(and others) things that i use every day</title><link>https://brainbit.uk/posts/bashand-others-things-that-i-use-every-day/</link><pubDate>Tue, 28 Jul 2020 19:23:37 +0000</pubDate><guid>https://brainbit.uk/posts/bashand-others-things-that-i-use-every-day/</guid><description>More and more we embrace bash to do things that maybe in the past we used lower level languages (Dockerfiles , Makefiles , Pipelines etc etc), or at least that’s the way im seeing it , so im leaving some bash little things i user every day:
for loops: for i in $(seq 0 3) ; do echo ${i} ;done for i in {0..3} ; do echo $i ; done for i in &amp;amp;#34;a\nb\nc&amp;amp;#34; ; do echo $i ; done if else oneliners: [[ $( pgrep nginx | wc -c ) &amp;amp;gt; 0 ]] &amp;amp;amp;&amp;amp;amp; echo &amp;amp;#34;nginx running&amp;amp;#34; || echo &amp;amp;#34;nginx running&amp;amp;#34; [[ $( pgrep nginx | wc -c ) &amp;amp;gt; 0 ]] &amp;amp;amp;&amp;amp;amp; echo &amp;amp;#34;nginx running&amp;amp;#34; || { echo &amp;amp;#34;nginx not running&amp;amp;#34; , systemctl start nginx.</description></item><item><title>Quickly JSON.parse() on command line</title><link>https://brainbit.uk/posts/quickly-jsonparse-on-command-line/</link><pubDate>Tue, 30 May 2017 13:16:43 +0000</pubDate><guid>https://brainbit.uk/posts/quickly-jsonparse-on-command-line/</guid><description>I was trying to get some data out of etcd (kubernetes) and i found the value was returned as a string:
you can see the quotes in the beginning, so after playing with sed for a bit , getting me nowhere , i discovered the -r flag of jq so…
As you can see now you have a json object back that we can pass back to jq:
just that.</description></item><item><title>Tmux productivity!</title><link>https://brainbit.uk/posts/tmux-productivity/</link><pubDate>Sat, 14 Jan 2017 19:24:35 +0000</pubDate><guid>https://brainbit.uk/posts/tmux-productivity/</guid><description>Screen multiplexers have been around for a long time , but for me i never been a big fan of screen , for a long time I’ve used dedicated terminals , until tmux came up . I have spent ridiculous amounts of time looking to work with the minimum effort possible and without reaching for the mouse , so this list is what i think it’s essential for my productivity:</description></item><item><title>My WeeChat Plugins</title><link>https://brainbit.uk/posts/my-weechat-plugins/</link><pubDate>Sun, 08 Jan 2017 16:05:53 +0000</pubDate><guid>https://brainbit.uk/posts/my-weechat-plugins/</guid><description>Weechat is an “irc” client with a ton of plugins , and it can connect to a lot more things than simply irc, (you can use bitlbee to proxy to things).
Buffers:
So others than some custom colors you can see buffers.pl (which is the bar that’s on the left , it’s quite useful)
To install it use:
/script install buffers.pl Iset
Another i would like to recommend is iset , it let you change settings from weechat itself it looks something like:</description></item><item><title>UNREACHABLE!</title><link>https://brainbit.uk/posts/unreachable/</link><pubDate>Sat, 26 Nov 2016 14:34:50 +0000</pubDate><guid>https://brainbit.uk/posts/unreachable/</guid><description>Have you ever run some ansible playbook and you get a message similar to: But you know the host is “reachable” , because you can ssh into it , it just happens that the ansible’s host ssh key isn’t on the node .
The word “UNREACHABLE” means (at least to me) that you can’t connect to port 22 (in this case) either because there’s no routing or there’s no application(ssh in this case) binding port 22.</description></item><item><title>Tcpdump inner works #1</title><link>https://brainbit.uk/posts/tcpdump-inner-works-sharp/</link><pubDate>Thu, 24 Nov 2016 09:27:49 +0000</pubDate><guid>https://brainbit.uk/posts/tcpdump-inner-works-sharp/</guid><description>I use tcpdump a lot , we all do , but if someone tells you to explain how it works what would you say?
Well we know that tcpdump applies a number of rules (if told) to filter traffic before the kernel(iptables or similar) drops it , that’s why if you do something like
tcpdump -i any dst port 21 and you start some connections against port 21 you will see traffic even tho you might not have port 21 bound by any process (some ftp server or what not).</description></item><item><title>Containers but not Docker</title><link>https://brainbit.uk/posts/containers-but-not-docker/</link><pubDate>Mon, 21 Nov 2016 20:47:08 +0000</pubDate><guid>https://brainbit.uk/posts/containers-but-not-docker/</guid><description>I’m not docker’s biggest fan , but i do see its benefits , although i think somehow it has managed to sort of hide what docker really is and what it really does, but this post isn’t about docker , but about namespaces.
Docker/lxc use a kernel feature that , in simplest terms , allows a process to have isolation a multiple levels (pids / fs / hostnames / etc)</description></item><item><title>Hardening Tools #1</title><link>https://brainbit.uk/posts/hardening-tools-sharp/</link><pubDate>Mon, 14 Nov 2016 19:03:06 +0000</pubDate><guid>https://brainbit.uk/posts/hardening-tools-sharp/</guid><description>I’d like to write short articles about cool hardening/sec tools , this is one i found the other day:
There’s a bunch of security tools around to do hardening , but one i liked very much recently is: Lynis.
Lynis is a collection of scripts in bash (?) that parse/run different things and give you a score, for example
(running ./lynis — profile default.prf ,
(default.prf is obvious your default profile where you can disable/enable things etc)</description></item><item><title>Repl for jinja2</title><link>https://brainbit.uk/posts/repl-for-jinja/</link><pubDate>Fri, 07 Oct 2016 16:24:32 +0000</pubDate><guid>https://brainbit.uk/posts/repl-for-jinja/</guid><description>As i work with Ansible (or I try to learn Ansible) sometimes i want to test little j2 snippets (Used in templates/when conditions / others within Ansible). You can ipython (or your fav repl ) and do it manually or you can use (and contribute) to this little tool i built yesterday.
I’ve called jinrepl (lack of a better name) , and it basically evals strings into j2.template and renders it , nothing major, but with a few neat features.</description></item><item><title>Logging Ansible</title><link>https://brainbit.uk/posts/logging-ansible/</link><pubDate>Thu, 06 Oct 2016 10:18:12 +0000</pubDate><guid>https://brainbit.uk/posts/logging-ansible/</guid><description>It’s important to have some kind of logging when things go wrong , and when they go right too .Somehow Ansible seems to log (to syslog (LOG_INFO facility))
Given this very basic playbook:
if you run something like: ( -vvv critical as otherwise, nothing goes to syslog)
ansible-playbook -i hosts demo.yml -**vvv** You will get some thing like:
which us quite neat , but what happens when things go wrong?, im gonna change the command I’m running to “decho” instead of “echo” , as we all know that’s gonna trigger some kind of error:</description></item><item><title>Ansible Conditionals quick dive</title><link>https://brainbit.uk/posts/ansible-conditionals-quick-dive/</link><pubDate>Wed, 05 Oct 2016 12:36:17 +0000</pubDate><guid>https://brainbit.uk/posts/ansible-conditionals-quick-dive/</guid><description>I feel like , this is too much , too much typing to do something so simple:
Somehow i think this should simplified , i think the assertion at the top is too much to test something so simple , I’d like something like:
If you not gonna reuse passwd_exist anymore what’s the point of another task to get this done.
Now I’m by no means an Ansible expert but i was wondering how complicated would it be to implement something like that , i went to freenode and the confirmed the only way to get this done was by having that “check” task :</description></item></channel></rss>