Sunday, 25 January 2015

Tutorial on "chkconfig" Command in Linux with Examples

    Whenever a new service (like Samba or NFS) is added to a Linux system, it is not configured to start automatically when the system starts up. So, by default, whenever you add a new service, you'll have to start it manually after the system reboots. 'chkconfig' command allows you to configure that newly added service to start after every system start up automatically. Not only this, you can change the configuration so as to add any service at different run-levels. With 'chkconfig' you can display the list of services those are configured for startup at a particular run-level.



This article explains the use of 'chkconfig' command in Linux.

1. Check Service Status

With 'chkconfig', you can determine whether a service is configured for startup, using the 'exit status' of the command. For this, just mention the service name as an argument to 'chkconfig' command. If the service is configured for startup, it's exit status will be '0', if not then it will be '1' (or non-zero).

Note: Exit status of any command can be determined by executing echo $? immediately after that command is executed. Exit status '0' denotes successful command execution, while non-zero exit status indicates that there was some error in executing that command or the command failed to execute.

Syntax:

chkconfig <SERVICE-NAME>
Example:

MyLinuxBox mandar ~ > chkconfig sshd
MyLinuxBox mandar ~ > echo $?
0
MyLinuxBox mandar ~ > chkconfig smbd
MyLinuxBox mandar ~ > echo $?
1
You can make use of this exit status in a bash script as follows (provide service name as an argument to the script):

#!/bin/bash

chkconfig $1

if [ $1 -eq 0 ]
then
    echo "Service $1 is configured for startup."
else
    echo "Service $1 is not configured for startup."
fi
Or simply:

#!/bin/bash
(chkconfig $1 && echo "Configured!") || echo "Not Configured."

2. Display configuration status of all services

When 'chkconfig' is executed with option --list, it will display all the services and their startup configuration status.

MyLinuxBox mandar ~ > chkconfig --list
NetWorkManager   0:off   1:off   2:off   3:on    4:off   5:on    6:off
abrtd            0:off   1:off   2:off   3:on    4:off   5:on    6:off
acpid            0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd              0:off   1:off   2:off   3:on    4:on    5:on    6:off
.
.
.
.
As above command will display all configuration of all the services, it might be very difficult to locate a particular service in that long list. Here, 'grep' would come to the rescue. Let's verify the startup configuration of 'sshd' once again.

MyLinuxBox mandar ~ > chkconfig --list | grep sshd
sshd   0:off   1:off   2:on    3:on    4:on    5:on    6:off
With the combination of chkconfig and grep, you can find all the services which have been configured to start at a particular run-level, as follows:

Syntax:

chkconfig --list | grep 3:on

3. Adding and Deleting Services

'chkconfig' command with the options --add and --del would add and delete, respectively, services would be turned on the run-levels 2 through 5. Let's suppose, we have newly installed 'vsftpd' on our system. So, its startup configuration would look like:

MyLinuxBox mandar ~ > chkconfig --list | grep vsftpd
vsftpd   0:off   1:off   2:off   3:off   4:off   5:off   6:off
Lets add it to the startup configuration.

MyLinuxBox mandar ~ > chkconfig --add vsftpd
MyLinuxBox mandar ~ > chkconfig --list | grep vsftpd
vsftpd   0:off   1:off   2:on    3:on   4:on    5:on    6:off
Lets now remove the 'vsftpd' service from the startup list.

MyLinuxBox mandar ~ > chkconfig --del vsftpd
MyLinuxBox mandar ~ > chkconfig --list | grep vsftpd
vsftpd   0:off   1:off   2:off   3:off   4:off   5:off   6:off

4. Add or Remove a Service at a particular run-level

'chkconfig' command when executed with --add or --del options, it would impact all the run-levels from 2 through 5. In order to turn on or off any particular service at a particular run-level, you can use:

chkconfig --level <LEVEL> <SERVICE> <on/off>
Example:
MyLinuxBox mandar ~ > chkconfig --level 35 vsftpd on
MyLinuxBox mandar ~ > chkconfig --list | grep vsftpd
vsftpd   0:off   1:off   2:off   3:on   4:off   5:off   6:off

