Count search results on Linux shell

Lets imagine you want to search for a term in a file and you want to know, how often it can be found in the file. With this command combination you can count search results on bash: $> less xmlfile.xml | grep SearchmeIfYouCan | wc -l This is how this way to count search results […]

Reset home folder permissions

Recently I messed up my life by running this from out of my home folder: $> chmod 600 * Naturally I thought to be in another folder 😉 The result was, that I could not open any programs any more. What was not that nice! 😉 To get out of trouble I had to run […]

Formatted CSV output on Linux shell

If you want to output a CSV file on Linux shell, you could just open it with less, cat or nano (un-formatted CSV output): $> less mydummyfile.csv $> cat mydummyfile.csv $> nano mydummyfile.csv The problem with this approach is, that you will get an unformatted ugly chunk of characters like that: A much better way is it, […]

Lock shellscript process under Unix based systems

Today I ran again into a common problem when dealing with cron based scipts that run concurrently. That’s why I had to lock shellscript process until it is finished before starting the next executing round. On Unix based systems like Linux you can achieve that with flock. flock binds a file descriptor to a certain lock […]

Htaccess Auth for wget and curl

You can download files protected by Basic Htaccess Auth via wget like that: $> wget –http-user=USERNAME –http-password=PASSWORD http://nice.file.url Or via curl like that: $> curl -u USER:PASSWORD http://www.caplantic.de  

Get your public IP via shell

To get your public IP you can use websites like www.whatismypublicip.com/ or just google for it (http://lmgtfy.com/?q=public+ip) But you can also get your public IP via the following Linux shell  command (the smart way :-D): $> curl ifconfig.me/all This gives you an output like that: ip_addr: 31.18.198.134 remote_host: ip123456.dynamic.kabel-deutschland.de user_agent: curl/7.35.0 port: 47745 lang: connection: keep_alive: encoding: […]

Run a DynDNS client under Raspbian

For a home automation project I have to setup a local DynDNS client on my Banana Pi running with Raspian. Here are the steps I’ve taken to run a DynDNS client under Raspbian (will work on other Debian based Linux distributions too): Install ddclient package: $>sudo apt-get install ddclient This command installs the package and starts the DynDNS […]

Get running Apache version via shell

You can get the Apache version currently running on  your webserver by the following shell commands. Get Apache version on CentOS / Redhat $> /usr/sbin/httpd -v Get Apache version on Ubuntu $> /usr/sbin/apache2 -v    

Xubuntu – Fix black screen after wakeup from suspend mode

On Xubuntu 14.04.3 LTS I got a black screen after wakeup the machine from suspend mode. This didn’t happen all the time. It was more of a sporadic phenomenon happening after entering the credentials to unlock the machine. Under these circumstances the screen got black and the machine didn’t react on any actions any more. I could got to […]

Deleting multiple lines with nano

That’s not as easy as you might think with nano. Mainly because of the stage keystroke-philosophy of nano. Here is the way I cut out multiple lines, whole paragraphs or also huge text blocks with nano (Xubuntu 14.04, MacOS X 10.9.5). Open file in nano: $> nano -c textFileToEdit.txt -c shows line-numbers. Alternatively you can press […]