Tag: CLI

Subversion, Tortoises and Rabbits

I’ve been porting some old Windows & DOS code into the Linux environment. For anything other than the most trivial of software projects it is advisable to use some form of software version control. A good version control system will allow you to store ‘snapshots’ of the code base as you progress through the development cycle. You can go back to a previous version of a file (or even all the files in a particular build of your project) very easily, and you can do things like compare two different versions of the same file for differences. Your version control system should also handle branches in the code base and, although I’m working on my stuff solo, it should allow easy collaboration between team members who are working on the same software project.

Subversion is a well known and highly respected, free and open source version control system. It is often referred to as SVN. Because it is such a richly featured and powerful system there is a fairly steep learning curve associated with its use. Nevertheless once you have it mastered it more than repays that learning effort. Subversion is used by the likes of the Apache Software Foundation (who maintain it), Free Pascal, FreeBSD, GCC, Django, Ruby, Mono, SourceForge, ExtJS, Tigris.org, PHP and MediaWiki. Serious players.

Out of the box, Subversion is completely command line driven. Even for a CLI freak like me it is sometimes more convenient to drive Subversion through a GUI. As you would expect there are plenty of Linux front-ends for Subversion. I’d used an excellent Windows-based one called TortoiseSVN. TortoiseSVN provides a set of extensions to the Windows explorer that provide access to the SVN functionality and which could be directly applied to files and folders. I was cock-a-hoop to find a clone of TortoiseSVN for Linux, called RabbitVCS.

The easiest way to install Subversion is to use the Ubuntu Software Centre. Search for Subversion and install it. Simple.

Installing RabbtVCS is slightly more involved. You need to add the RabbitVCS repository to your system.Open a terminal and type:

sudo add-apt-repository ppa:rabbitvcs/ppa
sudo apt-get update

When you next open the Ubuntu Software Centre you will see a RabbitVCS entry in the left-hand pane. Highlight that and you will see a list of the RabbitVCS components that you can now install. I only use the Nautilus file manager and I don’t program in Python. The whole point (for me) of using RabbitVCS is to avoid using the command line, so I didn’t install the CLI, Thunar and Python modules. I do use Gedit though so I installed the Rabbit Core, Nautilus and Geany modules.

RabbitVCS entry in the Ubuntu Software Centre
RabbitVCS entry in the Ubuntu Software Centre

Now, when I right-click a file or folder there is a RabbitVCS entry in the context menu, with differing sub-menus according to whether the folder or file I have clicked on is versioned or unversioned, whether it is up to date in my Subversion repository and so on.

RabbitVCS Context Menu
RabbitVCS Context Menu

Subversion is great, Subversion with RabbitVCS is magnificent. You have access to the functionality you need when and where you need it – right in your editor and in the Nautilus file manager.

One final note – I couldn’t locate any decent RabbitVCS documentation, but as it is almost a 100% clone of TortoiseSVN, I downloaded a PDF of their user guide. It is close enough to be useful.

Tags : , , ,

Accessing a Shared Folder on a Windows PC

Some years ago a friend of mine asked me to go over to his house to help him set up access to a Windows PC from an Ubuntu one. To cut a long and frustrating story short, we tried everything we could think of for an entire afternoon and still failed miserably. It was with a heavy heart then, that I turned to that same task again today.

I wanted to have access to a shared drive on a Windows XP laptop. I was amazed to find the answer after only a short period of Googling. These are the steps that I needed. The laptop in question is on a workgroup, and there is no password – it just boots straight up. It is attached wirelessly to the same network that my Ubuntu box is cabled onto.

I created a folder called davetest on the laptop & shared with read/write access. I checked that I could see it and that I had read/write access to it from another Windows laptop just to verify that the share was working. It was.

On my Ubuntu PC I opened a terminal and typed:

sudo apt-get install smbfs

As I understand it (and I’ll gleefully admit I’m no expert in this) SMB (Server Message Block) is a network protocol used to access such things as printers and shares between network nodes. The smbfs package allows Linux to interact with the SMB protocol via the Linux file system (hence smb fs).

