Abstract

Many of us work in the Windows OS during the day, but go home and use Ubuntu, or another version of Linux in the evening. Even though both use folders, and directories, there are some differences which can be confusing, or liberating.

In this talk I will list a number of differences and point out the value to the change. Some of the changes are based on different perspectives on how the computer works. Some of simply variations on a theme. and some are simply examples of the engineering principle NIH (Not Invented Here)

Intro

Lets start by looking at some of the major conceptual differences between Unix and Windows. I am going to use Unix to discuss core differences that are shared by all Linux system. I will refer to a distribution when the difference is specifically related to a specific distribution as opposed to all the Linux distributions.

Tux-vs-Vista
Tux-vs-Vista

Naming and organization of storage devices

This is, in my option, one of the major difference between Windows and Unix. Both system use a tree structure for their folder layout. But in the Unix system there is only one root and the physical devices are hidden by attaching everything to the file system tree.

Filesystem Hierarchy

The Filesystem Hierarchy Standard maintains a common set of directory locations for the parts of the system. You might ask why this matters, well there are many different Linux distributions, but also many add on programs. Think about the confusion that would exist if Debian, and Redhat, and Ubuntu storied their tools in different folders. You would need to have different versions of the programs for different distributions. Additionally image if shell scripts had to be modified for every distribution. As a note, this did happen in the Unix world before Linux and caused a lot of grief for developers.

For a good explanation have a look at Wikipedia under Filesystem Hierarchy Standard. Another good overview of the File System Hierarchy is organized by the Debian wiki FilesystemHierarchyStandard

File System Hierarchy
File System Hierarchy

Where are the drives in Unix?

In Windows, the physical storage devices are assigned letters, and the folder separator is the backslash “\”. Typically the operating system and it’s components are stored in C:\windows and it’s subdirectories. In Unix the OS files are in /boot and the OS application files are distributed according to the Filesystem Hierarchy Standard.

In my opinion this happened because many of the early Personal Computers, were built by hobbyists who were familiar with the underlying hardware. Where as in the Unix the systems were maintained by IT so the user did not need to know about the hardware.

When I was researching how to explain mounting I came across what I thought was a good explanation.

Unix systems have a single directory tree. All accessible storage must have an associated location in this single directory tree. This is unlike Windows where (in the most common syntax for file paths) there is one directory tree per storage component (drive).

Mounting is the act of associating a storage device to a particular location in the directory tree. For example, when the system boots, a particular storage device (commonly called the root partition) is associated with the root of the directory tree, i.e., that storage device is mounted on / (the root directory). What is meant by mounting a device in Linux?

The significance of mounting is that the physical storage methods are abstracted from the user. As a user you don’t really care if something is on one partition or another drive. Additionally, this method allows you to expand the size of your system by adding space on the tree.

Most modern Linux system allow automounting of CDs, and Memory sticks just by loading them. Much the same way that windows loads the storage devices and assigns them addition drive letters.

For a more indepth discussion have a look at the Forensic Discover book chapter 3 File System Basics

Process details

In the Windows world we are use to viewing process status via the task manager window. This gives you a list of running programs, running processes, memory usage and other information about the OS.

In the Linux world we have multiple ways of viewing and interacting with running processes. The most common command is top or htop used to show a process live as seen in task manager. There are specific tools for different types of process information

  • free The free command displays the amount of free and used memory in your system.

  • uptime The uptime command shows you a one-line display that includes the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

  • jobs Display programs running in the background.

  • fg Move background task to the forground.

  • & Move a task to the background.

  • kill The kill command sends a signal to a specified job or process.

  • nice The nice command can also be used to start a process with a different priority.

  • renice If you happen to start a process and realize that it should run at a different priority, there is a way to change it after it has started, using the renice command.

  • nohup The nohup command is used to start a command that will ignore hangup signals and will append stdout and stderr to a file. The default file is either nohup.out or $HOME/nohup.out

  • ps The PS (Process Status) command can be used to display information about running processes.

For more tools to explore process status have a look at 15 Command Line Tools to Monitor Linux Performance

But beyond these is the procfs. This is a window into the OS which allow detailed information about every process on the system. This pseudo file system is actually a window into the operating system. Because this information is exposed in /proc, much more information is available but seldomly used.

Another non-obvious use of the process system is to run tasks in the background. This can be useful if you want to edit a file but still use a terminal for other tasks. I often use this feature when I am logged into a Linux system from another system. I can start a background task and still keep working on my current tasks.

In order to make get a feel for what the process information tools can do I have used a script called “Gatherinfo” to document this computer while I was at work one day. Have a look at Gathering Info on Athena to see what I mean. You can find the script that created this info at: gatherinfo.

