Linux file system hierarchy

This section is about a quick overview of which directory and file is where so you know where to start.

It normally looks like an inverted tree with its roots on top and branches hanging below (don’t worry if you cant understand  this. Get through to the end, for sure you will).

Just like a tree, we have a root from which everything else is attached. It is normally denoted by a forward slash “/”. Remember when we were installing the Linux disto Elementary-OS we created a partition and mounted is on to “/”. Allow me to call any other directory below this root its “children”

The root has many standardized children which you will find in all your distros:

  • /bin   >Essential command binaries
  • /boot   >Static files of the boot loader
  • /dev   >Device files
  • /etc    >Host−specific system configuration
  • /lib    >Essential shared libraries and kernel modules
  • /media    >Mount point for removable media
  • /mnt   >Mount point for mounting a filesystem temporarily
  • /opt    >Add−on application software packages
  • /sbin   >Essential system binaries
  • /srv      >Data for services provided by this system
  • /tmp    >Temporary files
  • /usr     >Secondary hierarchy
  • /var      >Variable data

Lets discuss these children one by one:

/bin: This contains essential command binaries and no directory is not allowed in it as a standard. The commands are essential and in case a system fails and the computer is not able to mount or access any network services, the commands can be used to troubleshoot the machine.

/boot: Contains all files needed to boot the computer. Its contents rarely change.

/dev: Contains block and character devices e.g hard disk, printer, mouse. Everything in Linux is a file; you can locate your partitions as /dev/sda1 (where “a” and 1 can be any number/letter). This files are populated by the Linux Kernel in real time. These are my disks:

ls dev_sd

A look at my ls /dev/sd*

Note: you cannot access your partitions from here, leave this to your kernel. We will use /media or /mnt to access our partitions.

/etc: This is for machine/host specific configurations. Generally no binary files exist inside this directory. Remember when we automounted our partitions we used the configuration file  /etc/fstab

/lib: Binaries found in /bin and /sbin often use shared libraries located in /lib. You might also notice two directories /lib32 and /lib64. This was brought about so as to separate 64bit libraries and 32bit ones.

/media: Used to mount our partitions and also removable devices are automatically mounted here in some distros e.g Ubuntu. Once again remember our partition auto-mounting tutorial where we used /media/MUVI to mount our partition.

/mnt: It is advisable that the /mnt directory should be empty and should only be used for temporary mount points.

/opt: Its used to store optional software. In many cases this is software from outside the distribution repository. One time I installed Linux package for my broadband orange modem, it was installed under this directory.

/sbin: contains binaries that are used to configure the operating system. It should contain only binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin.

/srv: Used for data severed by your system e.g /srv/sales/www for serving www data for the sales department.

/tmp: Applications and users are supposed to use this to store temporary data. It is usually cleared on shutdown by some distros.

/home: This usually contains user data. If my user name is tux then a directory is created under  /home/tux which contains my data and configuration files.

/root: This is the home directory for the root user.

 

To sum it all up: (picture by tuxradar)

Linux file system tree

Linux file system tree

##

Any question? As usual feel free to ask, will be more than glad to help…..

Or just send me an inbox at tuxygeek at gmail dot com

Lets hit the terminal – part 1

What is terminal? It is where we write the commands. Before we do this did you know that you can do virtually everything in Linux for the without ever using the command line? This is how simple Linux has become.

Why do I need to write commands? Whenever you fire up your terminal emulator and use commands, you will have more control and feedback of what is actually happening. Lets say for example updating a package. If I use the available GUI all I am able to see is usually the progress bar while if i had used commands I would see each and every stage of the update process.

The other good and obvious reason why you might use the commands will  be just to look cool.

Lets start by the most common commands:

ls

Used to list contents of a directory. Has many switches but what you will mostly use are

ls -l   –> lists contents in list format.

ls -al –> lists all contents in list format.

ls -alh –> lists all contents in list format and human readable file sizes.