MyLinuxBox mandar ~ > chkconfig --level 35 vsftpd off
MyLinuxBox mandar ~ > chkconfig --list | grep vsftpd
vsftpd   0:off   1:off   2:off   3:off   4:off   5:off   6:off

5. How it works?

Just take a look at /etc/rc.d directory and its contents. It has some directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d and rc6.d. Each directory is associated with a run-level. Whenever a service is added/removed to/from the startup, a file (or a script file rather) linking to the corresponding service in /etc/init.d is created in /etc/rc.d/rcX.d directory, where X is the run-level.

For example, if service 'vsftpd' is added to the startup at run-level 3, a script (with name somewhat like S24vsftpd) would be created in /etc/rc.d/rc3.d which will be linked to /etc/init.d/vsftpd file. If the service is removed from startup, the filename would still be pointing to the same file, but it's name would be something like 'K24vsftpd'.

Note: If the file name starts with 'S', the service will be started at that particular run-level, whereas if the file name starts with 'K', the service will be killed.

Check:
1. Make sure that 'vsftpd' is turned off at all levels.


2. Check in /etc/rc.d/rc3.d and /etc/rc.d/rc5.d directories for any scripts related to 'vsftpd' service.


Yes, as expected, we could find a file, whose name starts with 'K', in both rc3.d and rc5.d directories.
3. Add the 'vsftpd' service to the startup at run-levels 3 and 5.


4. Now, check again for any entries for 'vsftpd' in rc3.d and rc5.d directories.


Yes, there are !!

That's all for this article. Stay tuned for a lot more articles on various Linux commands.




Friday, 16 January 2015

A Bash Script to Install/Upgrade to Linux Kernel 3.18.3 in Ubuntu/Linux Mint

The Linux Kernel 3.18.3 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. The following BASH script, when executed, despite of the system architecture (valid only for i386, i686 and x86_64 based systems), installs Linux kernel 3.18.3 in your Linux systems.



Note: Make sure that you execute this script as a ROOT user.

Usage:

./script_name.sh
Script:

#!/bin/sh

# Check if the user is ROOT
if [ $(id -u) -ne 0 ]
then
    echo "You are not ROOT! Please login as ROOT."
    exit
fi

# Latest Available Kernel version
LatestKernel="3.18.3-031803-generic"

# Required Packages
Headers_All="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803_3.18.3-031803.201501161810_all.deb"
Headers_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803-generic_3.18.3-031803.201501161810_i386.deb"
Image_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-image-3.18.3-031803-generic_3.18.3-031803.201501161810_i386.deb"
Headers_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803-generic_3.18.3-031803.201501161810_amd64.deb"
Image_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-image-3.18.3-031803-generic_3.18.3-031803.201501161810_amd64.deb"

# Debian Packages
DEB="linux-headers-3.18.3*.deb linux-image-3.18.3*.deb"

# Currently Installed Kernel Version
CurrentKernel_release=$(uname -r) 

# System Architecture
SystemArch=$(uname -i)

# Check if System already has latest kernel installed
if [ "$CurrentKernel" = "$LatestKernel" ]
then
    echo "Wow! Your System is Already Updated to Latest Available Kernel Version!"
    echo "Program will now exit..."
    sleep 2s
    exit
fi

# If latest kernel is not available, then check the system architecture and download necessary packages

# For 32-bit Systems

if [ $SystemArch = "i386" ] || [ $SystemArch = "i686" ]
then

    echo "Kernel upgrade process for 32-bit systems will now start..."
    sleep 2s
    echo "Downloading required packages.."
    sleep 2s

    wget $Headers_All
    wget $Headers_i386
    wget $Image_i386

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# For 64-bit Systems
elif [ $SystemArch = "x86_64" ]
then
    echo "Kernel upgrade process for 64-bit systems will now start..." 
    sleep 2s

    wget $Headers_All
    wget $Headers_amd64
    wget $Image_amd64

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# If system architecture is not compatible
else
    echo "Packages for following system architecture not found :  $SystemArch"
    echo "Program will now exit..."
    sleep 2s
