Archive

Posts Tagged ‘linux’

Holy Wars, aka Vi vs Emacs

March 29th, 2010 No comments

As a long-time Windows user, there was always something which confused me when it came to learning my trade on Linux based systems – the sheer amount of choice in apps on offer to fulfill a single task. Which leads me on to the next thing – the nigh-on-religious wars which have erupted around these apps.

Case in point: text editors. When I first went to edit a file in a pure Linux text console, I thought I would try out vi. When I found my head spinning after just a few minutes of trying to edit one line of a config file, I gave up and tried emacs. When I got overwhelmed by the sheer amount of stuff bolted into the text editor, I thought that I would go for the Linux text mode equivalent of Notepad, nano. I edited the file and moved onto the next thing I had to do.

But it really got me thinking. There is always a place for an alternative application in a given area – vi and emacs both do the same thing (edit plain text) but offer 2 very different ways of doing this, and both are highly configurable and so on and so forth. But what this doesn’t explain is the vitriolic debate which springs up around the users of each.

You don’t see this on other platforms – Windows users typically have to put up with Notepad until they discover something like Notepad++ and OS X users have Textmate (which seems to be very popular on that platform). However, you don’t get the users of UltraEdit insulting the entire families of those who use Notepad++. You don’t get arguments which have raged for 20+ years. In short, its all a bit more civilized.

So I get to my point – out of all these text editors on Linux, which one do you use and why? Functionality? The way the app looks? The price (or lack of it)?

Categories: Unix/Linux Tags: , , , ,

Installing SVN With Web Access Through Apache On Ubuntu

April 1st, 2009 2 comments

Getting started with SVN on Ubuntu takes only a few minutes, and enabling web access to the repository is also very straightforward.

First (in order to actually serve the files) you need to install Apache, open up a terminal window and run the following command. This will ensure that Apache is installed if you unselected it for some reason during the install.

sudo apt-get install apache2

Note the use of the sudo command. This will run the command you give it as a super user as normal users will not generally have access to install software like this. When you use sudo you will be prompted for the super user password. Next, use the following command to install SVN.

sudo apt-get install subversion libapache2-svn

You can now create your subversion repository, it is best to keep all of our repositories under the same directory so that things don’t get confusing in the long run. To create the SVN directory run the following.

mkdir svn

The following will create the repository in the directory /svn/myproject.

sudo svnadmin create /svn/myproject

Now we will need to edit some of the settings in our Apache SVN module. Use the following command to edit the correct file.

sudo gedit /etc/apache2/mods-enabled/dav_svn.conf

When you first open this file it is all commented out. You first need to uncomment the Location. This is the directory where subversion will be available from on the Apache side. Here I am setting this to svn so that when I navigate to http://127.0.0.1/svn I will see the correct output.

<Location /svn>

Note that you must also uncomment the closing location tag at the bottom of the document!

Uncomment the DAV line to enable the repository, this enables the DAV module.

DAV svn

If you have a single repository then then enable the SVNPath setting. However, if you have multiple repositories then enable the SVNParentPath setting. this will point to the main directory where your repository (or repositories) is stored.

SVNParentPath /svn

That’s about it really, but as a further step lets enable some sort of authentication. You will need to uncomment the following lines (which are grouped together).

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd

And the following line.

Require valid-user

Now, before we restart our Apache server and enable everything you have done we need to setup a username and password for the authentication to work. Use the following command to create a user and assign a password.

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd user

If this doesn’t work then try using htpasswd instead of htpasswd2. You should be prompted to enter your password twice and then receive a message telling you that the user has been created. Note that you should only use the -c option when you create a user for the first time because it creates the password file even if it is already there. If you use this option again in the future you will destroy any other users you have created. Instead, simply drop the -c and use -m on its own which causes the password to be MD5 encrypted, but will not recreate the file.

You can now restart the server by entering the following command.

sudo /etc/init.d/apache2 restart

You might initially try a short cut and do something like the following:

sudo apache2 restart

However, this will not work as the script in /etc/init.d/apache2 explicitly reads some environment variables that are important when starting the server.

You can now go to your subversion directory and see the following:

SVN Web Access

SVN Web Access

You will also see an authentication window appear, just use the username and password you set up before.

You now have a fully working subversion server with web access.

Categories: Apache, Unix/Linux Tags: , , , , , ,

Using !$ To Use Last Parameter

July 22nd, 2008 No comments

Much like using Alt+. to print out last parameter you can also use !$ to use the last parameter from the previous command. Here is a simple example.

# cd ..
# cd !$

In this example we are moving up a directory and then doing the same action again, the !$ is a short cut to get hold of the ... This is more useful when doing things with longer parameters like directory or file names. For example here we are creating a directory and then moving into that same directory.

# mkdir /www/htdocs/directory/
# cd !$

Categories: Unix/Linux Tags: , , , , ,

Raising Skinny Elephants Is Utterly Boring

July 21st, 2008 No comments

This might sound odd, but this is a mnemonic that helps you remember a sequence of letters that you can enter when your Linux system is locked. This is a last ditch attempt to get things up and running again and should only be used if all else fails and the only other thing that you can do it pull the plug.

If you have also tried pressing Ctrl+Alt+backspace and this does nothing then you can try using the key sequence Raising Skinny Elephants Is Utterly Boring.

Hold down the left Alt key and the SysRq key (found on the print screen button) and press each letter in turn. Make sure that you give a little time between keystrokes.

  • r
  • s
  • e
  • i
  • u
  • b

Here is a description of what you are doing.

  • The r stands for put keyboard in raw mode
  • The s for sync the disk
  • The e for terminate all processes
  • The i for kill all processes
  • The u for remount all filesystems read only
  • The b for reboot the system

Also , if your filesystem is Ext3 or ReiserFS and on reboot it wants you to do a filesystem check, don’t touch any key when it asks you to press "Y" and let it recover the journal automatically.

Also note that for this to work you need to have the SysRq key enabled in the Linux kernel, also called CONFIG_MAGIC_SYSRQ. You can check if it is enabled by typing:
ls /proc/sys/kernel/sysrq
If this prints out a line with that word then the key is enabled.

Use Alt+. To Print Out Last Parameter

June 27th, 2008 No comments

A handy trick when using a Unix/Linux system is to repeat the last parameter from the previous line. Lets say that you typed in the following line to move a file to another directory.

$ mv file.txt /usr/local/

To then move into that directory you can just type cd and Alt+. to copy in the last parameter used in the last line. This will put the following on the command line.

$ cd /usr/local/

You can press Alt+. multiple times to go back through your parameter history. Note that it only records the last parameter used for each line. So for the example above, if you pressed Alt+. twice you would get the last parameter of whatever command you executed before moving the file.

Categories: Unix/Linux Tags: , , , , , , , ,