Note: From above you can see that the command is ls while the l, a and h are usually referred to as switches. This switches normally have their long formats but starting with double dash ‘–‘ for instance ls -a equals ls –all.

To display list of files and directories under our present working directory just type ls -l. If the directory you wish to display contents of a directory other than the current just specify its full path. Do not forget to put space between command and the switch and between the switch and directory path.

ls -l  /etc/

Try this first then we continue with the other commands. Here is my result:

my ls -l

My ls -l /etc/ output

Don’t worry about the details we will discuss that later on.

cp

Guess what this one does………. Yes you got it.

Its used to copy files and directories. Generally this is how it is used:

cp SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY

Where SOURCE is the source file while DEST is the destination file. Lets copy a file test.txt from  /home/tux/Downloads to /home/tux/Documents

Go to your Downloads directory and create a file called test.txt. My user name is tux so replace tux with your user name

cp /home/tux/Downloads/test.txt /home/tux/Documents/test.txt

Try the above and do not forget the spaces.

cd

This is used to change your directory. Whenever you open your terminal you work from your home directory by default. To change to the /etc directory use the following command:

cd /etc/

To go back to your home directory simply type cd then hit Enter

mkdir

This is used to make a new directory.

mkdir testdir   –> make directory called testdir in your current working directory.

mkdir /home/tux/Downloads/testdir    –> make directory called testdir in the directory /home/tux/Downloads/

rm

Used to remove a directory or a file. Let me begin by a big warning: be careful with this command, once deleted there is no trash and no undo.

To remove an empty directory or a file:

rm testfile.txt

rm testdir –> where the testdir is an empty directory

Use the switch -R to remove a directory with contents.

rm -R testdir –> where the testdir is a directory

man

This is your friend. It contains help for almost all the commands available under Linux.

To get help on how to use the cp command, type:

 man cp

This will give you description of the command and the available switches for that particular command.

##

Any question? As usual feel free to ask, will be more than glad to help…..

Or just send me an inbox at tuxygeek at gmail dot com

fstab featured image

How to auto-mount partitions on Linux

I just booted my Windows and I found my C, D, E, F drives. Guess what! They have just been auto-mounted by your windows. Linux does not do this automatically unless you tell it to. This is how do it:

There is a file located in the /etc directory called fstab (file system table). This is where partitions  that are automatically mounted are specified. take an example of my fstab.(Am using centOS 7)- just in case you cant see click on the image to enlarge.

centOS 7 fstab

A look at my centOS fstab

To display the contents of your fstab file on your terminal run as a super user ‘ sudo cat /etc/fstab’

Assume the # parts they are comments with some information about the file, or better just read it for your own consumption.

The file contents are separated into 6 parts

<file system>  <mount point>      <type>   <options>  <dump>   <pass>

UUID=8f7de9   /                                ext4        defaults          1               1
UUID=d3d4ff   /media/MUVI          ext4        defaults           1               2
UUID=f9d1d   swap                          swap      defaults           0               0

file system: Every partition has a unique id called UUID which uniquely identifies the partition. The partitions can also be identified by kernel name descriptor  as  /dev/sda1. Either of this formats can be  used for this particular <file system> section. As shown above the UUID has been used but an equivalent for the same  partition would be to use /dev/sda2.

The following commands will help you identify the UUID and kernel name descriptor:

  1. sudo blkid
  2. sudo lsblk

mount point: this is where your partition will be mounted. For beginners I would advise that we just mount all our partitions in the /media directory for example line 2 above I decided to mount my partition on  /media/MUVI. For the / and swap mount points, they are normally added by the system, you will find them already included.

type: this is the file system type e.g ext4 and ntfs

options: This is the options for mounting the partitions. As per this level let us safely use the ‘defaults’. This uses the defaults for each file system.

dump: used to decide whether the partition will be backed up. There are two possible values, 0 or 1. 0 means no backup will be done while a 1 means the dump utility will perform backup of the partition. Lets use 0, we don’t need to set up this dump thing.

 

