Category: Linux & Open Source

Linux administration on Ubuntu and CentOS: commands, scripting, networking, services (DNS, DHCP, Samba, NFS, Apache, Squid) and LPIC study notes.

  • How do I configure swappiness? (Swap file)

    The Linux kernel provides a tweakable setting that controls how often the swap file is used, called swappiness

    A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly.

    Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system’s swappiness value by running:

    one@onezero:~$ cat /proc/sys/vm/swappiness
    60
    

    As I have 4 GB of RAM, so I’d like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open /etc/sysctl.conf as root. Then, change or add this line to the file:

    vm.swappiness = 10
    

    Reboot for the change to take effect

    You can also change the value while your system is still running

    sysctl vm.swappiness=10
    

    you can also clear your swap by running swapoff -a and then swapon -a as root instead of rebooting to achieve the same effect.

    To calculate your swap Formula

    free -m (total) / 100 = A
    
    A * 10
    
    root@onezero:/home/one# free -m
                 total       used       free     shared    buffers     cached
    Mem:          3950       2262       1687          0        407        952
    -/+ buffers/cache:        903       3047
    Swap:         1953          0       1953
    

    so total is 3950 / 100 = 39.5 * 10 = 395

    so what it mean is that when 10 % 395 MB of ram left then it start using swapiness


                                              Help . Ubuntu . Swap

                                               What is swappiness

    The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.

    .     swappiness can have a value of between 0 and 100

    .     swappiness=0 : Version 3.5 and over: disables swapiness. Prior to 3.5: tells the kernel to avoid swapping processes out of physical memory for as long as possible.

    .     swappiness=1 : Version 3.5 and over: Minimum swappiness without disabling it entirely

    .     swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache

    See http://en.wikipedia.org/wiki/Swappiness

    The default setting in Ubuntu is swappiness=60. Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended, but feel free to experiment.


    Started Using swap at 91%

    enter image description here As I have configured my system & vm to make use of ram at 90 % . At 90 % there was no swapping

    after that I opened some application like Firefox & Shutter , its start swapping because of ram usage is above 90 %

  • Recommended size in percentage for each partition (Ubuntu / Linux)

    I have seen most of dedicated hosting companies servers always have multiple partition for various folders. I have tried to follow some guide lines on my own on virtual box. I always use swap space as double the ram. let’s say

    TS = total Size
    SS = Swap Size
    MS = Main Size
    
    MS = TS - SS
    

    What is bellow is percentage on MS.

    /         20%
    /boot     100M
    /var      25%
    /home     24%
    /usr      10%
    /tmp      200M
    /opt      10%
    

    it looks like I still need some key places I should give more space and some other places I should reduce space for example /usr and /var.

    9.15.5. Recommended Partitioning Scheme

    9.15.5.1. x86, AMD64, and Intel 64 systems

    We recommend that you create the following partitions for x86, AMD64, and Intel 64 systems:
    • A swap partition
    • A /boot partition
    • A / partition
    • A home partition
    • A swap partition (at least 256 MB) — Swap partitions support virtual memory: data is written to a swap partition when there is not enough RAM to store the data your system is processing.
      In years past, the recommended amount of swap space increased linearly with the amount of RAM in the system. Modern systems often include hundreds of gigabytes of RAM, however. As a consequence, recommended swap space is considered a function of system memory workload, not system memory.
      The following table provides the recommended size of a swap partition depending on the amount of RAM in your system and whether you want sufficient memory for your system to hibernate. The recommended swap partition size is established automatically during installation. To allow for hibernation, however, you will need to edit the swap space in the custom partitioning stage.

      Table 9.2. Recommended System Swap Space

      Amount of RAM in the system Recommended swap space Recommended swap space if allowing for hibernation
      ⩽ 2GB 2 times the amount of RAM 3 times the amount of RAM
      > 2GB – 8GB Equal to the amount of RAM 2 times the amount of RAM
      > 8GB – 64GB 0.5 times the amount of RAM 1.5 times the amount of RAM
      > 64GB 4GB of swap space No extra space needed


      At the border between each range listed above (for example, a system with 2GB, 8GB, or 64GB of system RAM), discretion can be exercised with regard to chosen swap space and hibernation support. If your system resources allow for it, increasing the swap space may lead to better performance.
      Note that distributing swap space over multiple storage devices — particularly on systems with fast drives, controllers and interfaces — also improves swap space performance.

      Note

      Swap space size recommendations issued for Red Hat Enterprise Linux 6.0, 6.1, and 6.2 differed from the current recommendations, which were first issued with the release of Red Hat Enterprise Linux 6.3 in June 2012 and did not account for hibernation space. Automatic installations of these earlier versions of Red Hat Enterprise Linux 6 still generate a swap space in line with these superseded recommendations. However, manually selecting a swap space size in line with the newer recommendations issued for Red Hat Enterprise Linux 6.3 is advisable for optimal performance.
    • A /boot/ partition (250 MB)

      The partition mounted on /boot/ contains the operating system kernel (which allows your system to boot Red Hat Enterprise Linux), along with files used during the bootstrap process. For most users, a 250 MB boot partition is sufficient.

      Important — Supported file systems

      The GRUB bootloader in Red Hat Enterprise Linux 6.5 supports only the ext2, ext3, and ext4 (recommended) file systems. You cannot use any other file system for /boot, such as Btrfs, XFS, or VFAT.

      Warning

      Note that normally the /boot partition is created automatically by the installer. However, if the / (root) partition is larger than 2 TB and (U)EFI is used for booting, you need to create a separate /boot partition that is smaller than 2 TB to boot the machine successfully.

      Note

      If your hard drive is more than 1024 cylinders (and your system was manufactured more than two years ago), you may need to create a /boot/ partition if you want the / (root) partition to use all of the remaining space on your hard drive.

      Note

      If you have a RAID card, be aware that some BIOS types do not support booting from the RAID card. In cases such as these, the /boot/ partition must be created on a partition outside of the RAID array, such as on a separate hard drive.
    • A root partition (3.0 GB – 5.0 GB) — this is where “/” (the root directory) is located. In this setup, all files (except those stored in /boot) are on the root partition.
      A 3.0 GB partition allows you to install a minimal installation, while a 5.0 GB root partition lets you perform a full installation, choosing all package groups.

      Root and /root

      The / (or root) partition is the top of the directory structure. The /root directory (sometimes pronounced “slash-root”) is the home directory of the user account for system administration.
    • A home partition (at least 100 MB)

      To store user data separately from system data, create a dedicated partition within a volume group for the /home directory. This will enable you to upgrade or reinstall Red Hat Enterprise Linux without erasing user data files.

    Many systems have more partitions than the minimum listed above. Choose partitions based on your particular system needs. Refer to Section 9.15.5.1.1, “Advice on Partitions” for more information.
    If you create many partitions instead of one large / partition, upgrades become easier. Refer to the description of the Edit option in Section 9.15, “ Creating a Custom Layout or Modifying the Default Layout ” for more information.
    The following table summarizes minimum partition sizes for the partitions containing the listed directories. You do not have to make a separate partition for each of these directories. For instance, if the partition containing /foo must be at least 500 MB, and you do not make a separate /foo partition, then the / (root) partition must be at least 500 MB.

    Table 9.3. Minimum partition sizes

    Directory Minimum size
    / 250 MB
    /usr 250 MB, but avoid placing this on a separate partition
    /tmp 50 MB
    /var 384 MB
    /home 100 MB
    /boot 250 MB


    Leave Excess Capacity Unallocated

    Only assign storage capacity to those partitions you require immediately. You may allocate free space at any time, to meet needs as they occur. To learn about a more flexible method for storage management, refer to Appendix D, Understanding LVM.
    If you are not sure how best to configure the partitions for your computer, accept the default partition layout.
    9.15.5.1.1. Advice on Partitions
    Optimal partition setup depends on the usage for the Linux system in question. The following tips may help you decide how to allocate your disk space.
    • Consider encrypting any partitions that might contain sensitive data. Encryption prevents unauthorized people from accessing the data on the partitions, even if they have access to the physical storage device. In most cases, you should at least encrypt the /homepartition.
    • Each kernel installed on your system requires approximately 10 MB on the /bootpartition. Unless you plan to install a great many kernels, the default partition size of 250 MB for /boot should suffice.

      Important — Supported file systems

      The GRUB bootloader in Red Hat Enterprise Linux 6.5 supports only the ext2, ext3, and ext4 (recommended) file systems. You cannot use any other file system for /boot, such as Btrfs, XFS, or VFAT.
    • The /var directory holds content for a number of applications, including the Apache web server. It also is used to store downloaded update packages on a temporary basis. Ensure that the partition containing the /var directory has enough space to download pending updates and hold your other content.

      Warning

      The PackageKit update software downloads updated packages to /var/cache/yum/ by default. If you partition the system manually, and create a separate /var/ partition, be sure to create the partition large enough (3.0 GB or more) to download package updates.
    • The /usr directory holds the majority of software content on a Red Hat Enterprise Linux system. For an installation of the default set of software, allocate at least 4 GB of space. If you are a software developer or plan to use your Red Hat Enterprise Linux system to learn software development skills, you may want to at least double this allocation.

      Do not place /usr on a separate partition

      If /usr is partitioned separately from the rest of the root volume, the boot process becomes much more complex because /usr contains boot-critical components. In some situations, such as when installing on an iSCSI drive, the system will not boot.
    • Consider leaving a portion of the space in an LVM volume group unallocated. This unallocated space gives you flexibility if your space requirements change but you do not wish to remove data from other partitions to reallocate storage.
    • If you separate subdirectories into partitions, you can retain content in those subdirectories if you decide to install a new version of Red Hat Enterprise Linux over your current system. For instance, if you intend to run a MySQL database in /var/lib/mysql, make a separate partition for that directory in case you need to reinstall later.
    • UEFI systems should contain a 50-150MB /boot/efi partition with an EFI System Partition filesystem.
    The following table is a possible partition setup for a system with a single, new 80 GB hard disk and 1 GB of RAM. Note that approximately 10 GB of the volume group is unallocated to allow for future growth.

    Example Usage

    This setup is not optimal for all use cases.

    Example 9.1. Example partition setup

    Table 9.4. Example partition setup

    Partition Size and type
    /boot 250 MB ext3 partition
    swap 2 GB swap
    LVM physical volume Remaining space, as one LVM volume group
    The physical volume is assigned to the default volume group and divided into the following logical volumes:

    Table 9.5. Example partition setup: LVM physical volume

    Partition Size and type
    / 13 GB ext4
    /var 4 GB ext4
    /home 50 GB ext4
  • Installing common packages on Ubuntu

    #sudo apt-get install vim

    #sudo apt-get install nano

    #sudo apt-get install screen

    #sudo apt-get install sysstat

    #sudo apt-get install iotop

    #sudo apt-get install openssh-server

  • After installing Ubuntu on VirtualBox… (Guest Additions in Virtual Box)

    Virtual Box for some reason doesn’t seem to show Ubuntu in full screen mode and the display is distorted. You will have to install virtualbox-guest-additions in order to fix this issue.

    First, make sure you have the DKMS (Dynamic Kernel Module Support) package.
    In a terminal window type:
    Code:

    sudo apt-get install dkms

    Then, install the virtualbox-guest-additions by typing the following apt command in the terminal window:
    Code:

    sudo apt-get install virtualbox-guest-additions-iso
    
    (to search it first to see if it is available #apt-cache search virtualbox-guest-additions-iso)
  • 5 commands to check memory usage on Linux

    1. free command

    The free command is the most simple and easy to use command to check memory usage on linux. Here is a quick example

    $ free -m
                 total       used       free     shared    buffers     cached
    Mem:          7976       6459       1517          0        865       2248
    -/+ buffers/cache:       3344       4631
    Swap:         1951          0       1951

    The m option displays all data in MBs. The total os 7976 MB is the total amount of RAM installed on the system, that is 8GB. The used column shows the amount of RAM that has been used by linux, in this case around 6.4 GB. The output is pretty self explanatory. The catch over here is the cached and buffers column. The second line tells that 4.6 GB is free. This is the free memory in first line added with the buffers and cached amount of memory.

    Linux has the habit of caching lots of things for faster performance, so that memory can be freed and used if needed.
    The last line is the swap memory, which in this case is lying entirely free.

    2. /proc/meminfo

    The next way to check memory usage is to read the /proc/meminfo file. Know that the /proc file system does not contain real files. They are rather virtual files that contain dynamic information about the kernel and the system.

    $ cat /proc/meminfo
    MemTotal:        8167848 kB
    MemFree:         1409696 kB
    Buffers:          961452 kB
    Cached:          2347236 kB
    SwapCached:            0 kB
    Active:          3124752 kB
    Inactive:        2781308 kB
    Active(anon):    2603376 kB
    Inactive(anon):   309056 kB
    Active(file):     521376 kB
    Inactive(file):  2472252 kB
    Unevictable:        5864 kB
    Mlocked:            5880 kB
    SwapTotal:       1998844 kB
    SwapFree:        1998844 kB
    Dirty:              7180 kB
    Writeback:             0 kB
    AnonPages:       2603272 kB
    Mapped:           788380 kB
    Shmem:            311596 kB
    Slab:             200468 kB
    SReclaimable:     151760 kB
    SUnreclaim:        48708 kB
    KernelStack:        6488 kB
    PageTables:        78592 kB
    NFS_Unstable:          0 kB
    Bounce:                0 kB
    WritebackTmp:          0 kB
    CommitLimit:     6082768 kB
    Committed_AS:    9397536 kB
    VmallocTotal:   34359738367 kB
    VmallocUsed:      420204 kB
    VmallocChunk:   34359311104 kB
    HardwareCorrupted:     0 kB
    AnonHugePages:         0 kB                                                                                                                           
    HugePages_Total:       0
    HugePages_Free:        0
    HugePages_Rsvd:        0
    HugePages_Surp:        0
    Hugepagesize:       2048 kB
    DirectMap4k:       62464 kB
    DirectMap2M:     8316928 kB

     

    Check the values of MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree.
    They indicate same values of memory usage as the free command.

    3. vmstat

    The vmstat command with the s option, lays out the memory usage statistics much like the proc command. Here is an example

    $ vmstat -s
          8167848 K total memory
          7449376 K used memory
          3423872 K active memory
          3140312 K inactive memory
           718472 K free memory
          1154464 K buffer memory
          2422876 K swap cache
          1998844 K total swap
                0 K used swap
          1998844 K free swap
           392650 non-nice user cpu ticks
             8073 nice user cpu ticks
            83959 system cpu ticks
         10448341 idle cpu ticks
            91904 IO-wait cpu ticks
                0 IRQ cpu ticks
             2189 softirq cpu ticks
                0 stolen cpu ticks
          2042603 pages paged in
          2614057 pages paged out
                0 pages swapped in
                0 pages swapped out
         42301605 interrupts
         94581566 CPU context switches
       1382755972 boot time
             8567 forks
    $

    The top few lines indicate total memory, free memory etc and so on.

    4. top command

    The top command is generally used to check memory and cpu usage per process. However it also reports total memory usage and can be used to monitor the total RAM usage. The header on output has the required information. Here is a sample output

    top - 15:20:30 up  6:57,  5 users,  load average: 0.64, 0.44, 0.33
    Tasks: 265 total,   1 running, 263 sleeping,   0 stopped,   1 zombie
    %Cpu(s):  7.8 us,  2.4 sy,  0.0 ni, 88.9 id,  0.9 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem:   8167848 total,  6642360 used,  1525488 free,  1026876 buffers
    KiB Swap:  1998844 total,        0 used,  1998844 free,  2138148 cached
    
      PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND                                                                                 
     2986 enlighte  20   0  584m  42m  26m S  14.3  0.5   0:44.27 yakuake                                                                                 
     1305 root      20   0  448m  68m  39m S   5.0  0.9   3:33.98 Xorg                                                                                    
     7701 enlighte  20   0  424m  17m  10m S   4.0  0.2   0:00.12 kio_thumbnail

    Check the KiB Mem and KiB Swap lines on the header. They indicate total, used and free amounts of the memory. The buffer and cache information is present here too, like the free command.

    5. htop

    Similar to the top command, the htop command also shows memory usage along with various other details.

    htop memory ram usage

    The header on top shows cpu usage along with RAM and swap usage with the corresponding figures.

  • Linux (Users, Groups and Permissions)

    :::::::::::::Users in linux ::::::::::::::
    (to add a user)
    fali@ubuntu:~$sudo adduser ali

    (to delete user)
    fali@ubuntu:~$sudo userdel ali

    (to delete user and the user home directory)
    fali@ubuntu:~$sudo userdel -r ali

    (to manually delete the user home directory if it is left behind)
    fali@ubuntu:~$sudo rm -r /home/ali

    (all user informatin is stored in a text file /etc/passwd)(users passwords information file)
    (usernames and home directories)
    (to see all the information for users)
    (different services also have usernames)
    (you can rename the username in this file)
    fali@ubuntu:~$sudo vi /etc/passwd (or fali@ubuntu:~$sudo vim /etc/passwd)

    (to change the user password)
    fali@ubuntu:~$sudo passwd ali

    (to clear the screen)
    fali@ubuntu:~$clear

    ::::::::::::Groups in linux::::::::::::
    (put users into groups and give permissions to groups )
    fali@ubuntu:~$sudo groupadd marketing (add a group)
    fali@ubuntu:~$sudo groupdel marketing (delete a group)
    fali@ubuntu:~$sudo adduser ali marketing (add a user in a group)
    fali@ubuntu:~$sudo deluser ali marketing (to remove a user from a group)
    fali@ubuntu:~$sudo gpasswd -a ali managers
    fali@ubuntu:~$sudo gpasswd -d ali managers

    (to see all the information about the groups)(groups configuration file)
    fali@ubuntu:~$sudo vi /etc/group (fali@ubuntu:~$sudo vim /etc/group)

    (to see all the groups you are a member of)
    fali@ubuntu:~$groups
    (to see all the groups)
    fali@ubuntu:~$cat /etc/group

    :::::::::::permissions:::::::::::::::::
    three digit number e.g. 214
    first digit= permissions of the owner of the file (e.g. read, write and execute)
    second digit= permissions of the group owner
    third digit= everybody else (not even an owner) (mostly given read and execute for example to execute the scripts e.g 5)
    4=read
    2=write
    1=execute
    0=nothing

    (to change the permissions)
    fali@ubuntu:~$sudo chmod 755 folder1 -R
    fali@ubuntu:~$sudo chmod 775 file1
    (chmod stands for change mode)
    (-R switch is for recursive, for a folder)
    (three digit number depends on the security policy)

    to see the permissions for files and folders in the current directory->
    fali@ubuntu:~$ls -l
    drwxrwxrwx 2 root root test1
    (rwxrwxrwx means 777 permission)

    fali@ubuntu:~$sudo chmod 755 folder1 -R
    7=rwx (4+2+1)
    5=rx- (4+1)

    fali@ubuntu:~$ls -l
    drwxr-xr-x 2 ali group1 test1

    (execute for e.g. .txt file means that there are scripts in it)
    (execute for folder means you can change a working directory to be the working directory)
    (in windows the file or folder can be accessed by several groups, but in linux only by one user, one group and everyone)
    (but can use access control list to allow multiple groups to access file or folder)

    fali@ubuntu:~$sudo chmod u+w file1
    fali@ubuntu:~$sudo chmod g+r file1
    fali@ubuntu:~$sudo chmod o+x file1

    fali@ubuntu:~$sudo chmod -R u+w folder1

    fali@ubuntu:~$sudo chmod u-w file1
    fali@ubuntu:~$sudo chmod g-r file1
    fali@ubuntu:~$sudo chmod o-x file1

    fali@ubuntu:~$sudo chmod u+rwx,g+rw,o+x file1

    fali@ubuntu:~$sudo chmod u-rwx,g-rw,o-x file1

    ::::::::::::::Ownerships of files and folders:::::::::::::
    fali@ubuntu:~$sudo chown -R user1 folder1 (to change the user ownership of a folder and sub-folders)
    fali@ubuntu:~$sudo chown user1 file1 (to change the user ownership of a file)

    fali@ubuntu:~$sudo chgrp -R group1 folder1 (to change the group ownership of the folder and sub-folders)
    fali@ubuntu:~$sudo chgrp group1 file1 (to change the group ownership of the file)

    fali@ubuntu:~$ls -l
    drwxrwxrwx 2 root root 4096 test1
    (first root is the user-owner and the second root is the group-owner)

    fali@ubuntu:~$sudo chgrp -R ali folder1
    fali@ubuntu:~$ls -l
    drwxrwxrwx 2 ali root 4096 test1

    fali@ubuntu:~$sudo chgrp -R testgroup1 folder1
    fali@ubuntu:~$ls -l
    drwxrwxrwx 2 ali testgroup 4096 test1

    (changing ownership in one line)(-R is for recursive in case of a folder)
    fali@ubuntu:~$sudo chown ali:marketing file1
    fali@ubuntu:~$sudo chown -R ali:marketing folder1

  • Unix vs. Linux (Difference)

    Difference Between Linux and UNIX

    What is the difference between Linux and UNIX operating systems?

    UNIX is copyrighted name only big companies are allowed to use the UNIX copyright and name, so IBM AIX and Sun Solaris and HP-UX all are UNIX operating systems. The Open Group holds the UNIX trademark in trust for the industry, and manages the UNIX trademark licensing program.

    Most UNIX systems are commercial in nature.

    Linux is a UNIX Clone

    But if you consider Portable Operating System Interface (POSIX) standards then Linux can be considered as UNIX. To quote from Official Linux kernel README file:

    Linux is a Unix clone written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX compliance.

    However, “Open Group” do not approve of the construction “Unix-like”, and consider it misuse of their UNIX trademark.

    Linux Is Just a Kernel

    Linux is just a kernel. All Linux distributions includes GUI system + GNU utilities (such as cp, mv, ls,date, bash etc) + installation & management tools + GNU c/c++ Compilers + Editors (vi) + and various applications (such as OpenOffice, Firefox). However, most UNIX operating systems are considered as a complete operating system as everything come from a single source or vendor.

    As I said earlier Linux is just a kernel and Linux distribution makes it complete usable operating systems by adding various applications. Most UNIX operating systems comes with A-Z programs such as editor, compilers etc. For example HP-UX or Solaris comes with A-Z programs.

    License and cost

    Linux is Free (as in beer [freedom]). You can download it from the Internet or redistribute it under GNU licenses. You will see the best community support for Linux. Most UNIX like operating systems are not free (but this is changing fast, for example OpenSolaris UNIX). However, some Linux distributions such as Redhat / Novell provides additional Linux support, consultancy, bug fixing, and training for additional fees.

    User-Friendly

    Linux is considered as most user friendly UNIX like operating systems. It makes it easy to install sound card, flash players, and other desktop goodies. However, Apple OS X is most popular UNIX operating system for desktop usage.

    Security Firewall Software

    Linux comes with open source netfilter/iptables based firewall tool to protect your server and desktop from the crackers and hackers. UNIX operating systems comes with its own firewall product (for example Solaris UNIX comes with ipfilter based firewall) or you need to purchase a 3rd party software such as Checkpoint UNIX firewall.

    Backup and Recovery Software

    UNIX and Linux comes with different set of tools for backing up data to tape and other backup media. However, both of them share some common tools such as tar, dump/restore, and cpio etc.

    File Systems

    • Linux by default supports and use ext3 or ext4 file systems.
    • UNIX comes with various file systems such as jfs, gpfs (AIX), jfs, gpfs (HP-UX), jfs, gpfs (Solaris).

    System Administration Tools

    1. UNIX comes with its own tools such as SAM on HP-UX.
    2. Suse Linux comes with Yast
    3. Redhat Linux comes with its own gui tools called redhat-config-*.

    However, editing text config file and typing commands are most popular options for sys admin work under UNIX and Linux.

    System Startup Scripts

    Almost every version of UNIX and Linux comes with system initialization script but they are located in different directories:

    1. HP-UX – /sbin/init.d
    2. AIX – /etc/rc.d/init.d
    3. Linux – /etc/init.d

    End User Perspective

    The differences are not that big for the average end user. They will use the same shell (e.g. bash or ksh) and other development tools such as Perl or Eclipse development tool.

    System Administrator Perspective

    Again, the differences are not that big for the system administrator. However, you may notice various differences while performing the following operations:

    1. Software installation procedure
    2. Hardware device names
    3. Various admin commands or utilities
    4. Software RAID devices and mirroring
    5. Logical volume management
    6. Package management
    7. Patch management

    UNIX Operating System Names

    A few popular names:

    1. HP-UX
    2. IBM AIX
    3. Sun Solairs
    4. Mac OS X
    5. IRIX

    Linux Distribution (Operating System) Names

    A few popular names:

    1. Redhat Enterprise Linux
    2. Fedora Linux
    3. Debian Linux
    4. Suse Enterprise Linux
    5. Ubuntu Linux

    Common Things Between Linux & UNIX

    Both share many common applications such as:

    1. GUI, file, and windows managers (KDE, Gnome)
    2. Shells (ksh, csh, bash)
    3. Various office applications such as OpenOffice.org
    4. Development tools (perl, php, python, GNU c/c++ compilers)
    5. Posix interface

    A Sample UNIX Desktop Screenshot

    UNIX Desktop - IRIX 6.5 Desktop

    A Sample Linux Desktop Screenshot

    Linux KDE desktop environment

    UNIX and Linux Hardware

    Commercial UNIX hardware has more advanced initial boot options such as:

    • Decide how to boot
    • Check system health
    • Set hardware parameters etc

    The BIOS that is standard in PCs which is used by Linux has few, of these features. UNIX hardware or servers are pretty expensive as compare to Linux server systems.

     

    Comparison chart

    Linux

    Unix

    What is it? Linux is an example of Open Source software development and Free Operating System (OS). Unix is an operating system that is very popular in universities, companies, big enterprises etc.
    Cost Linux can be freely distributed, downloaded freely, distributed through magazines, Books etc. There are priced versions for Linux also, but they are normally cheaper than Windows. Different flavors of Unix have different cost structures according to vendors
    User Everyone. From home users to developers and computer enthusiasts alike. Unix operating systems were developed mainly for mainframes, servers and workstations except OSX, Which is designed for everyone. The Unix environment and the client-server program model were essential elements in the development of the Internet
    Manufacturer Linux kernel is developed by the community. Linus Torvalds oversees things. Three bigest distributions are Solaris (Oracle), AIX (IBM) & HP-UX Hewlett Packard. And Apple Makes OSX, an unix based os..
    Usage Linux can be installed on a wide variety of computer hardware, ranging from mobile phones, tablet computers and video game consoles, to mainframes and supercomputers. The UNIX operating system is used in internet servers, workstations & PCs. Backbone of the majority of finance infastructure and many 24×365 high availability solutions.
    Development and Distribution Linux is developed by Open Source development i.e. through sharing and collaboration of code and features through forums etc and it is distributed by various vendors. Unix systems are divided into various other flavors, mostly developed by AT&T as well as various commercial vendors and non-profit organizations.
    GUI Linux typically provides two GUIs, KDE and Gnome. But there are millions of alternatives such as LXDE, Xfce, Unity, Mate, twm, ect. Initially Unix was a command based OS, but later a GUI was created called Common Desktop Environment. Most distributions now ship with Gnome.
    File system support Ext2, Ext3, Ext4, Jfs, ReiserFS, Xfs, Btrfs, FAT, FAT32, NTFS jfs, gpfs, hfs, hfs+, ufs, xfs, zfs format
    Text mode interface BASH (Bourne Again SHell) is the Linux default shell. It can support multiple command interpreters. Originally the Bourne Shell. Now it’s compatible with many others including BASH, Korn & C.
    Price Free but support is available for a price. Some free for development use (Solaris) but support is available for a price.
    Security Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays. A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.
    Threat detection and solution In case of Linux, threat detection and solution is very fast, as Linux is mainly community driven and whenever any Linux user posts any kind of threat, several developers start working on it from different parts of the world Because of the proprietary nature of the original Unix, users have to wait for a while, to get the proper bug fixing patch. But these are not as common.
    Processors Dozens of different kinds. x86/x64, Sparc, Power, Itanium, PA-RISC, PowerPC and many others.
    Examples Ubuntu, Fedora, Red Hat, Debian, Archlinux, Android etc. OS X, Solaris, All Linux
    Architectures Originally developed for Intel’s x86 hardware, ports available for over two dozen CPU types including ARM is available on PA-RISC and Itanium machines. Solaris also available for x86/x64 based systems.OSX is PowerPC(10.0-10.5)/x86(10.4)/x64(10.5-10.8)
    Inception Inspired by MINIX (a Unix-like system) and eventually after adding many features of GUI, Drivers etc, Linus Torvalds developed the framework of the OS that became LINUX in 1992. The LINUX kernel was released on 17th September, 1991 In 1969, it was developed by a group of AT&T employees at Bell Labs and Dennis Ritchie. It was written in “C” language and was designed to be a portable, multi-tasking and multi-user system in a time-sharing configuration.