Executing an action or a set of actions on files.

Sometimes, you want to execute specific commands on a set of files, or manipulate some files with the same commands. Eg: - rename all files in a directory with a specific filename scheme. - extract id tags information from mp3s etc.

Share files in a Linux Network

Sometimes you want to share files in linux via network. Windows has the file sharing mechanism since Windows 98 or so. Whats there on Linux.

use available tools provided by your Platform(Linux)

Linux provides a nice tool called ImageMagick. This tool makes converting images to pdfs very easy.
> convert rofl.jpg rofl.pdf
It can also convert recursively, eg: whole directory trees.

> convert *jpg foo.jpg


Wakeonlan + ssh + VNC

*) Check if your IP address is static. If not you should use a service like dyndns to find your home IP.
*) Install an alternative firmware on your router like DD-WRT.
*) Install the program wakeonlan and ssh on your router.
*) If your workstation is switched off you can now use ssh to open a shell on your router and run wakeonlan from there to boot the workstation.
*) For secure remote access to your workstation you can install ssh.
*) Choose an unused port on the router and forward it to the ssh-port on your workstation so you can access it from the outside.
*) ssh can also deal with graphical user interfaces but this is quite slow and needs quite a lot of bandwidth.
A better option is to install a VNC-server on the workstation and a VNC-client on the laptop. The connection can be tunneled through ssh so it is encrypted.


Remote access to workstation

Sometimes I am at the university and I need some files I got on my workstation at home or I need to run some software I do not have installed on my laptop. Therefore I would like to have a tool or a collection of tools to turn on my workstation remotely if it is switched off and to interact with it. I want to be able to access all files on it and transfer them to my laptop if needed or copy data from my laptop But sometimes it is also necessary to start a program on the workstation. Theses programs could be simple shell scripts or other command line tools but also software with a graphical user interface. The workstation is connected to a Wifi-Router that is always turned on. Security is import, no one else should be able to gain access or intercept the communication.

Password recovery

Last summer I got a bit paranoid and created a very strong password for my laptop. I used a random generator to create an extremely strong password and for safety reasons I did not write it down. After a few weeks of vacation I forgot of course the password. I could have reinstalled the operating system but I was not in the mood to search for and reinstall all the software that I had on my laptop. I just wanted to have full access again to do some updates. The laptop did not have any other operating system installed. It had an internal DVD-driver but I was not sure if it was working or were my bland DVDs were. The BIOS was resent enough to allow booting from a USB pen drive. I also had another PC with Linux on it available.

Getting image width and height in Linux

imagemagick is a linux command line tool with many options to manipulate image files.
It allows you to resize an image, change between image formats and also work with pdfs (converting pdfs to images and vice versa, split and merge pdfs etc.)

One of the tools that come with imagemagick is called identify, which produces an output like

Image: rose.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 70x46+0+0
Resolution: 72x72
Print size: 0.972222x0.638889
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
min: 37 (0.145098)
max: 255 (1)
mean: 145.58 (0.5709)
standard deviation: 67.3195 (0.263998)

The "Geometry" line: Geometry: 70x46+0+0 contains the width x height, in this case 70x46 pixels, if you want to get the width "70" and height "46" without messing around with regexp you can use awk to do this in the following way

res=`identify -verbose $f | grep Geometry | awk '{print $2}' | awk -F+ '{print $1}'`
width=`echo $res | awk -Fx '{print $1}'`
height=`echo $res | awk -Fx '{print $2}'`

you first get the geometry line from the identify output using grep, then split it along white spaces getting "70x46+0+0", further you split that up along the + getting "70x46"

you then extract the width doing the exact same thing but splitting along the x and then getting the first element (the width) and the second (the height)

How to use LAN services over the Internet ?

Local Networks have many advantages when it comes to more complicated services like file sharing, remote desktop, network printer usage or NAS. Of course, I could use web space like DropBox, and there might be many other ways to make LAN services available over the internet. But what I am searching for, is an all built-in solution which is secure and easy to use. I want be able to connect several clients together for my LAN services. Not at least, LAN-Party’s without all the disadvantages due do local management and mobility are one of my expectations.

Obtain image file information using the Linux shell

Sometimes you have to evaluate an image, ie. find out what its width and height is and check against a maximum or minimum and based on the outcome take certain actions. You want to do this using the Linux shell.


RTC device behavior in Linux

Linux features a command called rtcwake which can - turn the computer off - suspend to memory - suspend to the hard drive - .. some other power saving mode and then turn it back on using the computers motherboards rtc device. Using Ubuntu Server 11.X and rtcwake with the "off" option was working as expected. On the very same machine with Ubuntu Desktop 10.10 after executing rtcwake the computer stays on with the rtcwake programm giving back control to the command line without giving any feedback (no error, no success message). How to "install" the "off" option (and other options) to work with rtcwake.



Subscribe to linux