Here are two other programs for listing system information on a Linux. Both of these are sell scripts.

  • grabsysinfo.sh

    How to get system information using bash script?

  • System Information Script SIS

    System Information Script {SIS} , Is Very powerful Shell script That Compatible With UNIX/Linux System and the distributions based on this OS , This Script can list Many important Information about the machine that load on it & information about the

The Battle has Begun
The Battle has Begun

Init Process

In Unix-based computer operating systems, init (short for initialization) is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes. Init is started by the kernel using a hard-coded filename, and if the kernel is unable to start it, a kernel panic will result. Init is typically assigned process identifier 1. init

Rather than trying to explain init to you lets let someone else have a shot.

  • Understanding The Linux Init Process & Different RunLevels

    Different Linux systems can be used in many ways. This is the main idea behind operating different services at different operating levels. For example, the Graphical User Interface can only be run if the system is running the X-server; multiuser operation is only possible if the system is in a multiuser state or mode, such as having networking available. These are the higher states of the system, and sometimes you may want to operate at a lower level, say, in the single user mode or the command line mode.

Now that we know how a Redhat system handles init and run levels lets look at Ubuntu.

  • UbuntuBootupHowto

    Since the introduction of Upstart some time in 2006, or more relevantly 9.10 Karmic where most of the system services were converted, the boot process changed somewhat. The following information is tested on 11.04 Natty:

Systemd

systemd is a system management daemon designed exclusively for the Linux kernel. In the Linux startup process, it is the first process to execute in user land; therefore, it is also the parent process of all child processes in user land.

systemd was developed for Linux to replace the init system inherited from UNIX System V and Berkeley Software Distribution (BSD) operating systems. Like init, systemd is a daemon that manages other daemons. All daemons, including systemd, are background processes. systemd is the first daemon to start (during booting) and the last daemon to terminate (during shutdown). systemd

I though I would provide some additional reading material if you are intested in learning more about systemd. It is the replacement for the System V and BSD initializations.

  • Here We Go Again, Another Linux Init: Intro to systemd

    In the days of yore we had a System V (SysV) type init daemon to manage Linux system startup, and it was good. It was configured with simple text files easily understood by mortals, and it was a friendly constant amid the roiling seas of change. Then came systemd, and once again we Linux users were cast adrift in uncharted waters. Why all this change? Can’t Linux hold still for just a minute?

Now that you understand what systemd is here are two introductions to systemd. The first from Fedora, and the second from Arch Linux.

  • Fedora Systemd

    systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux cgroups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. It can work as a drop-in replacement for sysvinit.

  • Arch Linux systemd

    systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic.

Finally I thought I would treat you to a discussion of the pros/cons of Systemd.

Linux Boot Process
Linux Boot Process

Linux Boot Process

In Linux, the flow of control during a boot is from BIOS, to boot loader, to kernel. The kernel then starts the scheduler (to allow multi-tasking) and runs the first userland (i.e. outside kernel space) program Init (which is mostly responsible to run startup scripts for each runlevel), at which point the kernel goes idle unless called externally. Linux startup process

Much of this is covered in the process startup discussed above in Initialization. But it is one of the interesting differences between Windows and Unix. Just because we take it fro granted does not mean it is not important.

User installed programs

The Unix system was designed from the beginning to be a multiuser system. So whether there is one user of one hundred users, everyone has a /home/<user> directory. All your individual configuration files are stored in $HOME. This allows each user to have his/her individual configurations for many programs. Firefox runs from the central location, but the cache and bookmarks, and other configuration items are saved in $HOME.

This also allows you to have your own versions of programs. For example suppose you wanted to have a version of perl that was newer than the one installed on the system. In order to have a different version of perl than the system default, you need to compile and install your own version. The steps would be something like this.

  1. Download the source code for perl

  2. After unpacking the archive in your $HOME location you run the command ./configure --prefix=$HOME which tells the system to use your $HOME folder as the root for the installation.

  3. Compile and install the software, typically make and make install.

  4. Assuming the program was installed in $HOME/bin you would change your path with export PATH=$HOME/bin:$PATH in .bash_profile or .bashrc. This way when you type perl on the command line it will look first in $HOME/bin. Other users would not see your perl, since it is in your $HOME and not the system location.

The folder $HOME/bin is a good location for any shell scripts you write for your self. Once they work well enough that you want to share them, copy the scripts to /usr/local/bin so everyone can make use of them.

Super Shell Scripts

Bourne Shell
Bourne Shell

Yes I know that Dos and Windows have batch file. But shell scripts have a number of advantages above and beyond what batch files can do.

Even though I would like to convince you all of the power of shell scripts that is not the purpose of this talk. I think the power is only rivaled by the number of tools available in any Linux system.

Lets roll back the clock and look at some of my early tutorials on Shell scripting in Bourne Shell Usage and Bourne Shell Usage Part II.

