Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:
Jump to menu and information about this site.

Friday·28·January·2011

Cool new feature in OpenSSH 5.7: scp between two remote hosts //at 02:55 //by abe

from the always-wanted dept.

Just a few days after OpenSSH 5.7 was released upstream, our (Debian’s as well as Ubuntu’s) tireless OpenSSH and GRUB maintainer Colin Watson uploaded a first package of OpenSSH 5.7 to Ubuntu Natty and to Debian Experimental.

Besides the obvious new thing, the implementation of Elliptic Curve Cryptography which promises better speed and shorter keys while staying at the same level of security, one other item of his changelog entry stuck out and caught my attention:

  • scp(1): Add a new -3 option to scp: Copies between two remote hosts are transferred through the local host.

That’s something I always wondered why it didn’t “just work”. While it still doesn’t seem to detect such a situation by default, it’s now at least possible to copy stuff from on remote box to another without ugly port forwarding and tunneling hacks.

Further cool stuff in the changelog:

  • sftp(1)/sftp-server(8): add a protocol extension to support a hard link operation. It is available through the “ln” command in the client. The old “ln” behaviour of creating a symlink is available using its “-s” option or through the preexisting “symlink” command.

Colin++

Wednesday·01·December·2010

Useful but Unknown Unix Tools: htop //at 02:20 //by abe

from the top-on-steroids dept.

You probably know about “top”, in Debian and Ubuntu part of the procps package.

Ever wanted to see CPU and memory usage as bars and not numbers?

Ever wanted to kill a process from inside top by just selecting its row instead of having to type its pid?

Ever tried to press a cursor key inside top? It makes a noise and says “Unknown command - try ‘h’ for help”. Short said: top is not that interactive.

Ever wanted top to be more colorful?

Well, there is a solution to all these issues. It’s called htop (Debian package) and is some kind of colorful, ncurses based cross-over between top and a Midnight Commander for processes:

htop on single core machine htop on single core machine with MC theme htop on idling 16 core machine htop on 16 core machine under load
More screenshots of htop at screenshot.debian.net and at the project’s site at SourceForge.

It can do many things, top can’t do:

  • Different color themes including fore- and background (includes also a monochrome theme for people considering ANSI colors being eye cancer :-)
  • Highlighting the current user’s processes.
  • Scrolling up, down and sidewards.
  • Interactively selecting processes with cursor keys as well as with the mouse.
  • Kill or renice the selected process without having to enter its pid
  • Show the CPU usage for each core and a CPU usage summary at the same time.
  • Show CPU, memory and swap usage as textual bars, either encoded in colors or characters.
  • Easy interactive configuring while running.
  • Automatically saves the current state (sort order, color scheme, etc.)
  • Easy access to the most often used functions through F-keys like in Midnight Commander.

One more cool thing about htop: It’s also available on the Nokia N900 as “app”.

The only thing I found so far that top can do, but htop can’t, is top’s batch mode (e.g. with “top -b -n 1”) where it runs non-interactively and its output can even be piped to other processes. The Xymon/Hobbit monitoring system uses that as input for some machine statistics.

Tuesday·30·November·2010

Useful but Unknown Unix Tools: colored cal(endar) //at 02:09 //by abe

from the colorful-commandline-commands dept.

Another thing I regard as useful on the commandline are colors. (Others commonly refer to my color preferences as eye cancer, but that’s not relevant here. ;-) Colors help to easily distinguish between relevant and non-relevant things or to separate different things.

One colored command line program I use nearly everyday is the colored fork of bsdmainutils’s well know (or at least better known) “cal” program whose output looks like this:

$ cal
    November 2010    
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
$ 

Since the colored fork calls itself still “cal” (as the Debian source package is called), to avoid conflicts with bsdmainutils’s cal, the binary package and the binary itself are called ccal (short for colored cal) and its output looks like this:

$ ccal
    November 2010     
 Mo Tu We Th Fr Sa Su 
  1  2  3  4  5  6  7 
  8  9 10 11 12 13 14 
 15 16 17 18 19 20 21 
 22 23 24 25 26 27 28 
 29<30>               
                      
$ 

ccal also use the locale definitions (LC_TIME), if available, that’s why the one “screenshot” is Sun-Sat and the other one is Mon-Sun.

According to the man page, ccal has some more improvements over the classic cal:

