Snott

Blog

  • Understanding the Linux Directory Structure

    Understanding the Linux Directory Structure

    Folder Icon

    I am pretty sure sometime you have asked yourself “where do that program I just installed went to?” you can access the program no problems, but you have no clue of the directory where it got installed, well, maybe with a little more understanding of how Linux handles directories you should be able to find it.

    I will post here some explanations of the directories and what they store, and then you will get a nice image resuming this, the image it’s very useful and self-explanatory and could help you learn the structure faster.

    /

    The root directory. The starting point of your directory structure. This is where the Linux system begins. Every other file and directory on your system is under the root directory. Usually the root directory contains only subdirectories, so it’s a bad idea to store single files directly under root.

    Don’t confuse the root directory with the root user account, root password (which obviously is the root user’s password) or root user’s home directory. You need root permissions to write to this folder, in fact, you need root permissions to access any folder on the system different from your home directory.

    /boot

    Pretty self-explanatory,  this is the place where Linux keeps information that it needs when booting up, that is, the Kernel used for booting and your bootloader, be it GRUB or LILO. If you list the contents of /boot, you’ll see one or more files starting with vmlinuz – those are kernels.

    You should be very carefull when you do anything to this folder, if you don’t know what you are doing you might render your system unbootable, as a rule of thumb, it is highly recommended to have this folder on a separate partition from the rest of the system.

    /etc

    The configuration files for the Linux system. Most of these files are text files and can be edited by hand. Lots of user installed applications store the configuration files here. There are a lot of files here, some of the most useful are:

    /etc/inittab
    A text file that describes what processes are started at system bootup and during normal operation. For example, here you can determine if you want the X Window System to start automatically at bootup, and configure what happens when a user presses Ctrl+Alt+Del.

    /etc/fstab
    This file contains descriptive information about the various file systems and their mount points, like floppies, cdroms, even network shares that you want to mount at boot.

    /etc/passwd
    A file that contains various pieces of information for each user account. This is where the users are defined.

    /bin, /usr/bin

    These two directories contain a lot of programs (binaries, hence the directory’s name) for the system. The /bin directory contains the most important programs that the system needs to operate, such as the shells, lsgrep, and other essential things. /usr/bin in turn contains applications for the system’s users. However, in some cases it really doesn’t make much difference if you put the program in /bin or /usr/bin.

    /sbin, /usr/sbin

    Most system administration programs are stored in these directories. In many cases you must run these programs as the root user.

    /usr

    This directory contains user applications and a variety of other things for them, like their source codes, and pictures, docs, or config files they use. /usr is the largest directory on a Linux system, and some people like to have it on a separate partition. Some interesting stuff in /usr:

    /usr/doc
    Documentation for the user apps, in many file formats.

    /usr/share
    Config files and graphics for many user apps.

    /usr/src
    Source code files for the system’s software, including the Linux kernel.

    /usr/include
    Header files for the C compiler. The header files define structures and constants that are needed for building most standard programs. A subdirectory under /usr/include contains headers for the C++ compiler.

    /usr/local

    This is where you install apps and other files for use on the local machine.

    As a recommendation, If you find interesting apps that aren’t officially a part of your distro (i.e installed by your package manager), you should install them in /usr/local. For example, if the app would normally go to /usr/bin but it isn’t a part of your distro, you should install it in /usr/local/bin instead. This way you would always KNOW what did you install manually and avoid confusion, keeping things organized to avoid headaches later.

    /lib

    The shared libraries for programs that are dynamically linked. The shared libraries are similar to DLL’s on Winblows.

    /home

    This is where users keep their personal files. Every user has their own directory under /home, and usually it’s the only place where normal users are allowed to write files. You can configure a Linux system so that normal users can’t even list the contents of other users’ home directories (Linux is a really good multiuser system, unlike windows that you can list all contents of all users). This means that if your family members have their own user accounts on your Linux system, they won’t see all the important files (you know you only got porn there, but lets call that “important files”) you keep in your home directory.

    /root

    The superuser’s (root’s) home directory. Don’t confuse this with the root directory (/) of a Linux system.

    /var

    This directory contains variable data that changes constantly when the system is running, this folder is really useful for system administrators because it contains all the logs about system usage, load, access times, etc. Some interesting subdirectories to know about:

    /var/log
    A directory that contains system log files. They’re updated when the system runs, and checking them out can give you valuable info about the health of your system. If something in your system suddenly goes wrong, the log files may contain some info about the situation.

    /var/mail
    Incoming and outgoing mail is stored in this directory.

    /var/spool
    This directory holds files that are queued for some process, like printing.

    /tmp

    Programs can write their temporary files here.

    /dev

    The devices that are available to a Linux system. Remember that in Linux, devices are treated like files and you can read and write devices like they were files. For example, /dev/fd0 is your first floppy drive, /dev/cdrom is your CD drive, /dev/hda is the first IDE hard drive, and so on. All the devices that a Linux kernel can understand are located under /dev, and that’s why it contains hundreds of entries.

    /mnt

    This directory is used for mount points. The different physical storage devices (like the hard disk drives, floppies, CD-ROM’s) must be attached to some directory in the file system tree before they can be accessed. This attaching is called mounting, and the directory where the device is attached is called the mount point.

    The /mnt directory contains mount points for different devices, like /mnt/floppy for the floppy drive, /mnt/cdrom for the CD-ROM, and so on. However, you’re not forced to use the /mnt directory for this purpose, you can use whatever directory you wish. Actually in some distros, like Debian and SuSE, the default is to use /floppy and /cdrom as mount points instead of directories under /mnt.

    /proc

    This is a special directory. Well, actually /proc is just a virtual directory, because it doesn’t exist at all! It contains some info about the kernel itself. There’s a bunch of numbered entries that correspond to all processes running on the system, and there are also named entries that permit access to the current configuration of the system. Many of these entries can be viewed.

    /lost+found

    Here Linux keeps the files that it restores after a system crash or when a partition hasn’t been unmounted before a system shutdown. This way you can recover files that would otherwise have been lost. This folder should NOT be confused with the trash folder, trash folder if for files that you intentionally deleted, while lost+found is for filesystem recovery purposes.

    Now, as promised, here is the image about the Linux Directory Structure:

    Directory Tree

  • Docky in ArchLinux does not launch anymore after a system upgrade

    Docky in ArchLinux does not launch anymore after a system upgrade

    Docky LogoIf you, like me, use docky for managing your windows and launching your applications, you should have noted that recently an ArchLinux update broke docky because it installed a newer version of mono that docky doesn’t like. Anyways, here is how to fix it.

    This is the error when trying to launch docky:

    [1111@MNAME ~]$ docky
    Could not load file or assembly 'Mono.GetOptions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies.
    
    Unhandled Exception: System.TypeLoadException: Could not load type 'Docky.Docky' from assembly 'Docky, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null'.

    You can just recompile the package the usual way, but the best and easiest way to do it is to use the ABS (Arch Build System). If you already have ABS installed you can safely skip to the “Compiling docky using ABS” part. Here is a step by step guide:

    To install ABS:

    sudo pacman -S abs

    Also you will need some compiling tools, install with:

    sudo pacman -S base-devel

    Next edit /etc/abs.conf to have the desired repos fetched

    sudo nano /etc/abs.conf

    Make sure that the last line is uncommented, if you don’t want to fetch some repo, just add a ! in front of its name and you should be good to go, I would recommend fetching all of them, it doesn’t take much space (entire tree is like 56mb uncompressed, about 18mb download) and it is really handy.

    Next, download the abs tree:

    sudo abs

    Your ABS tree is now created under /var/abs. Note the appropriate branches of the ABS tree now exist and correspond to the ones you specified in /etc/abs.conf.

    The abs command should be run periodically to keep in sync with the official repositories.

    Next thing you have to do is create a build directory, a folder on your home

    mkdir -p $HOME/abs

    There you will compile the files you need for getting docky to work.

    Now that ABS is installed and correctly configured, we can get on to:

    Compiling Docky using ABS:

    docky package its in community so we need to copy those files to our pc:

    cp -r /var/abs/community/docky $HOME/abs

    and change directory to $HOME/abs:

    cd ~/abs/docky

    now run:

    makepkg -s

    NOTE: DON’T ever do “sudo makepkg -s” be sure to run it as a normal user or else you could end up breaking your system.

    This will compile the package, wait for it to finish and then install it using pacman:

    sudo pacman -U slim-1.3.0-2-i686.pkg.tar.xz

    now test docky, everything should be working now :D

    Any questions leave it in the comments.

    Thanks for reading!

    NOTE: I’m leaving this here just for reference purposes or If you encounter a similar issue in the future, as of now, this isn’t needed anymore because the appropriate changed have been made on the Arch Linux packages