I try do summaries so you don’t get so much of the geeky stuff.  This is just the beginning but if you feel you want more in-depth visit archlinux fstab documentation

 

 

cinnamon desktop environment

Linux Desktop Environment

Welcome to our Linux world. A world of choice; did you know you can choose which Desktop Environment you want to use? Before we choose I guess we need to know what a Desktop Environment is. Pay attention and read again to get it right.

It basically provides you with the user interface to enable you interact with your computer. Desktop environment is the layer that allows one to see and use the mouse cursor, open files, move windows, maximize windows, log into your computer among other things.

Let me assume you have used windows before, Windows 2000, XP, Vista, 7 or  8. From when you log into your computer, click on start menu , launch that “My Computer” and listen to music in VLC then minimize the VLC to your taskbar , you utilize the desktop environment.

Different distros come with different or multiple desktop environments. Some come with a couple of environments so you chose the one you wish to install or even all if  you so wish. Here are a list of the Desktop environments that are officially supported under Linux:

Cinnamon

cinnamon  desktop environment

Enlightenment

enlightment desktop environment

GNOME

gnome 3 desktop environment
KDE

kde desktop environmentOther common ones:

  1. LXDE
  2. MATE
  3. Xfce

This list is too short compared to the full list but at least you get the idea. You can install any of them as long as you are running Linux. Each of them have pros and cons but just FYI gnome and kde are more resource intensive compared to the others.

Different Desktop Environments come packaged with different packages for example gnome comes with nautilus as default windows manager while kde comes with dolphin as its default. Windows manager is that package that allows you to open, create, delete a folder/directory. This however does not mean that you stuck with the defaults, you can run dolphin on a gnome desktop environment; yes, that’s how flexible we are ( Am feeling like Linux itself right now).

Below is both dolphin and nautilus running under gnome3 desktop environment: To the left is dolphin

dolphin-nautilus

 

Any question? As usual feel free to ask, will be more than glad to help…..

Or just send me an inbox at tuxygeek at gmail dot com

Installing Linux

Installing Linux – Step by Step guide

In this tutorial I will be using a distro based on Ubuntu called Elementary OS. From my previous post it was position 7 on top Linux distros. Once you are able to install through this 6 steps then feel confident you can install nearly any distro out there.

BTW if you don’t understand what a distro or Linux is, check out what is Linux.

Let me make some assumptions in this tutorial:

  1. You can boot to a USB disk/ CD without difficulties.
  2. You are as blank about Linux as I was back in 2008, or a little better. Trust me, you cant be worse.
  3. You have at least 20Gb free hard disk space.

Step 1: Boot into the CD/USB stick then give it while till you see a screen similar to the one below.

step 1 of the installation

step 1 of the installation

At this stage there are two options. You can choose to try the distro as it is or install it to your hard disk. Since we are doing an installation, click on Install elementary OS to take you to step 2.

Step 2: The following screen pops up at this stage.

step 2 of the installation

screen appearing at step 2.

At this moment, I feel its important to talk about the fact that most Linux distros do not come preloaded with some of the most common software and plug-ins. One that might shock you is that which enables you to play mp3 files (meaning you cannot play mp3 music immediately you install the distro). Hey, don’t worry if you have internet while installing just check the second check box (Install this third-party software) if you dont have internet I will tell you what to do later so lets hit the “continue” button.

Lets pay more attention here, less stories more ‘geeky’ stuff coming.

step 3: At this point choose “something else” unless you want to remove everything from your hard disk which am pretty sure you don’t want to.

Installing elementary OS step 3

choose “something else”

step 4: Manual hard disk partitioning.

 

Linux installation step 4

step 4: partitioning of the hard disk.

Are you confused at this screen? worry less. Just look for your free space under “Device” mine as you can see is 21474MB which is roughly 20GB free space.

