Month: May 2011
One of the things that held me back from adopting Ubuntu was the few Windows programs that I used a lot and for which I couldn’t find a Linux equivalent.
I know there are always going to be some specialist applications that are never going to be ported to Linux. The software that came with my Garmin SatNav, for example. It lets you upgrade the maps and so forth. Will that ever be ported to Linux? Frankly, there’s more chance of me being the next Pope.
I have an iPod and I have an Android phone. I wanted to sync music to both of these from my computer. In Windows I used to use iTunes for my iPod and Winamp for my Android. That was particularly slick, because there is a Winamp Android app. It allows you to synch between your PC and your Android phone wirelessly. How cool is that? Is there a Winamp app for Linux? Nope.
After a bit of Googling I saw that the Banshee music player could sync to both of these devices. It also plays videos, manages podcast subscriptions and allows you to buy music through Amazon or through the Ubuntu One Music Store. You can listen to internet radio, audio books and just about everything else I’ve thrown at it. It is a standard part of the Ubuntu 11.04 installation.
All this seemed too good to be true – but then I hit a snag. I couldn’t get it to sync to my Android, which happens to be a HTC Desire.
Eventually I found the trick. You need to create a text file called .is_audio_player. Put the following single line of text in it:
Copy that file to the root of your Android’s SD card.
Now when you connect it to Banshee you will see it listed in the devices section of the menu tree. The rest is straightforward and simple.
I’m working on porting an old DOS project to Linux, partly for fun, partly for nostalgia and partly as a learning exercise.
I copied all of the old source and header files to the Development folder of my Ubuntu box. I then noticed that every file name was in upper case. I wanted them to be in lower case. I guessed that there must be a command somewhere that would rename all of them in one go and leave them with the same name as they already had, but in lower case.
The rename command uses Perl behind the scenes, and with these command line options selected it does just what I wanted.
rename ‘y/A-Z/a-z/’ *
For more information, type the following into a terminal window:
I use the terminal windows a lot. Sometimes it is useful to see a tree view of your files and folders. To obtain a tree view for the command line, type the following into a terminal window:
sudo apt-get install tree
When you issue the tree command you’ll see an output in this format.
I backup at the end of each and every day that my computer has been used. You should too.
I prefer backups that move copies of my files onto the backup media in the same tree structures as the sources files were in, and copies them as plain files. This means they are easily accessible whenever and where ever I mount the backup media. If I want to copy some of my files on a different computer I can connect the backup drive to it and copy the files over using the OS. I don’t have to install the backup software on that other computer in order to perform a selective restore. After all, the other computer might be running a different OS, and have no access to the backup software that created the backup.
You can instruct most backup software to create backup ‘volumes’ where the backup is actually a catalog file (or a set of such files). A catalog file is a single file holding many of your backed up files in a compressed format within it. They may or may not be encrypted. There is a need and a purpose for this type of backup as well but for me, for my personal use, a simpler approach is best.
On Windows I used to use the excellent (and free) Cobian Backup. Amongst its many options were the ones that would make it perform the way I wanted my backups to be made, and it never failed me. So for me, it was perfect.
That covered the data. I also used to use the excellent (but not free) Acronis True Image. This was one of the few packages I used that wasn’t freeware or open source. It allowed me to take snapshots of my entire hard disk. In case of catastrophe I could restore the entire platter in one step. I would then restore my most recent data backup and I’d be back to where I had been before the disaster. It hauled my ass out of the fire on more than on occasion.
Making the effort to create the periodic images took time and a degree self-discipline, and restoring from them could take anything up to an hour on my system. Because my PC is pretty fast I can re-install Ubuntu in about 20 minutes, so I’m not planning on making images of my hard disk. If the worst comes to the worst I’ll format it, re-install Ubuntu and simply start again. It’s faster than re-imaging. There are some perfectly good Linux based equivalents of Acronis, such as Clonezilla, that would allow me to image the whole hard disk for disaster recovery, but I don’t think they would save me any time when it came to the crunch.
Of course, once I’d restored Ubuntu I would have to install any software I use that isn’t part of the base install, but even taking that into account I think imaging my machine is a thing of the past.
So all I had to do was find a backup application on Ubuntu that I liked, and that backed up the way I wanted. I’ve settled on the bizarrely named luckyBackup. That’s a lower case l at the start of the name. I must admit to feeling a little unsettled about using a backup program with the word lucky in its title, but it has been great. It is sufficiently flexible to allow me to set it up the way I want to use it, and it runs along at a great rate of knots.
The first backup obviously took some time, because everything had to be backed up. But subsequent backups only copy files that have changed or been created since the last backup, and the backups are over in the blink of an eye. You can install luckyBackup using the Ubuntu Software Center.
The luckyBackup application is is actually a front end to the rsync command.
To see the instructions for using rsync directly, open a terminal window and type:
I’m a command prompt man at heart, but just have a read through that and you’ll see why a simplified GUI front-end is sometimes a good idea.
What can I say. I’m old school. For me keyboard shortcuts are usually a lot faster than using the mouse. Many of these use the Super Key. This is the key that on most keyboards has the Windows logo on it.
Super Key Opens the dash.
Super Key (held down) Opens the Launcher and numbers the entries. Hit a number to launch that application.
Alt+F1 Opens the Launcher and allows you to use the Up/Down arrow keys to move the highlight from application to application. Hit Enter to open the highlighted application. Press the Right Arrow to show the Quicklist (if the highlighted application has one).
Alt+F2 Opens dash in search mode. Type the name of an application and it will provide suggestions as you type.
Super+A Opens up the application window from the Launcher.
Super+F Opens up the files and folders window from the Launcher.
Super+W Display all open windows. Click on one to have that application become the active window. Note that this shows all applications from all workspaces. If the window you click on is from a different workspace, that workspace becomes your working desktop.
Super+D Hides all windows. Repeating Super+D restores them.
Super+T Opens the bin.
Super+S Shows all workspaces. You can then drag windows from one workspace to another with the mouse. Click on the application or workspace you wish to work with.
Ctrl+Alt+T Opens a Terminal window.
Ctrl+Alt+L Locks the screen. Needs your password to get back in.
Ctrl+Alt+Left, Right, Up or Down Changes your working desktop to a different workspace.
Ctrl+Alt+Shift+ Left, Right, Up or Down Moves the current window to a different workspace.
F10 – Opens the first menu on top panel. This will be the menu of the active window (the application which has focus) or the default Ubuntu desktop menu.
This made me laugh. It’s from stickycartoons.com.
I was doing some more poking around in the .bashrc file in my home folder, and I spotted these three lines.
if [ -f ~/.bash_aliases ]; then
What these lines do is look in my home folder for a file called .bash_aliases. If it is found, the file is opened and the contents are read in. Effectively it makes the contents of the .bash_aliases file appear to be part of the .bashrc file.
Because the .bashrc file is executed each time you open a terminal window, anything you put in the .bash_aliases file is executed as well. And as the name implies, the idea is that you put your personal alias definitions in the .bash_aliases file.
By default there is no .bash_aliases file, but you can create one and add some entries to it by typing:
The first line makes sure you are in your home folder, the second opens the gedit editor and tells it to open a file called .bash_aliases. If no such file exists, it is created. These are some lines from my .bash_aliases file.
alias hf=’history | grep $1′
alias pf=’ps -e | grep $1′
The first alias sets cls to clear the screen. It’s just faster to type cls than it is to type clear. Likewise the second line. It’s fewer keystrokes to hit h. instead of history.
The hf alias is a bit more interesting. I use the history option a lot. hf makes it a bit easier to locate the command you want. For instance, to see the files you have recently opened in gedit, you could type:
The result on my test machine is shown here. The commands that have gedit in them are listed with the gedit highlighted in red.
The pf alias does the same sort of thing, but with process names instead of command names. You can use it to list all of the processes that have a certain word in their name. In the example below I have used the pf alias twice, once to list all the processes that have gnome in their name and once to list all processes that have unity in their name.
Note that when you have typed your aliases into the bash_aliases file, you must save the file, and exit the terminal session, and open a new terminal window before the aliases become available for use.
Remember, because the .bash_aliases file is a dotfile (its name starts with a full stop), the .bash_aliases file will not be listed when you use the ls command.
To see dotfiles you have to use the the -a or -A parameters, or use the la system-provided alias.
If you go poking around in the .bashrc file, located in your home folder, you’ll see the following lines:
alias ll=’ls -alF’
alias la=’ls -A’
alias l=’ls -CF’
These provide some ready made aliases for you. Alisases take commonly used commands and provide abbreviations for you so that you don’t have to type the original command in again and again.
For example, if you type:
in a terminal window Ubuntu will treat it as though you had typed:
is the equivalent of having typed:
is the equivalent of having typed:
To see a description of what the various options for ls do, type:
You will see a display like this:
Use q to quit from the man session when you wish to return to the command prompt.
ls has many options. One I use a lot is:
This gives a long listing of files and folders. Here is a single line of an example output from ls -l:
drwxr-xr-x 2 dave dave 4096 2011-05-22 21:44 Shutter Caps/
The first character represents the File Type. In the example above the d indicates that this is a folder. The possible characters that could be used in this position, and their meanings, are as follows:
d = directory (folder)
– = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file
The next 9 characters represent the permissions for the file or folder. There are three sets of 3 symbols, or triplets. The first triplet represents user permissions, the second triplet represents group permissions and the final triplet represents permissions for other (as in all other users). The three characters in each triplet represent the read, write and execute permissions for that triplet.
r = read permission
w = write permission
x = execute permission
– = no permission
In this example, rwxr-xr-x indicates read-write-execute permission for user, read and execute (no write) permission for group, and execute only permission for others.
The rest of the line is made up of a number of fields.
Number of Links
In this example, 2 indicates there are two links to this folder.
In this example, this folder is owned by the user named dave.
In this example, this folder belongs to the dave group.
In this example, 4096 indicates the size. Note that this is not the same as the amount of data in the folder. It shows the size of the internal representation of a folder within the Ubuntu file system.
The date and time of the last modification of the folder. In this example, 2011-05-22 21:44 indicates the folder (actually, its contents) was last modified at 9:45pm, on 22nd May, 2011.
The name of the folder. In this example, the folder name is Shutter Caps. (This happens to be where I have Shutter store any screen captures I take.)
Whenever you open a terminal window a script file called .bashrc is run. This establishes certain settings within your terminal environment.
In your home folder, if you type:
You will see the contents of this file listed to the screen.
To stop the output whizzing past in a flash type the following:
cat .bashrc | less
This will allow the less program to handle the output. You can then scroll backwards and forwards through the contents of the file using the Home, End and Up Arrow and Down Arrow keys. Q will exit back to the prompt. This is a convenient way to examine text files safely – there is no danger of you accidently making changes to them.
Within the .bashrc file are some lines that look like this:
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
if you want to have a colour prompt in your terminal windows, in your home folder type:
This causes the gedit editor top open the file so you can make changes to it. Be Careful! Change the line that said:
to now say:
Save the file, and close gedit. Close the terminal window and open a new terminal window. I use keyboard shortcuts a lot, so I do this through:
You should now see a colour prompt.
It’s not life-changing perhaps, but it helps to visually distinguish the output from the shell prompt.