If displaying the single-month format, ccal will look for a date file (the default file or whatever you specify with the -d option). If found, ccal will read the file, looking for special date descriptions for that month which will be displayed to the right of the calendar. By default, up to 24 appointments (number may be changed with -m) may be displayed per month. If the current date happens to fall on one of these special dates, it will be flagged by an asterisk. If there is room, appointments for the next month may also be displayed (next month’s dates having definitions like “2nd Thursday” will be skipped).

But I must admit, I don’t use that feature. I just use it as on-demand calendar sheet.

The colored “screenshot” above is btw. generated with Adam Borowski’s ansi2html which popped up after I published my Intent to package “aha” (for Ansi HTML Adapter), the first ANSI colors to HTML converter I found on the net. (And yes I searched for it because of this and some yet to come blog postings. No spoilers here though. ;-)

While capturing colored output of “ls” and some other tools was easy, it needed a little hack to capture ccal’s output, because if you pipe ccal output to anything, it drops its colors. Always. The solution was to run it in GNU Screen, log the output and then pipe the log file through “aha” or “ansi2html”:

$ screen -c /dev/null -L ccal; cat screenlog.0 | ansi2html > ccal.html

Probably the output of every program which drops colors when writing to a pipe instead of a terminal can be fetched that way.

Update, 2:04 CET: As Adam Borowski points out in message 62 of #605380, “script” is the better tool for making tools believe they talk to a terminal:

$ script -q /dev/null -c "ccal" | ansi2html

Catching the output of a whole year’s calender (“ccal 2011”) failed with GNU screen though, as it was truncated on the 24th of September by GNU screen (as it was already truncated in the screenlog.0), so no “screenshot” of that for the moment. And with script, I’d get the whole output, but would have to manually fix the styles so they don’t get posted literally to Planet Debian. So look for yourself how the output of “ccal 2011” looks like by installing ccal. ;-)

Monday·29·November·2010

Useful but Unknown Unix Commandline Options of cat //at 14:04 //by abe

from the cats-can-do-more-than-you-may-expect dept.

Yesterday in Harald König’s commandline talk at LinuxDay.at, I first heard of cat’s -e option, and noticed that cat has quite some interesting options. From the man page of cat:

-A, --show-all
equivalent to -vET
-b, --number-nonblank
number nonempty output lines
-e
equivalent to -vE
-E, --show-ends
display $ at end of each line
-n, --number
number all output lines
-s, --squeeze-blank
suppress repeated empty output lines
-t
equivalent to -vT
-T, --show-tabs
display TAB characters as ^I
-v, --show-nonprinting
use ^ and M- notation, except for LFD and TAB

Some examples made on an UTF-8 terminal:

user@host:demo $ cat bla
ä  ö  ü ß   


abc
user@host:demo $ cat -Ab bla
     1  M-CM-$  M-CM-6  M-CM-<^IM-CM-^_   $
$
$
     2  abc$
user@host:demo $ cat -Ens bla
     1  ä  ö  ü ß   $
     2	$
     3  abc$
user@host:demo $ 

I hope this blog posting will reduce the percentage of “useless uses of cat” by raising the amount of “useful uses of cat”. :-)

Saturday·27·November·2010

Useful but Unknown Unix Tools: units //at 14:56 //by abe

from the megameter dept.

Ever wondered how to easily convert e.g. 10 seamiles into kilometres? Use units:

$ units 
2411 units, 71 prefixes, 33 nonlinear units

You have: 10 seamiles
You want: km
        * 18.288
        / 0.054680665
You have: ^C
$

Of course this is interactive. There’s also a non-interactive mode:

$ units '10 seamiles' 'km'
        * 18.288
        / 0.054680665
$ 

The line with the asterisk means that 10 seamiles are 18.288 kilometres or 1 kilometre is the 0.054680665th part of 10 seamiles.

This quite non-intuitive output is caused by the fact that unit is designed to be used with units only:

$ units seamiles km
        * 1.8288
        / 0.54680665
$

Now this makes more sense: You have to multiply seamiles with 1.8288 to get kilometres and you have to multiply (not divide) kilometres with 0.54something to get seamiles.

But this output is still a little bit cumbersome, and annoying if you want to use it in shell scripts. But for luck, units knows some nice options, especially “-v” (“–verbose”) and “-t” (“–terse”):

