How to mount a ISO image under Linux

This post will be short. I wil only write the necessary commands to mount an ISO under Linux.

1. Open your terminal and get root

pedro@pedro-laptop:$ sudo su

2. Create the directory where we wanto to mount the ISO image

root@pedro-laptop:$ mkdir /media/iso

3. Mount the image in the directory as shown below

root@pedro-laptop:$ mount -o loop image.iso /media/iso

Where image.iso is the ISO file we want to mount, and /media/iso is the directory we created previously.

That’s all, now we can go to the directory where the ISO is mounted and explore it like a regular CD or DVD!

pedro@pedro-laptop:$ ls -lah /media/iso

In order to umount, just launch the command as superuser

pedro@pedro-laptop:$ sudo umount /media/iso

How to recover a file deleted by SVN if you use Eclipse

If you arrived until here, maybe you have lost a file and you want to recover it, so summon up your patience (and get lucky).

Some days ago I was so happy working with Eclipse writing PHP code when I thought: «This is the moment to commit my work». And I did it.

Usually, making a commit makes your SVN to manage the files, synchronicing the modified ones, and storing the new changes in a secure place. But when more than one person is working on the same file, you have a lot of chances your SVN to become crazy getting in troubles. I lost almost the whole work of this day 🙁

Searching on internet (I can’t remember where) Thanks to Dani Bru and his invaluable help, he found the name of a magic directory where were supposed to rest an automatic set of backups. «Yes… of course!» I thought. I had no hope, but this was the only track to solve the problem, and we get to work.

Apparently, in some obscure and hidden place of your file system, Eclipse makes (at least one) a backup before a commit. And this is how we find the place:

First step

Open your terminal and write:

pedro@pedro-laptop:~$ updatedb

Be patient, this can take a while. Specially if you never did it before. The command updates the file system index, so we can get an accurate search in the next step. When it finalizes, you won’t get any output, just will return to the console.

Second step

Search the string org.eclipse.core.resources, which is the magic directory that can save our lifes (well, our day):

pedro@pedro-laptop:~$ locate org.eclipse.core.resources | grep history

Third step

Go into the directory relative to your project. Specifically into the .history hidden directory. In this example I will search something about an android project:

pedro@pedro-laptop:~$ cd /home/pedro/workspace/android/.metadata/.plugins/org.eclipse.core.resources/.history/
pedro@pedro-laptop:~$ ls
0 13 1c 2 24 28 2f 33 38 41 48 4e 52 60 6a 71 7a 7f 84 88 9 9b a3 a9 af b2 b6 be c2 c7 ce da e6 ec f f3 fd 1 16 1d 20 25 2a 3 34 3a 43 49 5 57 61 6e 72 7b 8 85 89 91 9d a4 ab b b3 b7 c c3 c8 d2 db e7 ed f0 f7 10 17 1e 22 26 2b 30 36 3c 44 4a 50 59 63 6f 75 7d 81 86 8a 94 9f a5 ad b0 b4 b8 c0 c5 ca d7 e2 e8 ee f1 f9 12 18 1f 23 27 2d 32 37 3d 45 4c 51 5f 64 7 77 7e 83 87 8d 97 a0 a8 ae b1 b5 b9 c1 c6 cd d9 e3 ea ef f2 fc

Fourth step

Launching a ls, we will get a lot of directory names without any apparent sorting (I couldn’t figure at least). But we can sort them by date with this command:

pedro@pedro-laptop:~$ ls -tlahr

This command will show the directories from older to newest (oldest at top of the list, and newest in the bottom). The only thing we can do at this point is look into these directories, starting by the newest one. Maybe some directories are empty, in this case go to the previous one. Being lucky, you will find some directory containing some strange files named like a MD5 hash. Open them and check if they are what you are looking for:

pedro@pedro-laptop:~$ cd e2
pedro@pedro-laptop:~$ ls -lah
total 20K
drwxr−xr−x   2 pedro pedro 4.0K 2011-09-06 00:30 .
drwxr−xr−x 147 pedro pedro 4.0K 2011-09-06 00:54 ..
−rw−r−−r−−   1 pedro pedro 1.9K 2011-09-06 00:27 1036c7a60ed800101a3dcfaf52c523eb
−rw−r−−r−−   1 pedro pedro  824 2011-09-04 21:14 108c03632ad7001017b898f7b25b1cbb
−rw−r−−r−−   1 pedro pedro 1.3K 2011-09-04 21:25 505f6baf2bd7001017b898f7b25b1cbb

pedro@pedro-laptop:~$ gedit * &

If the force is with you, is possible to find your missing files. I got the force with me and I restored the work of my day! 😀

Luck & thanks to Dani who helped me making this story have a happy end!

How to create a mountpoint trough SSH

For console addicted, accessing trough SSH to a server is a really common task. Under my point of view, usually console text editors like vi or nano are not the best option to work with a lot of files at the same time like we can do with any other graphic text editors.
So, I decided to make an internet search to try to find an application able to mount a SSH connection like a standard file system. The application is called sshfs, they didn’t think a lot to get the name 😛
In order to install it, if you use ubuntu, just click on sshfs or write the command below in a terminal:
pedro@pedro-laptop:~$ sudo apt-get install sshfs
Once installed, you only need this command to get it work:
pedro@pedro-laptop:~$ sshfs /media/ssh
  • user, is the name of the SSH user,
  •, is the name of the server (colon is required)
  • /my/directory, is the remote directory you want to mount, and
  • /media/ssh, is the local directory where the mountpoint will be placed
That’s all, you can now open the directory /media/ssh like any other local directory and open files with your favourite text editor 🙂

Change Gnome and Unity week start day

If you have installed the United States language version of Ubuntu, for sure you have your start week day set to Sunday, instead of Monday, at your calendar applet. There isn’t an option where the user can change this in an user-friendly way, and there are a lot of non-US users (like me) who are used to see the week starting by Monday. This little HOW-TO will show you the way to change it step by step.

  1. Open your favorite terminal application, and edit the file /etc/default/locale
    pedro@pedro-laptop:~$ sudo nano /etc/default/locale
  2. You will se one line containing LANG=»en_US.UTF-8″. Now you have to add the following lines, without removing the first one:

    Save the file and exit the editor. With these options, Ubuntu will display the time format in the english european variant, set the default paper size to A4 and set metrics for use with measurements.

  3. In order to start using the new configuration you should restart your graphic desktop manager. Just type this:
    pedro@pedro-laptop:~$ sudo /etc/init.d/gdm restart
Take care! Executing the last command will restart your gdm, and will close all running applications. So please, be sure to save your work before doing this.
Ubuntu Calendar Applet
Calendar starting on Monday