Sign In

    Enjoy FOSSwire's content? Have it delivered! Subscribe

    Mastering APT

    Chances are, if you use Debian, Ubuntu, or Freespire, you've heard of it: APT. But what is it?

    APT stands for Advanced Packaging Tool, and was developed for the Debian Linux distribution. Basically, it allows you to install anything supported on your system with one line in the terminal.

    Most people prefer to use a GUI for this type of thing. Many APT-based distributions also have a GUI for installing and removing applications. This usually is Synaptic. Many other GUI's are also derived from Synaptic: The Update Manager and Add/Remove applications both use it as a backend.

    APT, unlike a vanilla RPM distribution, uses things called repositories to find packages you can install. Many of them are turned on by default in a distribution. You can add more yourself, as well as disable any that you don't like.

    Most of the time, you can manage your software by using Synaptic, Adept, or another GUI. But what if you boot your system in failsafe mode, and there isn't one?

    That is where apt-get, the brains behind everything else, comes in handy.

    (Note: This tutorial will not take into account any sudo's or su's that you will need to use in commands. To run these commands as-is, you will be need to be in recovery mode, logged in as root, or you may prefix every command with sudo.)

    First of all, let's start with a basic command: updating the repository list. Every time an update is released or you make a change to your repository, you will need to run this command:

    apt-get update

    The tool will look at your sources, and download them from the servers to check for updates. To upgrade your system, however, requires a different command:
    apt-get upgrade

    Make sure you do not get the two confused: update refreshes the list of software, upgrade downloads and installs all upgrades available.

    Now, let's say you want to install XChat. Commonly, packages can be found as their name in the repository, so the following could be used:

    apt-get install xchat

    A quick sidenote: If for some reason you want to reinstall a package, just run the install command again as usual.

    The install command for the most part is straightforward. But, what if you did not know the exact name? That is where the tool apt-cache comes in.

    apt-cache search xchat

    will search for all programs with the name or description of XChat, at which point you could then install.

    If you decide you do not like XChat, you can remove it as easily as you installed it:

    apt-get remove xchat

    You now have the skills to survive in the wild world of the terminal to install any program you want. Install responsibly. ;)


    Unix fundamentals - mount points

    Today, I'm going to introduce the concept of mount points. Mount points are, in essence, folders in which external filesystems are mounted (their contents are dropped into that folder). We'll be going into that in a bit more detail in just a second. First of all, the obligatory Wikipedia definition:

    A mount point is a term used to describe where the computer puts the files in a file system on Unix-like systems. For example, many modern Linux distributions automatically mount the CD drive as /mnt/cdrom, so the contents of the CD drive will appear in the /mnt/cdrom directory. A device can be mounted anywhere on the directory structure. Normally only the root user can mount a new file system but systems are often configured so that users may mount pre-set devices. A file system can be mounted by running the mount utility.

    Windows, OS/2 and other operating systems that have their heritage in DOS and the old days of the IBM PC, use a drive letter structure to access different devices on the system. I'm sure you're aware of the idea of the C drive under Windows.

    Well, Unix-like operating systems don't work anything like that, I'm afraid.

    Let's have a quick example. I've got a 512 MB USB stick and I plug it into my PC running Linux. Behind the scenes, the operating system does the following:

    • Creates a folder called /media/PETER512 (PETER512 is the volume name of my USB stick).
    • Mounts the USB stick's contents inside this new folder

    Fairly simple. So what does it actually do when it mounts the contents? Think of it as taking the contents of the device and dropping them into that folder. Now, if you browse to that folder, you can read and write the contents of the actual device, just as if it was a normal folder on your hard drive.

    The folder (which is the mount point - the point where that device is mounted) can be anywhere, but it's a convention that you use /media or /mnt. Equally, it doesn't have to be a USB stick. CDs, DVDs, network drives, removable hard drives, even .iso image files, can be mounted so you can access them and interact with them.

    And finally, a quick command line practical exercise. You will need to know the device string of whatever you want to mount, which unfortunately makes this process a bit geeky and difficult. In this example, I'm using /dev/sda1 (which is what most USB devices are if you have IDE hard drive).

    In most cases, you also need administrator/root privileges to mount and unmount.

    # mkdir /mnt/mymountpoint
    # mount /dev/sda1 /mnt/mymountpoint

    When you're done, you can unmount the device with umount (optionally, you could also rmdir the folder if you don't need it).

    # umount /mnt/mymountpoint


    The differences between the GPL, LGPL and the BSD

    There are a lot of different open source licences out there, and it can sometimes be a bit confusing if you're not intimate with the details of each one. So here's a quick roundup of three of the most popular licenses and the difference between them.

    Just a quick disclaimer - I'm not a lawyer, so don't depend on my explanations on the licences here. All the usual disclaimers apply.

    GNU General Public Licence

    The GNU General Public Licence, or GPL as it's often called, is the most popular free software licence and it's used by many different projects, including the Linux kernel, the GNU tools and literally hundreds of others.

    You can find the legal text for the GPL here, but here's a quick summary of what it means.

    Basically, you're allowed to use, redistribute and change the software, but any changes you make must also be licensed under the GPL. So that means you have to give everyone else the same rights as you got. Fair's fair, right?

    There are also other restrictions and there's quite a nice human-readable version at the Creative Commons site.

    The GNU Lesser General Public Licence

    The LGPL is similar to the GPL, but is more designed for software libraries where you want to allow non-GPL applications to link to your library and utilise it. If you modify the software, you still have to give back the source code, but you are allowed to link it with proprietary stuff without giving the source code to all of that back.

    Again, there's a nice friendly look at this on the Creative Commons site.

    The BSD Licence

    In contrast to the GNU licences, the BSD licence is very permissive. Used originally by the BSD operating system, it covers a fair amount of software.

    The BSD basically says "here's the source code, do whatever you want with it, but if you have problems, it's your problem". That means you can take BSD'ed code and turn it into a proprietary application if you so wish - there's nothing saying you have to give the code back (although it is nice to do so).

    The BSD licence is very small because it is so simple, and often looks like this:

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of the [[whoever]] nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    There are also several other licences (the MIT for example) that are similar in spirit to the BSD.

    Obviously, that's not all the licences - there are plenty, and developers choose them for different circumstances. Some are restrictive, but preserve the free-ness of the code like the GPL, and some are much more permissive.

    The Free Software Foundation call the GPL-style restrictions (you must release any modifications under the same licence) 'copyleft'. Mr Stallman himself has an essay about this and other issues on the GNU site. Bear in mind though, this article does push Stallman's personal views on software licences quite heavily. Take with a pinch of salt if necessary.


    1. 1
    2. 2
    3. 3
    4. 4