$ units -v '10 seamiles' km
        10 seamiles = 18.288 km
        10 seamiles = (1 / 0.054680665) km
$ units -t '10 seamiles' km
18.288

Now that’s way easier to read and script!

You can also script more complex things like

$ units -v '100 attoparsec/microfortnight' m/s
        100 attoparsec/microfortnight = 2.5509901 m/s
        100 attoparsec/microfortnight = (1 / 0.39200466) m/s

Unfortunately not all common units are unambiguous for units:

units -v '100 km/h' m/s
conformability error
        100 km/h = 1.5091905e+38 s / kg m
        m/s = 1 m / s

Well, “h” seems not to be units unit for “hours”, so lets tell it explicity that we want km per hour:

units -v '100 km/hour' m/s
        100 km/hour = 27.777778 m/s
        100 km/hour = (1 / 0.036) m/s

Looks more like what I expected.

“units” behaves though a little bit strange when I try to convert litres per 100 kilometres into miles per gallon:

$ units -t '6L/100km' 'mpg'
conformability error
6e-08 m^2
425143.71 / m^2
$

Interestingly changing the verbosity helps already in this case:

$ units -v '6L/100km' 'mpg'
        reciprocal conversion
        1 / (6L/100km) = 39.202431 mpg
        1 / (6L/100km) = (1 / 0.025508622) mpg

Greetings from the Debian booth at LinuxDay.at and thanks to Y_Plentyn, rhalina and bzed for example ideas and the suggestion to write a blog posting about units. :-)

Friday·26·November·2010

Useful but Unknown Unix Tools: awsetbg //at 19:03 //by abe

from the an-awesome-background-image-tool dept.

Have you ever wondered which tool you should use to set the background of your X11 desktop? There are tons of it and every single one does need different command line options. And if you picked one, you could be sure, you’ll once come to a machine or operating system, where that one isn’t available.

When I started to play around with the tiling window manager awesome, I also noticed that the awesome Debian package contains awesome’s own desktop background image setting tool named “awsetbg”.

“Yet another one!” I thought.

But I was wrong: Today I noticed the word “wrapper” in awsetbg’s man page. I became curious and had a peek into its source code. And indeed, it’s an awesome desktop background image setting POSIX bourne shell compatible shell-script: It knows about not less than 15 other desktop background image setting tools and can be used as frontend wrapper for those who don’t want to remember each tool’s command line syntax:

Needless to say that most of them are also available in Debian. :-)

You may wonder what’s useful with it. Well, it does something you no more need to do yourself or in one of your own scripts: Checking which desktop background image setting tools are available on the machine you’re currently working and using the appropriate command line options for tiling, fullscreen, whatever.

Only drawback I found so far: In Debian, you need the awesome window manager package to be installed, if you want to get the script via APT. But on the other hand, it’s just a shell script. You can easily put it into your $HOME/bin or so. :-)

Thursday·25·November·2010

Useful but Unknown Unix Commandline Options: touch -d //at 20:42 //by abe

from the How-to-time-your-blog-postings-properly dept.

You may wonder how I manage to write one “Useful but Unknown Unix Something” blog posting per day. Well, I don’t. I write them in bursts, but don’t want to flood Planet Debian and Planet Symlink with more than one such posting a day.

The first bunch of postings were mostly slides (or part of a slide plus what I tell while showing the slide) from my Unknown but Useful Unix Tools talk and written somewhen last week. And this blog posting and yesterday’s blog posting were written in a row, too.

What does that have to do with Unix commandline tools? Well I use Blosxom as blogging engine and it’s based on simple text files lounging around in some directories, and the last modification time stamp is the posting’s date – which is cached after first time seen by the entries_index plugin so that I can fix typos without resetting the posting’s release date. Postings with a modification date in the future won’t be shown before that time.

So how do you set the last modification date to a date in the future? With “touch” from GNU Coreutils of course. Like “date”, “touch” also knows the option “-d” to explicity set a date and time instead of using the current date and time.

Now in my humble opinion the cool feature is that you can easily describe dates by giving touch values like “now + 1 hour”, “12:00 tomorrow” or so:

$ touch bla
$ ls -l
total 0
-rw-r--r-- 1 abe abe 0 2010-11-23 22:59 bla
$ touch -d 'now + 1 day + 23 hours - 42 minutes' bla
$ ls -l
total 0
-rw-r--r-- 1 abe abe 0 2010-11-25 21:17 bla
$

