Linux Infancy 2
Okay, so you’ve downloaded Ubuntu or some other variety of linux - commonly referred to as flavours, builds, or distributions - and want to install some program you found on SourceForge (a huge internet repository of open source software by nerdy people with a lot of programming talent - sometimes - and obviously a lot of spare time). Now installation can be a problem if your built-in package manager (the module that pops up when you click the add/remove button in your “start” menu) doesn’t handle that particular application. More complications can arise if they haven’t provided you with something called the binary version. Binaries are just packages of source code that have been compiled and are ready to install out-of-box. In this post I’ll go over installing a binary package and then next time move onto the source code installations.
If you’ve been given the binary version of some piece of software then you can install it on your Ubuntu system by navigating to the folder you downloaded it into and running one of a few different kinds of commands that either actually installs the software into your system or runs the software from the folder you downloaded it into. Briefly, the way to do this is as follows;
1. open a terminal window then type
cd /directory_string/name_of_downloaded_file
Where cd is a command that stands simply for ‘change directory’ to whatever you type after the ‘/’. The highest level of directory (or most basic if that makes more sense) is just called ‘File System’ by default which is like a Windows ‘C’ Drive. Most of your activity, if you’re a basic Ubuntu user, will occur in folders within the /usr/ folder. It is important here to understand that directory_string should be something like this;
/usr/local/share/
…etc if that’s where the program you’re installing is located. Moreover, it is important to ensure you type the name of the program exactly as it appears in the file system. Sometimes your downloads will be in your user folder, in which case it will look something like this;
/home/your_user_name/Desktop/
…etc if you downloaded it somewhere in a folder on your current Desktop. The best way for a windows ex-patriot to find the string is to click the ’start’ button on your desktop. Then, open the ‘places’ folder and navigate as you would using Windows Explorer to the place where you downloaded the files. At the top of the file explorer module will be a series of buttons that begin with the first folder you entered from (e.g. usr) and will end on the right with the current folder you are in. It’s a handy way for you to navigate around since you can click any of those buttons and be transported back to that particular folder. So, for navigating within the Terminal window you just have to place ‘/’ between each of the those folder names beginning with a ‘/’ before the first folder and not necessarily ending with a ‘/’ unless you’re also going to identify something within the last folder (like a program or file you want to manipulate). A handy location string short-cut is ‘~’ which, when placed before the first ‘/’ in your string, indicates the current user directory. So, if you wanted you could replace the following long folder path;
/home/your_user_name/Desktop/
with the following short cut;
~/Desktop/
Now that you’ve navigated to the folder with your download in it, you can take a look inside the package with or without ‘extracting’ it first. The command dir at the Terminal window prompt will show you the files in the folder you are currently in. Notice that you’ll know what folder you’ve navigated to because the location is given before the prompt in the Terminal window. You can also just use the GUI (Graphical User Interface) or Windows like file system explorer (Windows Explorer) like you did to find the file path in the first place. Inside the package will be a bunch of folders and files that you really don’t need to know anything about at this point except that there will also be a document (Word Pad looking opened with a Text Editor) called README.doc or possibly Install.doc that will contain specific instructions on installing that binary including additional ‘libraries’ that your system might need. I’ll deal with libraries next time as well. So, follow the instructions for installing provided and you’re probably good to go. The README file will likely also contain instructions for ‘extracting’ or ‘unzipping’ the compressed package. You can do this in a few different ways and the Ubuntu Linux distribution contains a number of pieces of software for this purpose. The most commonly used is tar. The end of the file name of the package your trying to install likely looks like this;
somepackageidownloaded-4.5.3.2.1.tar.gz
the important part to understand right now it the tar.gz. That file extension means that the package is compressed using tar and can, therefore, be uncompressed/unzipped/extracted using the same. the file system GUI approach will determine all of this automatically if you right click and select extract to here from the context sensitive menu. On the other hand, you can extract the files from the Terminal prompt - as long as you’re in the folder that contains the package- by using the following;
untar -xvf somepackageidownloaded-4.5.3.2.1.tar.gz
Be sure to read through all of the manual pages for any command you haven’t used before to ensure that the options you select for that command (also called flags) are doing what you want them to. The flags can be in any order and follow the ‘-’ but generally come before whatever file you want the command to alter. Then you can look in the file again for files with extensions like .pyc and .sh. The .pyc file likely won’t run, but it’s program code created with a language called Python. The .sh is the key since that’s like the Windows .exe files. Try simply entering the file name with the .sh extension in the terminal window and see if it runs. If that doesn’t work have another look at the INSTALL and README documents. If all of that fails you can also use file system explorer if you’re more comfortable using the GUI. Look for a little diamond shaped icon with some gears in it with your filesystem explorer. Try double clicking it. If that runs the program then it can be run from the Terminal prompt as well, all ‘out-of-box‘, right from the folder you downloaded the package into by entering the file name of whichever gear icon file actually worked into the terminal prompt.
So, with any luck that will save someone some damn time when trying to install programs. There’s more to it and more ways to install things which I’ll get into next time.
Posted in Technology |
March 7th, 2008 at 2:14 pm
I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.
Stacey Derbinshire
March 7th, 2008 at 6:00 pm
Just to add my 2 cents, a .tar.gz file isn’t actually compressed with tar. Tar itself just takes a list of files and turns it into 1 file, often referred to as a “tarball”. The tarball is then compressed by gzip (hence the .gz), or sometimes bzip2 (.bz2). So it’s generally a collection of files that’s been rolled into a tarball, then compressed with one of the 2.
tar -xzvf will handle tar.gz ones
tar -xjvf will handle tar.bz2 files
..
Another thing to note would be that a unix system’s PATH variable doesn’t often contain “.” (current directory) by default. So when trying to execute a file that is in the directory you’re in, but that directory isn’t part of the PATH variable, you need to toss a “./” in front of it.
ie ./configure, ./script.sh, ./runmyassnowbiotch, etc