Friday, 29 June 2012

10 Nautilus tips and tricks

Nautilus is the file manager for Gnome. Gnome is a GUI for many Linux distributions and it is my favourite so far.

A file manager is the program that manages and lets you access your files. In plain words, it is the window with folders and stuff in it. Knowing how to use it properly can let you save a lot of time (unless you want to use the terminal, which could be even faster), so here is a list of a few tips and tricks to improve your file managing experience!

You can open a new window from terminal (if you have Gnome) with the command:

nautilus &

1. Change default "Open with" program for an extension

A quite common problem is the one of changing the default program with which a file is opened. If you have a Windows background, you'll endlessly search in the "Open with" from the right-click menu, but you will not find the answer there. Fortunately, the solution is easy:

-   Right-click on file with interested extension
-   Click on "Properties" at the bottom of the menu
-   Go on the "Open with" tab
-   Select wanted application and click on "Set as default"

Now the application you selected will be used by default as main application to open the files with the same extension with a double-click.


2. Multiple Panes in one window

Sometimes we want to move files from one folder to another and it would be convenient to have both folders somehow open in the same window to ease the transfer. This is possible!
In a window, just press the F3 button and a new pane will appear (initially with the same folder showing to both frames). You can switch from a pane to another just clicking on the wanted frame.


3. Select items matching a pattern

If you want to select multiple files with a certain name only or, say, with the same extension, there is an easier way rather than doing that manually!

Press Ctrl+S in a window and a dialog will open asking for the pattern. You can use the power of wildcards in this window!

The wildcards you can use are * and ?. Their working is very simple. Whenever the find program sees a *, it substitutes any random string in it. Basically, if you type just: * . It means everything.
For the ? wildcard, instead, it will replace only one character. Then, typing ????? will match any string containing 5 letters or numbers, including the extension.

It should be now clear how powerful can it be using wildcards for selecting files. I will provide a few examples:

*.jpg
Will select every file with extension .jpg, i.e. every image in a folder.
*2012*.jpg
This, instead, will select every picture in the folder containing 2012 in its name (note that *2012.jpg will only look for pictures having 2012 at the end of the filename, and viceversa for 2012*.jpg).
*.*
This will select all files (while * would also select folders).
???.*
This will select any file that contains 3 characters, such as lol.jpg or asd.txt.


4. Move, Copy, Link

You can use the click-and-drag options also present in Windows under Nautilus:

-   If you click and drag files without pressing any additional key, it will chose what to do depending on the destination. It will move files if the destination is local (same hard disk) and copy if the destination is not on the same File System (external drive).
-   If you click and drag pressing the Ctrl key, it will copy the files in any case.
-   If you click and drag pressing the Shift key, it will move the files in any case.
-   If you click and drag pressing both the Ctrl and Shift key, it will create a (soft) link to the files.


5. Move windows from anywhere

For users with low resolution screen, it may happen that some windows have the title bar (to move it) outside the borders of the screen.
This is quite annoying and it may be even impossible to close it, as the X button is hidden.
In order to move the Window, though, you can keep pressed the Alt key and left-click anywhere inside the window to move it!


6. Resize windows from anywhere

Similar to the previous one, but press Alt and middle-click with your mouse to resize the window without having to hunt for the border!


7. Run common scripts with one click

Nautilus has a default script folder in which you can put your bash scripts and run them by just selecting them (e.g. a script to remove files older than a certain date, or a script to clean the name of the selected files... you can really use your imagination here).

This is extremely useful and you can either download bash scripts or make your own. You just need to right-click and then select the "Scripts" menu, then the script which you want to run. You may find the script folder empty, initially.

In order to add your scripts to the list, you need to put your scripts in the scripts folder for nautilus. You can open it clicking on "Open scripts folder" from the same "Scripts" menu, but it is usually located in ~/.gnome2/nautilus-scripts


8. Quickly check number and size of multiple files

If you need to quickly know how big is a collection of files, it will be necessary to select them and check the bottom right corner of the folder. The number of the files selected, together with their total size is displayed in a pop-up balloon.


9. Keyboard shortcuts

This is a list of shortcuts to quickly perform the underlined actions. For some of them (e.g. Rename) you need to highlight a file first.

Rename: F2
Create new folder: Shift+Ctrl+N

Cut: Ctrl+X
Copy: Ctrl+C
Paste: Ctrl+V
Select All: Ctrl+A
Invert Selection: Shift+Ctrl+I

Add to Bookmarks: Ctrl+D
Search for Files: Ctrl+F

Move to Parent folder: Alt+↑
Move to Selected folder: Alt+↓
Move back: Alt+←
Move forward: Alt+→


10. Gnome 3 window tricks

This tricks will work only with Gnome 3.

Expand window: you can double-click on the title-bar to expand a window in any Gnome, but with Gnome 3 you can drag the title bar and push the window to the top to automatically expand it.

Divide screen between two windows: drag the window from the title bar and push it to the left (or right) to expand the window to half the size of the screen.

Open the activities: without clicking, push your mouse to the top right corner. This will open the "Activities menu".



Problem with the avahi daemon during the boot

A small reminder that I'm still alive plus a problem that almost scared me today (technologically speaking).

My Fedora 11 did me a trick and after an "apparently normal" shutdown yesterday, the avahi daemon failed during the boot hanging it on the login page (background image missing and plenty of error messages about the fail installing the daemon).
There were no ways to log in since after entering the password the laptop would have got stuck in an infinite loading machine. The other terminals (Ctrl+Alt+F2...) worked well.