exit
fi

    echo "Your system has been successfully upgraded to latest kernel version $(LatestKernel)."
    echo "System will now reboot."
    sleep 5s
    shutdown -r now
NOTE: Above script worked perfectly on my i386 system. I need confirmation from i686 and x86_64 users, if it works fine for them. Please suggest any changes to be incorporated.

How To : Install NVIDIA 346.35 Graphics Drivers in Ubuntu/Linux Mint Systems

    The latest version of Nvidia Graphics driver for Linux which is Nvidia 346.35 has been released and is available for download. It comes with plenty of fixes and changes. This article will guide you to install Nvidia 346.35 in Ubuntu and Linux Mint systems.


Fixes

  • Added support for the following GPUs:
    • GeForce 800A
      GeForce 800M
      GeForce GTX 970M
      GeForce GTX 980M
  • Added support for X.Org xserver ABI 19 (xorg-server 1.17).
  • Improved compatibility with recent Linux kernels.
  • Fixed a bug that prevented internal 4K panels on some laptops from being driven at a sufficient bandwidth to support their native resolutions.
  • Fixed a regression that prevented the NVIDIA kernel module from loading in some virtualized environments such as Amazon Web Services.
  • Fixed a regression that caused displays to be detected incorrectly on some notebook systems.
  • Fixed a bug that could cause X to freeze when using Base Mosaic.
  • Fixed a regression that prevented the NVIDIA X driver from recognizing Base Mosaic layouts generated by the nvidia-settings control panel.
  • Updated the NVIDIA X driver to reject frame packed interlaced HDMI 3D modes during mode validation. These modes were being validated by the driver, despite never having been supported.
  • Fixed a bug that prevented the console from being restored after forcefully terminating X, on some GPUs with multiple DisplayPort monitors attached. This bug also subsequently prevented X from being started following the failed console restoration.
More details in the Release Notes.

Installation

Remove currently installed graphics drivers.

sudo apt-get purge nvidia*
End the graphic session with the appropriate command from the list of commands given below:

# For Ubuntu LightDM [DEFAULT]
sudo service lightdm stop

#For Gnome GDM
sudo service gdm stop

#For Linux Mint MDM
sudo service mdm stop
Download the appropriate driver from the source. Here are the download links:
Make the installer file executable.

chmod +x ~/Downloads/NVIDIA-Linux-*-346.35.run
Run the executable installer file.

sudo sh ~/Downloads/NVIDIA-Linux-*-346.35.run
This will start the installation process. Follow the on-screen instructions to complete the process.

Note : Do not delete the installer file. It will be needed while removing/uninstalling the Nvidia 346.35 driver if it fails to work properly.

To uninstall,

sudo sh ~/Downloads/NVIDIA-Linux-*-346.35.run --uninstall

A Bash Script to Install/Upgrade to Linux Kernel 3.18.2 in Ubuntu/Linux Mint

The Linux Kernel 3.18.2 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. The following BASH script, when executed, despite of the system architecture (valid only for i386, i686 and x86_64 based systems), installs Linux kernel 3.18.2 in your Linux systems.



Note: Make sure that you execute this script as a ROOT user.

Usage:

./script_name.sh
Script:

#!/bin/sh

# Check if the user is ROOT
if [ $(id -u) -ne 0 ]
then
    echo "You are not ROOT! Please login as ROOT."
    exit
fi

# Latest Available Kernel version
LatestKernel="3.18.2-031802-generic"

# Required Packages
Headers_All="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802_3.18.2-031802.201501082011_all.deb"
Headers_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802-generic_3.18.2-031802.201501082011_i386.deb"
Image_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-image-3.18.2-031802-generic_3.18.2-031802.201501082011_i386.deb"
Headers_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802-generic_3.18.2-031802.201501082011_amd64.deb"
Image_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-image-3.18.2-031802-generic_3.18.2-031802.201501082011_amd64.deb"

