{"id":252,"date":"2017-12-05T12:19:41","date_gmt":"2017-12-05T12:19:41","guid":{"rendered":"http:\/\/wp.spoton.cz\/?p=252"},"modified":"2017-12-05T12:19:41","modified_gmt":"2017-12-05T12:19:41","slug":"extremely-useful-unix-on-liners","status":"publish","type":"post","link":"https:\/\/spoton.cz\/index.php\/2017\/12\/05\/extremely-useful-unix-on-liners\/","title":{"rendered":"Extremely useful Unix one-liners"},"content":{"rendered":"<p>Simple and effective, if you know what you&#8217;re doing. That is the CLI, or terminal on any UNIX based system. I&#8217;ll just dump all one-line commands that might come in handy &#8211; here.<!--more--><\/p>\n<h3>Sort pacakges by size on debian<\/h3>\n<p>Ever wondered how to sort out packages based on their sizes on Debian, Raspbian, Ubuntu, or whatever debian based?<\/p>\n<pre>dpkg-query -W --showformat='${Installed-Size;10}\\t${Package}\\n' | sort -k1,1n<\/pre>\n<h3>Age of kids in days<\/h3>\n<p>If you are not sure how many days your kids roam the earth. Not exactly a oneliner, but could be&#8230;\u00a0<\/p>\n<pre>bday='2013\/01\/11 13:00'; expr $(expr $(expr `date +\"%s\"` - `date +\"%s\" --date \"$bday\"`) \/ 3600) \/ 24<\/pre>\n<h3>Redirect ports.<\/h3>\n<p>If you love tunneling, you come to this need inevitably. For example, redirect all traffic to port 443 (on all addresses) to port 4433 &#8211; where an API is listening, but cannot listen on a non-privileged port. Tadaaa.<\/p>\n<pre>iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 4433\n# If you want to list your rules\niptables -L -t nat\n# Delete the rule? 2 =&gt; rule number, count\niptables -t nat -D PREROUTING 2<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple and effective, if you know what you&#8217;re doing. That is the CLI, or terminal on any UNIX based system. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":365,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,9],"tags":[28,34,57,59,61,73,85,95,97,98],"_links":{"self":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/252"}],"collection":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/comments?post=252"}],"version-history":[{"count":0,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/252\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media\/365"}],"wp:attachment":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/categories?post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/tags?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}