What I did was then load the live cd and search for help over the internet being prepared to backup and re-install Fedora.
There weren't almost any hint on the web on how to solve this problem, if not for some issues with wireless cards, but nothing similar to my problem that completely blocked me from opening my GUI. I was lost.

Looking at these problems, anyway, enlightened me on how effective is the log system in Linux and the common suggestion to solve problems was, first of all and always, looking at the log in /var/log/messages, that is a record of everything Linux does in background or not.
That's how, after few minutes of searching and reading, that I stumbled upon this line:

Nov 23 09:49:01 acer avahi-daemon[1290]: write(): No space left on device
Nov 23 09:49:01 acer avahi-daemon[1290]: Failed to create PID file: No space left on device


That's even too clear. What seemed a serious problem on some damaged part of my distro was, instead, a problem of carelessly leaving the hard-disk with few bytes not even sufficient to start Gnome.

Deleting some files to free some space through terminal or using a live cd was enough to bring Gnome fully working again!

This is just to prove that sometimes problems that seem too complicate, can be solved just looking at a description of what is going on in the machine, given in detail by the machine itself.
Such an elegant service must not be wasted googleing the problem without mercy but, in most of the cases, "problems" can be solved locally using logs, man pages and your brain.

Hope I've learned the lesson!


Edit: thread found on fedoraforum.org (that is an excellent support forum, anyway) about a similar issue.

Problem with Grsync and (partial) remedy


Grsync screen
I seize the opportunity of a recent problem with Grsync to talk about it.

Grsync is an useful GUI for the command rsync.
This command is very powerful, since it synchronizes two folders that can be on two different machines, or the same machine. Usually, if on the same machine, rsync is used for backup purposes.
Grsync provides a lot of options to make synchronizations and backups and is really user friendly: it only needs source and destination folders and some options to be set.

The synchronization consists in making the destination folder equal to the source folder.
This is a very common task, since it is common that a folder on a usb stick is used on other PCs and then we want to copy this folder on the PC at home. Copying the entire folder every time will be a slow method, especially if we are handling with gigabytes of data! Copying the files one by one requires a lot of memory and patience. Grsync requires just one click to identify (there are different methods that I will not list, for now) the differences between the two folders and copy only the files different, saving time, memory (human in this case) and cpu.


The usage is very simple: source and destination paths in the relative space and a few options; I'll explain the main ones, but a mouse roll-over the option gives a sufficient explanation of the option:
- Preserve time/owner/permissions/group: the destination files will have respectively the same modification time, the same owner (be careful, this is only a super-user option... in doubt un-tick it), the same permissions on the files (read-write-execute) and the same group.
- Delete on destination: makes a perfect synchronization, since file deleted in the source folder will be deleted also in the destination folder. Essential to have a faithful copy of the source, but to un-tick for incremental backups.
- Verbose: every deleted and copied file, error or message in general will be reported.

The next step is installing it! In Fedora you can use yum from a terminal:

sudo yum install grsync

or download and compile it from the official website.


---


Now let's focus on the problem: Grsync is not working now.
Why?
A conflict (maybe) with the gtk+ update (you don't need to know what gtk+ is, but if you really want... here).
Apparently, the new version of gtk: gtk+2.0-2.16.6 is not letting work grsync 0.9.1. The symptoms are different:
- Grsync window that won't open, but will be silently running in the processes.
- Message error, if grsync is run from terminal:

(grsync:#####): Gtk-CRITICAL **: gtk_combo_box_append_text: assertion `GTK_IS_LIST_STORE (combo_box->priv->model)' failed

repeated for how many grsync sessions are defined.
The problem has been discussed and there isn't still solution as reported here.
I absolutely don't have the solutions for this problem, since my beginner abilities could only help someone to explain or discover new cool programs as in this post.
Anyway, I've got two remedies, until someone find a radical solution to the problem.


The first remedy is pretty lame... but necessary if you want to stick to the program: a downgrade.

If you installed grsync with yum, that's very easy to do:

yum downgrade grsync

and it will downgrade grsync to the older version (0.6.3-2) that is working with the gtk+ update.


The second remedy is much more cool: using directly the rsync command in a terminal.
Rsync has a very easy syntax:

rsync [options] [source] [destination]

and it features a huge number of options. Check out the man pages to know more about this splendid command.
To automatize backups, you can also create a script. This is a BASH example that I use (I'm a BASH beginner too :D):

#!/bin/bash
#
# Syncronize using rsync "src" folder on the PC (source) with the "dest" folder
# on the stick (destination).
#

echo "Starting..."
rsync -vrlpEogth --delete --progress /home/user/src /media/usbstick/dest
exit


I'll introduce BASH and scripts in another post if you're not familiar with that.


That's all for now.

See you soon!


*** UPDATE ***
Thanks to the developer Piero Orsoni, the new version of the program, Grsync 0.9.2, is now full-working.
The version will be soon available also in the repositories.

Welcome!

Welcome to grep Linux!

This blog is one of the two daughter websites of the original Pepe Blog (now closed). I was writing about Science and Technology randomly, but over time, I switched my OS to Linux Fedora and got really into it. That resulted in a copious amount of blog posts about Linux and my experience using it.

That was getting readers confused and for this reason I decided to split the original blog into two blogs, one treating Linux in full and the other (Bad Scientist) about Science and various geek stuff.

I will post about cool news, tips and tricks on Linux, and various problems (with solutions) which I encountered in the perilous journey of working under a Linux OS. This blog is meant to be for beginners which have already some knowledge of a UNIX OS workings.

Thank you for reading,
Giulio