Instead of instructing you today in shell scripting, let me give you a few good references on writing shell scripts. Experiment you might be surprised.

  • Linux Shell Scripting Tutorial (LSST) v2.0

    This tutorial is a beginners handbook for new Linux users / Sys admins and school students studying Linux or computer science.

  • Writing Shell Script

    With the thousands of commands available for the command line user, how can you remember them all? The answer is, you don’t. The real power of the computer is its ability to do the work for you. To get it to do that, we use the power of the shell to automate things. We write scripts.

    Scripts are collections of commands that are stored in a file. The shell can read this file and act on the commands as if they were typed at the keyboard. In addition to the things you have learned so far, the shell also provides a variety of useful programming features to make your scripts truly powerful.

  • Bash Shell Script Function Examples

    How do I create a shell script function using Bash under UNIX / Linux operating systems?

    Functions are nothing but small subroutines or subscripts within a Bash shell script. You need touse to break up a complex script into separate tasks. This improves overall script readability and ease of use. However, shell function cannot return value. They return a status code.

X Windows twm
X Windows twm

X Windows

Back when UNIX was a new thing, around 1970, graphical user interfaces were only a weird thing being played with in a laboratory (Xerox’s PARC to be precise). Nowadays, however, any operating system in hopes of being competitive needs to have a GUI subsystem. GUIs are supposed to be easier to use. This is not much of a concern under UNIX, which has traditionally been, to some extent, pretty user-hostile, preferring versatility over ease of use. However, there are several reasons why a GUI is desirable even on a UNIX system. For instance, given UNIX’s multitasking nature, it’s natural to have a lot of programs running at any given time. A GUI gives more control over how things are displayed on-screen, thus providing with better facilities for having a lot of programs on-screen at the same time. Also, some kinds of information are better displayed in graphical form. X Window System Architecture Overview

Before I go and repeat myself let me take you to part of a previous talk about The X Window Subsystem

If you would like a little more depth on the X-Windows system, have a look at What Is the X Window System

Display Manager

The X Display Manager (XDM) is an optional part of the X Window System that is used for login session management. This is useful for several types of situations, including minimal X Terminals, desktops, and large network display servers. Since the X Window System is network and protocol independent, there are a wide variety of possible configurations for running X clients and servers on different machines connected by a network. The X Display Manager < The display manager is what we see when ever we login to a modern OS. Windows has one, the Mac has one, and Linux has many.

Lets go back to a couple of talks I gave previously on Display/Windows Managers.

  • Linux Window Manager Use

    This talk will focuse on how to work with window managers under Linux. Rather than a survey of different window managers, I am going to focus on how to customize them.

  • Display Managers

    Before we start discussing the Display managers I thought it would be fun to get a quick over view of them from YouTube.

The Commandline In the Beginning… Or a local copy is available here: In the Beginning…

Tools, Tools, and more Tools

At this point I want to remind you of a little history of Unix.

Although UNIX was developed by programmers for programmers, it provides an environment so powerful and flexible that it is found in businesses, sciences, academia, and industry. An Overview of the UNIX* Operating System

What this means to us is that Unix is a DIY (Do It Yourself) operating system. This also means that your Linux system comes with all the tools needed to make changes to the system. With the exception of some proprietary programs, like Adobe Reader you can get the source code for any part of the system, including the operating system.

But today I am not going to lecture you on how to modify your Linux system. Instead lets look at some basic Linux commands.

As an interesting experiment I compared the number of executable files on a Windows 7 workstation and a Ubuntu workstation. In Windows I found 479 exe files, and 2 batch files under C:\Windows. But on a Ubuntu system I searched /bin /usr/bin /sbin /usr/sbin /usr/local/bin for executable files and found 3040 files. Of that number of executable files 559 were shell scripts. So what is this telling me?

Compare Dos to Linux Command Line Tools

As an old CLI (Command Line Interface) user I like to compare the command line tools first. The only problem with this is that Linux has many more command line tools than does Dos/Windows. But if you are familiar with the Dos/Windows command line, then we should start with a comparison.

Command line help for Linux

In the spirit of helping to spread the knowledge here is some more help understanding the Linux command line.

  • Basic UNIX/Linux commands Custom commands available on departmental Linux computers but not on
    Linux systems elsewhere have descriptions marked by an *asterisk. Notice that for some standard Unix/Linux commands, friendlier versions have been implemented; on departmental Linux computers the names of such custom commands end with a period.

You might also check out How to use Unix/Linux from the CS department at Plattsburg N.Y.

Also see CS Teaching Material Archive at Boston University.

Freedom, Choices, Beautiful
Freedom, Choices, Beautiful

Written by John F. Moore

Last Revised: Tue Nov 1 18:14:05 EDT 2016

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
HTML5 Powered with CSS3 / Styling, and Semantics