To see all the possibilities you have to describe relative dates with “touch”, “date”, and maybe other GNU Coreutils tools, check that you have “info” installed and call:

$ info '(coreutils.info.gz)Relative items in date strings'

Oh, and this whole story about setting modification dates manually to arbitrary values also means that the “Tattletale Statistics: Blogtimes November 2010” image in my blog’s side bar is absolute nonsense, at least this month. Well, never trust any statistic you haven’t faked yourself. ;-)

But on the other hand, the dates in the example may give a hint when I really wrote that blog posting. Or not. ;-)

And I wonder what my backup tools think about last modification times in the future. Well, they probably only check for modification dates newer than last backup and therefore should be fine. *phew*

Tag Cloud

2CV, aha, Apache, APT, aptitude, ASUS, Automobiles, autossh, Berlin, bijou, Blogging, Blosxom, Blosxom Plugin, Browser, BSD, CDU, Chemnitz, Citroën, CLI, CLT, Conkeror, CX, deb, Debian, Doofe Parteien, E-Mail, eBay, EeePC, Emacs, Epiphany, Etch, ETH Zürich, Events, Experimental, Firefox, Fläsch, FreeBSD, Freitagstexter, FVWM, Galeon, Gecko, git, GitHub, GNOME, GNU, GNU Coreutils, GNU Screen, Google, GPL, grep, grml, gzip, Hackerfunk, Hacks, Hardware, Heise, HTML, identi.ca, IRC, irssi, Jabber, JavaShit, Kazehakase, Lenny, Liferea, Linux, LinuxTag, LUGS, Lynx, maol, Meme, Microsoft, Mozilla, Music, mutt, Myon, München, nemo, Nokia, nuggets, Open Source, Opera, packaging, Pentium I, Perl, Planet Debian, Planet Symlink, Quiz, Rant, ratpoison, Religion, RIP, Sarcasm, Sarge, Schweiz, screen, Shell, Sid, Spam, Squeeze, SSH, Stoeckchen, Stöckchen, SuSE, Symlink, Symlink-Artikel, Tagging, Talk, taz, Text Mode, ThinkPad, Ubuntu, USA, USB, UUUCO, UUUT, VCFe, Ventilator, Vintage, Wahlen, Wheezy, Wikipedia, Windows, WML, Woody, WTF, X, Xen, zsh, Zürich, ÖPNV

Calendar

 2018 →
Months
Dec
 December →
Mo Tu We Th Fr Sa Su
         
19 20 21 22 23
24 25 26 27 28 29 30
31            

Tattletale Statistics

Blog postings by posting time
Blog posting times this month



Search


Advanced Search


Categories


Recent Postings

13 most recent of 30 postings total shown.


Recent Comments

Hackergotchi of Axel Beckert

About...

Debian GNU/Linux is my favourite Linux distribution, being stable, flexible, consistent and having a great community. Although I'm not the biggest bug report writer, I try to contribute by staffing the Debian booth at events, carrying the necessary hardware there or even organising the whole booth.


RSS Feeds


Identity Archipelago


Picture Gallery


Button Futility

Valid XHTML Valid CSS
Valid RSS Any Browser
This content is licensed under a Creative Commons License (SA 3.0 DE). Some rights reserved. Hacker Emblem
Get Mozilla Firefox! Powered by Linux!
Typed with GNU Emacs Listed at Tux Mobil
XFN Friendly Button Maker

Blogroll

People I know personally


Other blogs I like or read


Independent News


Interesting Planets


Web comics I like and read

Stalled Web comics I liked


Blogging Software

Blosxom Plugins I use

Bedside Reading

Just read

  • Bastian Sick: Der Dativ ist dem Genitiv sein Tod (Teile 1-3)
  • Neil Gaiman and Terry Pratchett: Good Omens (borrowed from Ermel)

Currently Reading

  • Douglas R. Hofstadter: Gödel, Escher, Bach
  • Neil Gaiman: Keine Panik (borrowed from Ermel)

Yet to read

  • Neil Stephenson: Cryptonomicon (borrowed from Ermel)

Always a good snack

  • Wolfgang Stoffels: Lokomotivbau und Dampftechnik (borrowed from Ermel)
  • Beverly Cole: Trains — The Early Years (getty images)

Postponed