We need to create two partitions from this free space. The first one is known as the swap space ( this is used for the internal operation of Linux.) while the second one is known as the root partition.

Select on the free partition then click on “add to add a new partition

step 5: Creating the swap space

The screen below enables you to add the swap space.

creating swap space

Step5: Creating swap space

As a rule of thumb, lets make it half  our RAM size i.e if your RAM is 2GB then our swap space should be 1 GB.

Under partition size input the correct swap size depending on the size of your RAM (remember 1024Mb = 1Gb, not 1000Mb). To use our new partition as swap space, under “Use as” choose swap area from the drop down menu.

For swap:

  1. New partition size: enter appropriate size (half your RAM).
  2. Use as: Swap area

 

step 6: Creating the root partition.

What is this root?: just like the tree root which holds the tree firm on the ground and carries the whole tree, this partition holds your Linux and everything in Linux comes from it. It is normally represented by a forward slash “/”. Can we just skip this root gibberish? I will give you a good explanation later in another article for now lets blindly create it.

Once again on the free space create a new partition, give it an appropriate size ( my recommendation – approximately 20Gb if you really have space problems otherwise give tux some handsome space).

Oh, I think I skipped something, under use as be faithfully choose ext4.

Linux installation step 6: Creating root partition

step 6: Creating root partition

We look at three things:

  1. New partition size: enter appropriate size
  2. Use as: ext4
  3. Mount Point: /

Did I say you are done? Technically you are, the remaining part is as easy as filling in your name and location then…..

 

Installation complete, Reboot

Installation complete, Reboot

 

 

Any question? As usual feel free to ask, will be more than glad to help…..

Or just send me an inbox at tuxygeek at gmail dot com

So, What is Linux?

I will try to be as simple as I can be on this one but feel free to still ask any question.

What is Linux?
At this particular stage allow me to call Linux an Operating System just like the Microsoft’s Windows and Apple’s Mac OS. It is a derivative of the Minix which was based on Unix which makes Linux a Unix-Like operating system.

Difference with Windows and Mac OS: Linux is free and can be shared amongst friends, and maybe enemies. For Linux you can also get the source code for free, modify and redistribute hence Windows and Mac OS are known as proprietary operating systems while Linux is an open source operating system.

On to a more confusing question….

What is Ubuntu?: Ubuntu is a Linux distribution commonly known as distros. A distro is an operating system which has been made up of a collection of software around the Linux kernel.
It is at this point that I defer with my first Linux definition and I will now call it a kernel. Lets use Ubuntu as a distro example.

The Linux kernel is developed by people across the world then it is verified and released by Linus Benedict Torvalds (the geek who came up with the idea of having Linux).

After the kernel is released, Ubuntu team takes it up adds the user level applications such as libre office writer, Mozilla Firefox etc. they then package them together with the kernel, test and fine tune for optimal performance then release it as an operating system e.g Ubuntu 14.04 (which, FYI, am using to write this article)

What are the other distros?: There are almost 200 distros to date. The famous 10 are as listed:

  • Linux Mint
  • Ubuntu
  • Mageia
  • Fedora
  • openSUSE
  • ArchLinux
  • Elementary OS
  • Zorin OS
  • Cent OS
  • Puppy Linux

Conclusion:

relationship between kernel, user space and hardware

Relationship between kernel, user space and hardware

Got a question? Pop it on the comments below.

Ubuntu release schedule available

This might not attract the many of you but for those who care & are in to this type of thingy, the next Ubuntu release schedule is out. Ubuntu 13.10 code named Saucy Salamander is set for 17th October 2013 while Ubuntu 14.04 is set for 17th April 2014. Ubuntu 14.04 is said to have more device support like tablets, TVs & smartphones.

Canonical released the Ubuntu touch for phone sometime in February this year & can be used in Nexus phones & tablets android devices. Having used it for sometime, having a fully fledged Ubuntu in a tablet will be a great & interesting step which can definitely change the tablet market currently dominated by only Android & Apple. Continue reading