Friday, November 15, 2013

Magic screen on the wall, who is the fairest one of all?

Just wanted to share a very old article I stumbled upon a few day ago. It is a small into to GNU screen and can be found here http://www.linuxjournal.com/article/6340.

Like many other vannabe *unix natives I have being using screen on and off for different tasks, but not very efficiently. Basically I just used it to launch a process and then Ctrl-A+D to detach and get back later with screen -r. Just recently discovered that screen is a very power full tool for doing your every day work.

Now the first thing I do when opening my laptop is "still" to open Chrome but the second thing I do now is to type screen in my terminal and hence spawning windows within screen with all the stuff I need. But in order to work efficiently with screen you need to know the basics of navigating between windows, copy-paste and so forth. All this a more is covered very nicely in the article above.

Friday, September 20, 2013

Disk space not used, but not free. Where did it go...

I recently pulled out almost all of my hair, searching for lost disk space on a Ubuntu box.

"df" showed that almost all space on disk was used, but i was not able for find the files taking up all the space. Of course I went through all the usual suspects (http://ubuntuforums.org/showthread.php?t=1122670), but in the end cause was very simple and yet not obvious.
Side story; the box runs a installation of MySQL that had been mangled when trying to import a database from another box. The MySQL files had been deleted, but I forgot to shutdown the MySQL daemon. So all files used by MySQL was still held by MySQL. This led to disk space being used, but not found when searching for files. the trick to discover the used space was the following:

lsof | grep "deleted"

I know it is a obvious error, but I use a few hours to find this.So heres the tip for you.

Monday, September 9, 2013

Simple copy of file between linux boxes with netcat

I am still pretty new all this Linux sysadmin stuff, so when I get new tricks to to help me I clap my hands and quickly write it down. So here goes.

If you need to copy large amounts between instances, you might not have access to copy between the specified instances via scp. Here netcat, nc, can help you. It opens a direct connection between the two instances, so you can stream bit from one to the other.

Example

I want to send file1.txt from instance A to instance B.

On instance B do:

$ tar -cf - . | nc A_ip 4000

On instance A do:

$ nc -l 4000 | tar xvf file1.txt

If you need to send over a lot of files you can use the following on instance A:

$ nc -l 4000 | tar xvf -

If you are sending a a huge amount of data, you might need to throw gzip and gunzip in to the mix:

$ tar -cf - . | gunzip | nc A_ip 4000
$ nc -l 4000 | gzip |tar xvf file1.txt

Of course you need to make sure the ports are open for communication, but most instances have at least one open port that can be used. Just make sure the port is not use by other programs.

Note that netcat syntax differs a bit between the original unix version and the OpenBSD version. The above examples are in the OpenBSD variant.

Reference

 - http://www.commandlinefu.com/commands/view/2536/using-netcat-to-copy-files-between-servers


Friday, March 15, 2013

Sad day for people who can concentrate for more than 2 minutes

Its a sad day today. Google Reader have been terminated!

In the newest spring cleaning from Google, Google is shutting down Google Reader along side a lot of other stuff. I am not to say wether this is good business or not  as seen from Googles point of view. But from my point of view, its a sad day.

I have been using Google Reader for more than 6 years and have grown accustomed to its simplicity, easy navigation and general ease of use. These characteristics are, in my opinion  not to be found any where else in any RSS reader, hence a sad day.

The main thesis out in webland is that most people now a days use social media for keeping track of news and therefor there is no use for Google Reader/RSS anymore. That might be right for day to day news, "Elephant ate my baby" kind of stuff, but to me and a lot of others, there a re simply to much stuff I need to keep my eye on and social media is simply going by to fast and to shallow. I need a place where everything is aggregated and stays there until I have decided that it should not any more. Social media today simply does not do this very efficient today. Most social media today is like a flashing bilbard on Time Square, things flashing by to feed people in a hurry and people who cannot concentrate for more that 2 minuts at the time. My guess is that most people disagree with me on that point, but from where I am sitting this is the truth.

Enough ranting on social media for now. The bottom line is that I will be missing my faithful companion Google Reader. Hopefully I will find a new friend that will support me in my daily work and help me stay up to date.