# Debian Packages
DEB="linux-headers-3.18.2*.deb linux-image-3.18.2*.deb"

# Currently Installed Kernel Version
CurrentKernel_release=$(uname -r) 

# System Architecture
SystemArch=$(uname -i)

# Check if System already has latest kernel installed
if [ "$CurrentKernel" = "$LatestKernel" ]
then
    echo "Wow! Your System is Already Updated to Latest Available Kernel Version!"
    echo "Program will now exit..."
    sleep 2s
    exit
fi

# If latest kernel is not available, then check the system architecture and download necessary packages

# For 32-bit Systems

if [ $SystemArch = "i386" ] || [ $SystemArch = "i686" ]
then

    echo "Kernel upgrade process for 32-bit systems will now start..."
    sleep 2s
    echo "Downloading required packages.."
    sleep 2s

    wget $Headers_All
    wget $Headers_i386
    wget $Image_i386

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# For 64-bit Systems
elif [ $SystemArch = "x86_64" ]
then
    echo "Kernel upgrade process for 64-bit systems will now start..." 
    sleep 2s

    wget $Headers_All
    wget $Headers_amd64
    wget $Image_amd64

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# If system architecture is not compatible
else
    echo "Packages for following system architecture not found :  $SystemArch"
    echo "Program will now exit..."
    sleep 2s
exit
fi

    echo "Your system has been successfully upgraded to latest kernel version $(LatestKernel)."
    echo "System will now reboot."
    sleep 5s
    shutdown -r now
NOTE: Above script worked perfectly on my i386 system. I need confirmation from i686 and x86_64 users, if it works fine for them. Please suggest any changes to be incorporated.

A Bash Script to Install/Upgrade to Linux Kernel 3.18.1 in Ubuntu/Linux Mint

The Linux Kernel 3.18.1 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. The following BASH script, when executed, despite of the system architecture (valid only for i386, i686 and x86_64 based systems), installs Linux kernel 3.18.1 in your Linux systems.



Note: Make sure that you execute this script as a ROOT user.

Usage:

./script_name.sh
Script:

#!/bin/sh

# Check if the user is ROOT
if [ $(id -u) -ne 0 ]
then
    echo "You are not ROOT! Please login as ROOT."
    exit
fi

# Latest Available Kernel version
LatestKernel="3.18.1-031801-generic"

# Required Packages
Headers_All="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-headers-3.18.1-031801_3.18.1-031801.201412170637_all.deb"
Headers_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-headers-3.18.1-031801-generic_3.18.1-031801.201412170637_i386.deb"
Image_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-image-3.18.1-031801-generic_3.18.1-031801.201412170637_i386.deb"
Headers_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-headers-3.18.1-031801-generic_3.18.1-031801.201412170637_amd64.deb"
Image_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-image-3.18.1-031801-generic_3.18.1-031801.201412170637_amd64.deb"

# Debian Packages
DEB="linux-headers-3.18.1*.deb linux-image-3.18.1*.deb"

# Currently Installed Kernel Version
CurrentKernel_release=$(uname -r) 

# System Architecture
SystemArch=$(uname -i)

# Check if System already has latest kernel installed
if [ "$CurrentKernel" = "$LatestKernel" ]
then
    echo "Wow! Your System is Already Updated to Latest Available Kernel Version!"
    echo "Program will now exit..."
    sleep 2s
    exit
fi

# If latest kernel is not available, then check the system architecture and download necessary packages

# For 32-bit Systems

