…with an open minded approach

Posts tagged “prompt

setup iptable rules for transmission (torrents)

Without further addo, here it is, a working example how to configure iptables to allow transmission torrents to internet (udp 51413) + transmission remote RPC (tcp 9091, localnetwork only) + ssh (tcp 22, localnetwork only).

 

 

Drop a comment if its usefull 🙂

Advertisements

text manipulation: lines to columns and other goodies

Have a look at the power of the “paste” comand – it just solves a bunch of situations with ease, and its litle known… transpose pair a lines into 2 columns, etc…

 

Have a look to these examples to get an idea of “paste” power…

 

http://www.theunixschool.com/2012/07/10-examples-of-paste-command-usage-in.html


unix directory hacks with cd

I’ll just link to the http://www.thegeekstuff.com/2008/10/6-awesome-linux-cd-command-hacks-productivity-tip3-for-geeks/

Read them carefully and your console efficiency may just get a big boost 🙂

 


Bash local variables

All variables in bash default to being *global*.

To define a variable as *local* to a function, we can do:

function my_func {

local MY_LOCAL_VAR=”is local to the scope of its function”

}


debugging bash scripts

There is a very handy bash option, that will “run the entire script in debug mode. Traces of each command plus its arguments are printed to standard output after the commands have been expanded but before they are executed” (see [1])

This seems most usefull for inhouse-scripts, to show progress of the script

 

 

[1]: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html

 

 


Bash initialization files

This bash resume diagram is respectfully copied from http://www.solipsys.co.uk/new/BashInitialisationFiles.html

I’ll post it here before I need it again – its just great


Prefix command with environment variable: my_var=”me” cmd_that_sees_my_var

In bash (at least):

This can be used to pass values into the program using the environment variables (instead of arguments) while not polluting the general envirnoment used by other programs

Good infos:

http://stackoverflow.com/questions/10856129/setting-an-environment-variable-before-a-command-in-bash-not-working-as-expected


Bash color prompt

For ubuntu it’s very ease to make the bash prompt colored -just follow the instructions

The reason that lead me to use it, is to easily distinguish the prompt in the middle of a lot of output, like in the end of log files or between commands – (see this ascii cast)