I had to create a folder on the Ubuntu PC in the media folder on which the remote share would be mounted:

sudo mkdir /media/laptop

I then had to edit the fstab file:

sudo gedit /etc/fstab

I added the following line to the bottom of the file (note that this should all entered on one long line):

//<IP Address>/davetest /media/laptop  cifs  guest,uid=1000,iocharset=utf8,codepage=unicode,unicode  0  0

<IP Address> = IP of laptop
davetest = name of shared folder on laptop
uid = The user ID of the user who will take ownership of the mounted files

Finally I used the mount command to mount the shared folder onto the Ubuntu file system at the /media/laptop location:

sudo mount -a

I received no error messages, so I proceeded to the first and simplest test:

ls /media/laptop

This listed the files in the shared folder on the Windows laptop. I experimented further and through the usual means I verified that I could copy files to the location, delete files and change files. The new file system location was accessible through the terminal windows and through Nautilus.

Windows Shared Folder in Terminal
Windows Shared Folder in Terminal
Windows Shared Folder in Nautilus
Windows Shared Folder in Nautilus

Makes me wonder what the deuce we were doing all those years ago, and why it was such an epic failure.

Tags : , , ,

Listing the Interfaces in Wireshark

As sad as it is, I had to bring work home the other night. I had some network packet sniffing traces to work through. There’s one tool that stands head and shoulders above the rest when it comes to this type of thing, so I installed Wireshark onto my PC. It is listed in the Ubuntu Software Centre.

I only had to analyse the traces, I didn’t need to do a new capture. I did still notice that the interface list in Wireshark was empty. This usually lists the network interfaces that Wireshark has found. You can then select the interface you want to do a traffic capture on and away you go.

Wireshark without Interfaces Listed
Wireshark without Interfaces Listed

As I say, I didn’t need to do a new capture so it didn’t affect me, but it left me wondering how you get the interfaces to show up in Wireshark in Ubuntu. The trick is to start Wireshark as a super-user. You can do this by opening a terminal window and typing:

sudo wireshark

You will then be prompted for your password.

Wireshark will then display all of the network interfaces it can find. Business as usual.

Wireshark with Interfaces Listed
Wireshark with Interfaces Listed
Tags : ,

The Hidden Easter Cow

Sometimes programmers add hidden functions or benefits in their software. These are called easter eggs.

Heaven only knows what’s going on here, but if you type the following into a terminal window:

apt-get moo

You’ll see the apt-get cow.

Go figure. Or go moo.

The apt-get Cow
The apt-get Cow
Tags :

Change Multiple File Names to Lower Case

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:

man rename

Tags :

Tree view in Terminal

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.

Output from tree
Output from tree
Tags : ,

Putting Aliases in the .bash_aliases File

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
. ~/.bash_aliases

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:

cd ~
gedit .bash_aliases

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 cls=clear
alias h.=history
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:

hf gedit

The result on my test machine is shown here. The commands that have gedit in them are listed with the gedit highlighted in red.

Output from the hf alias
Output from the hf alias

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.

Output from the pf alias
Output from the pf alias

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.

Tags : , , ,

Ready Made Aliases

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:

ls -alF



is the equivalent of having typed:

ls -A

And typing:


is the equivalent of having typed:

ls -CF

To see a description of what the various options for ls do, type:

man ls

You will see a display like this:

Output from man is
Output from man is

Use q to quit from the man session when you wish to return to the command prompt.

Tags : , ,

Decoding the ls -l Output

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.

Time Stamp
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.)

Tags : ,

Create an ISO Image from the Command Line

I needed to quickly create an ISO image from a CD I had. Here’s a speedy way to do it from the command line. Insert the CD and let it get mounted by Ubuntu.

Open a terminal. I like keyboard shortcuts so I do this by hitting:


Then type:

genisoimage -o <image you wish to create>.iso -R /media/<mount name>

Obviously, substitute your real names for the place holders in the example above. The -R parameter tells genisoimage to try to copy and preserve the file permissions and ownership data to the ISO image.

If you don’t have the genisoimage application installed, you can get it by typing:

sudo apt-get install genisoimage

Tags :