if [ $SystemArch = "i386" ] || [ $SystemArch = "i686" ]
then

    echo "Kernel upgrade process for 32-bit systems will now start..."
    sleep 2s
    echo "Downloading required packages.."
    sleep 2s

    wget $Headers_All
    wget $Headers_i386
    wget $Image_i386

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# For 64-bit Systems
elif [ $SystemArch = "x86_64" ]
then
    echo "Kernel upgrade process for 64-bit systems will now start..." 
    sleep 2s

    wget $Headers_All
    wget $Headers_amd64
    wget $Image_amd64

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# If system architecture is not compatible
else
    echo "Packages for following system architecture not found :  $SystemArch"
    echo "Program will now exit..."
    sleep 2s
exit
fi

    echo "Your system has been successfully upgraded to latest kernel version $(LatestKernel)."
    echo "System will now reboot."
    sleep 5s
    shutdown -r now
NOTE: Above script worked perfectly on my i386 system. I need confirmation from i686 and x86_64 users, if it works fine for them. Please suggest any changes to be incorporated.

How To: Install Linux Kernel 3.18.3 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.18.3 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.18.3 in your Ubuntu or Linux Mint system.


Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803_3.18.3-031803.201501161810_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803-generic_3.18.3-031803.201501161810_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-image-3.18.3-031803-generic_3.18.3-031803.201501161810_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.18.3*.deb linux-image-3.18.3*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803_3.18.3-031803.201501161810_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-headers-3.18.3-031803-generic_3.18.3-031803.201501161810_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.3-vivid/linux-image-3.18.3-031803-generic_3.18.3-031803.201501161810_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.18.3*.deb linux-image-3.18.3*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove 'linux-headers-3.18.3*' 'linux-image-3.18.3*'

How To : Install/Upgrade to Linux Kernel 3.19-RC4 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.19-RC4 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.19-RC4 in your Ubuntu or Linux Mint system.


Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-rc4-vivid/linux-headers-3.19.0-031900rc4_3.19.0-031900rc4.201501112135_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-rc4-vivid/linux-headers-3.19.0-031900rc4-generic_3.19.0-031900rc4.201501112135_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-rc4-vivid/linux-image-3.19.0-031900rc4-generic_3.19.0-031900rc4.201501112135_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.19*.deb linux-image-3.19*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-rc4-vivid/linux-headers-3.19.0-031900rc4_3.19.0-031900rc4.201501112135_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-rc4-vivid/linux-headers-3.19.0-031900rc4-generic_3.19.0-031900rc4.201501112135_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-rc4-vivid/linux-image-3.19.0-031900rc4-generic_3.19.0-031900rc4.201501112135_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.19*.deb linux-image-3.19*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove 'linux-headers-3.19*' 'linux-image-3.19*'

Monday, 12 January 2015

How To : Install TeamViewer 10 in Ubuntu/Linux Mint/Debian Systems


    TeamViewer is the most popular application that is mostly used to connect to any remote desktop around the world from your own system. Besides remote controlling TeamViewer can be used for desktop sharing, online meetings, web conferencing and file transfer between computers. This application is available for Windows, Mac, Linux and Android operating systems along with Windows Phones. This article will guide you to install latest version of Teamviewer which is TeamViewer 10 on your Ubuntu and Linux Mint systems.

What's New..?

  • Performance optimization : CPU Usage, HD voice transmission quality, faster logins.
  • Centralized setting possible : All the settings possible through a centralized management console.
  • Master whitelist : To allow only the authorized users reducing administrative overheads.
  • Conversation history and Chat groups
  • Improved image and video quality along with one-click video calls
  • You can now put your Display picture to easily get identified in the friends list.
  • Real-time session notes : To note down something important while the session is ongoing.
  • Idle session timeout : You need not worry about the idle sessions as they will be closed automatically after a timeout.
  • Easy file sharing : Integrated with Google drive and dropbox.
  • The whiteboard : To make the knowledge transfer more efficient.
 Refer to this page for more detailed information.

Installation


For 32-Bit Systems

$ sudo apt-get install gdebi

$ wget download.teamviewer.com/download/version_10x/teamviewer_linux.deb

$ sudo gdebi teamviewer_linux.deb

For 64-Bit Systems


$ sudo dpkg --add-architecture i386

$ sudo apt-get update

$ sudo apt-get install gdebi

$ wget download.teamviewer.com/download/version_10x/teamviewer_linux.deb

$ sudo gdebi teamviewer_linux.deb

To remove Teamviewer 10,

$ sudo apt-get remove teamviewer*

Saturday, 10 January 2015

A Bash Script to Install/Upgrade to Linux Kernel 3.17.8 in Ubuntu/Linux Mint

The Linux Kernel 3.17.8 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. The following BASH script, when executed, despite of the system architecture (valid only for i386, i686 and x86_64 based systems), installs Linux kernel 3.17.8 in your Linux systems.



Note: Make sure that you execute this script as a ROOT user.

Usage:

./script_name.sh
Script:

#!/bin/sh

# Check if the user is ROOT
if [ $(id -u) -ne 0 ]
then
    echo "You are not ROOT! Please login as ROOT."
    exit
fi

# Latest Available Kernel version
LatestKernel="3.17.8-031708-generic"

# Required Packages
Headers_All="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.8-vivid/linux-headers-3.17.8-031708_3.17.8-031708.201501081837_all.deb"
Headers_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.8-vivid/linux-headers-3.17.8-031708-generic_3.17.8-031708.201501081837_i386.deb"
Image_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.8-vivid/linux-image-3.17.8-031708-generic_3.17.8-031708.201501081837_i386.deb"
Headers_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.8-vivid/linux-headers-3.17.8-031708-generic_3.17.8-031708.201501081837_amd64.deb"
Image_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.8-vivid/linux-image-3.17.8-031708-generic_3.17.8-031708.201501081837_amd64.deb"

# Debian Packages
DEB="linux-headers-3.17.8*.deb linux-image-3.17.8*.deb"

# Currently Installed Kernel Version
CurrentKernel_release=$(uname -r) 

# System Architecture
SystemArch=$(uname -i)

# Check if System already has latest kernel installed
if [ "$CurrentKernel" = "$LatestKernel" ]
then
    echo "Wow! Your System is Already Updated to Latest Available Kernel Version!"
    echo "Program will now exit..."
    sleep 2s
    exit
fi

# If latest kernel is not available, then check the system architecture and download necessary packages

# For 32-bit Systems

if [ $SystemArch = "i386" ] || [ $SystemArch = "i686" ]
then

    echo "Kernel upgrade process for 32-bit systems will now start..."
    sleep 2s
    echo "Downloading required packages.."
    sleep 2s

    wget $Headers_All
    wget $Headers_i386
    wget $Image_i386

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# For 64-bit Systems
elif [ $SystemArch = "x86_64" ]
then
    echo "Kernel upgrade process for 64-bit systems will now start..." 
    sleep 2s

    wget $Headers_All
    wget $Headers_amd64
    wget $Image_amd64

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# If system architecture is not compatible
else
    echo "Packages for following system architecture not found :  $SystemArch"
    echo "Program will now exit..."
    sleep 2s
exit
fi

    echo "Your system has been successfully upgraded to latest kernel version $(LatestKernel)."
    echo "System will now reboot."
    sleep 5s
    shutdown -r now
NOTE: Above script worked perfectly on my i386 system. I need confirmation from i686 and x86_64 users, if it works fine for them. Please suggest any changes to be incorporated.

Friday, 9 January 2015

How To: Install Linux Kernel 3.18.2 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.18.2 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.18.2 in your Ubuntu or Linux Mint system.



Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802_3.18.2-031802.201501082011_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802-generic_3.18.2-031802.201501082011_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-image-3.18.2-031802-generic_3.18.2-031802.201501082011_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.18.2*.deb linux-image-3.18.2*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802_3.18.2-031802.201501082011_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-headers-3.18.2-031802-generic_3.18.2-031802.201501082011_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.2-vivid/linux-image-3.18.2-031802-generic_3.18.2-031802.201501082011_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.18.2*.deb linux-image-3.18.2*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove 'linux-headers-3.18.2*' 'linux-image-3.18.2*'

    Total Pageviews