Which Linux Kernel, What Distro, 32-bit or 64-bit?

 Command Line, Linux  Comments Off on Which Linux Kernel, What Distro, 32-bit or 64-bit?
Jan 012015
 

On the terminal, there are a plethora of commands that spit out answers to questions about the Linux kernel and/or the Linux distribution underpinning your system.

Let’s take a deko at a few of them.

Some of the below commands give only the distro, others mention just the kernel version and a few provide information on the kernel, distro and whether it’s a 32-bit or 64-bit Linux OS.

Inxi

My favorite command line tool inxi provides details on kernel, distribution and whether you’re running a 32-bit or 64-bit OS.

$ inxi -S
System:    Host: Tanya Kernel: 3.13.0-24-generic i686 (32 bit) Desktop: Gnome Distro: Linux Mint 17.1 Rebecca

Some distributions like Linux Mint come with inxi pre-installed.

If inxi is not on your system, I strongly recommend you get it asap.

You can easily install inxi by running the below command:

Ubuntu/Debian Users

sudo apt-add-repository ppa:unit193/inxi && apt-get update

Once you’ve completed the above step, then run the below command to complete installation of inxi.

apt-get install inxi

CentOS/Fedora Users

$ sudo yum install inxi

Uname Commands

For a quick glance at just the kernel version on your computer, try either of the below commands.

$ uname -r
3.13.0-24-generic

or

$ uname -mrs
Linux 3.13.0-24-generic i686

The i686 notation (above) means that it’s a 32-bit OS.

$ uname -a
Linux Sasha 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux

Uname is easy to remember for kernel information but not so great for distribution details because even if you’re running Linux Mint it’ll tell you Ubuntu (the foundation of Linux Mint).

Cat /etc

For a quick glance at the Linux distribution on your computer, go for the below command.

$ cat /etc/issue
Linux Mint 17.1 Rebecca \n \l

For a more detailed explanation, try the below command:

$ cat /etc/*release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=17.1
DISTRIB_CODENAME=rebecca
DISTRIB_DESCRIPTION="Linux Mint 17.1 Rebecca"
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"

If all you’re interested in is whether it’s 32-bit OS or 64-bit OS, go for the below command.

$ getconf LONG_BIT
32

Here’s annother way to find out if your computer is running a 32-bit or 64-bit Linux.

$ file /sbin/init
/sbin/init: ELF 32-bit LSB  shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=c394677bccc720a3bb4f4c42a48e008ff33e39b1, stripped

Need one more way to find out if your Linux OS is 32-bit or 64-bit?

OK, here we go.

$ arch
i686

Simple as pie, right?

Lsb Method

Now before I run out steam, let me show you one more way to check your Linux distribution and its version.

$ lsb_release -a
No LSB modules are available.
Distributor ID:	LinuxMint
Description:	Linux Mint 17.1 Rebecca
Release:	17.1
Codename:	rebecca


Note
: I can get lsb_release -a to work on LinuxMint/Ubuntu computers but it does not work on CentOS.

Folks, as you’ve seen from the various options I’ve outlined above, there are several ways to bell a Linux distribution or kernel cat. 😉

Pick whichever one suits you best.

CentOS 7 – Making It More User Friendly

 Linux, Open Source  Comments Off on CentOS 7 – Making It More User Friendly
Dec 182014
 

Making CentOS 7 More User Friendly
Cent OS 7 with Gnome 3 has a bunch of vexing issues.

Fortunately, the issues can be easily fixed.

I did a minimal install and then set up Gnome 3 desktop on it.

Icons on Desktop

But one thing I found vexing was the inability to place shortcuts for applications on the desktop, something I could do easily with my other Linux distros like Ubuntu, Linux Mint etc, Mac or any Windows PC.

And then I discovered a solution to the problem of placing shortcuts on the Gnome 3 desktop.

Here’s how you can get application shortcuts on the Gnome 3 desktop in CentOS 7:

1. Click on home folder on desktop. The file browser window will open.

2. Next, click the Computer tab in the left navigation panel and go to /usr/share/applications. Now you should see all the applications icons in the right browser window.

3. Right click on any icon (calculator, Firefox browser, Contacts etc) that you want on the desktop.

4. After right clicking the icon, select Copy To in the context menu. A Select Destination will open up, now pick Desktop folder in the left navigation panel (via left-click)

5. Finally left-click the Select button in the bottom right of the window.

Remember the steps:

(Right-Click) Application Icon->Copy To (in Context Menu)->Select Destination->Desktop->Select

Voila, the icon shortcuts to your favorite applications should now appear on your desktop.

Tackling Panel Issue

Unfortunately, placing application shortcuts on the desktop is not the only issue with CentOS 7 (running Gnome 3).

There’s also the top panels issue.

For those struggling to add launchers to the horizontal panel bar, here’s the solution.

$ yum install gnome-shell-browser-plugin

After installing the plugin, navigate to https://extensions.gnome.org on your Firefox browser

In the search box, type Frippery Panel Favorites. After you click on Frippery Panel Favorites in the search results, a slider button will appear in the browser window. Slide it to On position and you will be given the option to Download and Install Frippery Panel Favorites from extensions.gnome.org. Click Install and you’ll have your favorites on the top panel.

You can add other extensions similarly by visiting the Gnome Extensions page on your Firefox browser

By the way, there’s also a way to edit applications in the Favorites/Panel list and the order they appear in.

Here’s how you do it.

1. Press the Windows key on your keyboard to get Overview overlay
2. Right-click any app in the left side-menu that you don’t like and remove it via the context menu
3. Open the Show Applications (nine white dots) icon at bottom of left-side menu
4. Now right-click on any application icon and select “Add to Favorites”
5. Change the order of icons in Favorites and on the Panel by dragging the applications up or down

After making the above changes, your CentOS 7 PC (with the Gnome 3 desktop) will be a friendlier, easier-to-use system than before.

CentOS 7 is a solid Linux distribution and with just a little extra effort we can make it a breeze to use.

Hope you enjoyed this post.

Deadly Linux Vulnerability Uncovered

 Linux, Security  Comments Off on Deadly Linux Vulnerability Uncovered
Dec 162014
 

A security alert by cloud and security services provider Alert Logic warns of a dangerous vulnerability in the Linux authorization system that allows privilege escalation through “wheel” to unauthorised users.

Wheel is a special user group controlling access to su command, and thereby superuser privileges.

The vulnerability permits unauthorized users to get root access, which in essence means gaining control of the entire system to do whatever malicious actions they want to.

Named “Grinch” (after Dr.Seuss’ unsavory fictional character), the vulnerability is considered serious because of Linux’ sway in e-commerce deployments.

Surveys have found that Linux/Unix power 65% of web servers.

The vulnerability is said to span all Linux distros including mobile platforms like Android that are based on Linux.

Although no patch is available yet, recommendations to avoid the exploit being triggered include studying logs to monitor user actions on the system and avoiding installation tools like PKCon (PackageKit Console Client). Safer to stick with installation tools like Yum or dnf.

According to Alert Logic’s Chief Security Evangelist Stephen Coty, the fix for the vulnerability lies in managing PolKit authorization rules or properly managing group privileges for users.

Red Hat, the maintainer of PolKit, is said to have opened a ‘trouble ticket’ to examine the vulnerability.

Related Content
Stephen Coty Blog Post

Inxi – A Nonpareil Command Line Tool

 Command Line, Linux  Comments Off on Inxi – A Nonpareil Command Line Tool
Dec 132014
 

Although there are solid GUI tools like hardinfo and sysinfo that provide a cornucopia of hardware, software and even networking information about your Linux system, nothing beats inxi for those who live, breathe and die on the command line.

The beauty of inxi is that it provides its output in an easy to read format.

How to Install Inxi

Unfortunately inxi does not come installed by default on any of the distros (Linux Mint, Ubuntu, Red Hat and Kali) I’ve explored.

But installing inxi is not a hard task.

It takes no more than a couple of minutes to get it running on your Linux system.

* Ubuntu/Debian users should run the below command to install inxi on their systems (inxi script may come pre-installed on Linux Mint):

# sudo apt-get install inxi

* CentOS/Fedora users must run the following command:

# sudo yum install inxi

inxi – Various Commands

Now let’s take a dekko at some of the key inxi commands.

Single Line
$ inxi -c 6
CPU~Quad core Intel Core2 Quad CPU Q9400 (-MCP-) clocked at 2659.881 Mhz Kernel~3.13.0-24-generic i686 
Up~2 days Mem~1350.7/3875.8MB HDD~2000.4GB(8.4% used) Procs~198 Client~Shell inxi~1.8.4

You get the essentials of your Linux system including processor, harddisk, memory etc on a single line (on your terminal, the info should be in a single line but I’ve split up the output above for lack of space).

Display Basic Information
$ inxi -b
System:    Host: Sasha Kernel: 3.13.0-24-generic i686 (32 bit) Desktop: Gnome Distro: Linux Mint 17.1 Rebecca
Machine:   System: Dell product: OptiPlex 780
           Mobo: Dell model: 03NVJ6 version: A02 Bios: Dell version: A14 date: 08/21/2012
CPU:       Quad core Intel Core2 Quad CPU Q9400 (-MCP-) clocked at 2659.881 MHz 
Graphics:  Card: Intel 4 Series Chipset Integrated Graphics Controller 
           X.Org: 1.15.1 drivers: intel (unloaded: fbdev,vesa) Resolution: 1600x900@60.0hz 
           GLX Renderer: Mesa DRI Intel Q45/Q43 x86/MMX/SSE2 GLX Version: 2.1 Mesa 10.1.0
Network:   Card: Intel 82567LM-3 Gigabit Network Connection driver: e1000e 
Drives:    HDD Total Size: 2000.4GB (8.4% used)
Info:      Processes: 199 Uptime: 3 days Memory: 1408.6/3875.8MB Client: Shell inxi: 1.8.4
Display Audio Card Info
$ inxi -A
Audio:     Card: Intel 82801JD/DO (ICH10 Family) HD Audio Controller driver: snd_hda_intel
           Sound: Advanced Linux Sound Architecture ver: k3.13.0-24-generic
Show Graphics Card Info

Check out the below command for details on graphics card in your Linux system.

$ inxi -G
Graphics:  Card: Intel 4 Series Chipset Integrated Graphics Controller 
           X.Org: 1.15.1 drivers: intel (unloaded: fbdev,vesa) Resolution: 1600x900@60.0hz 
           GLX Renderer: Mesa DRI Intel Q45/Q43 x86/MMX/SSE2 GLX Version: 2.1 Mesa 10.1.0
Show CPU Info
$ inxi -C
CPU:       Quad core Intel Core2 Quad CPU Q9400 (-MCP-) cache: 3072 KB flags: (lm nx sse sse2 sse3 sse4_1 ssse3 vmx) 
           Clock Speeds: 1: 2659.881 MHz 2: 2659.881 MHz 3: 2659.881 MHz 4: 2659.881 MHz
Information on Drives

The below inxi command provides details on both hard drives and optical drives.

$ inxi -d
Drives:    HDD Total Size: 2000.4GB (8.4% used) 1: id: /dev/sda model: SAMSUNG_ST2000LM003 size: 2000.4GB 
           Optical: /dev/sr0 model: N/A dev-links: cdrom
           Features: speed: 8x multisession: yes audio: yes dvd: yes rw: cd-r,cd-rw,dvd-r,dvd-ram
Display Machine Information

The following command should give you information on system name, model, motherboard, bios

$ inxi -M
Machine:   System: Dell product: OptiPlex 780
           Mobo: Dell model: 03NVJ6 version: A02 Bios: Dell version: A14 date: 08/21/2012
Display WAN IP Address
$ inxi -i
Network:   Card: Intel 82567LM-3 Gigabit Network Connection driver: e1000e 
           IF: eth1 state: up speed: 100 Mbps duplex: full mac: 84:2b:2b:ba:ec:21
           WAN IP: 213.238.170.107 IF: eth1 ip: 10.0.1.5
Show Partition Information
$ inxi -p
Partition: ID: / size: 1.8T used: 158G (10%) fs: ext4 ID: /boot size: 236M used: 44M (20%) fs: ext2 
           ID: swap-1 size: 4.12GB used: 0.02GB (1%) fs: swap
Display Full Information

Of all the inxi commands, inxi -F provides the maximum data covering all aspects of the computer.

$ inxi -F
System:    Host: Sasha Kernel: 3.13.0-24-generic i686 (32 bit) Desktop: Gnome Distro: Linux Mint 17.1 Rebecca
Machine:   System: Dell product: OptiPlex 780
Mobo: Dell model: 03NVJ6 version: A02 Bios: Dell version: A14 date: 08/21/2012
CPU:       Quad core Intel Core2 Quad CPU Q9400 (-MCP-) cache: 3072 KB flags: (lm nx sse sse2 sse3 sse4_1 ssse3 vmx)
Clock Speeds: 1: 2659.881 MHz 2: 2659.881 MHz 3: 2659.881 MHz 4: 2659.881 MHz
Graphics:  Card: Intel 4 Series Chipset Integrated Graphics Controller
X.Org: 1.15.1 drivers: intel (unloaded: fbdev,vesa) Resolution: 1600x900@60.0hz
GLX Renderer: Mesa DRI Intel Q45/Q43 x86/MMX/SSE2 GLX Version: 2.1 Mesa 10.1.0
Audio:     Card: Intel 82801JD/DO (ICH10 Family) HD Audio Controller driver: snd_hda_intel
Sound: Advanced Linux Sound Architecture ver: k3.13.0-24-generic
Network:   Card: Intel 82567LM-3 Gigabit Network Connection driver: e1000e
IF: eth1 state: up speed: 100 Mbps duplex: full mac: 84:2b:2b:ba:ec:21
Drives:    HDD Total Size: 2000.4GB (8.4% used) 1: id: /dev/sda model: Samsung_ST2000LM003 size: 2000.4GB
Partition: ID: / size: 1.8T used: 158G (10%) fs: ext4 ID: /boot size: 236M used: 44M (20%) fs: ext2
ID: swap-1 size: 4.12GB used: 0.02GB (1%) fs: swap
RAID:      No RAID devices detected - /proc/mdstat and md_mod kernel raid module present
Sensors:   System Temperatures: cpu: 30.0C mobo: N/A
Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 194 Uptime: 2 days Memory: 1113.1/3875.8MB Client: Shell inxi: 1.8.4

Go ahead, take inxi for a spin on your Linux system.

You’ll be surprised at how much information you can gather on your system via the inxi command.

Don’t forget to check the man pages for inxi by running:

$ man inxi

on the command line to get a list of the various inxi options.

Related inxi Content
Information about Inxi
Inxi Installation

Netstat Cheat Sheet for Newbies

 Command Line, Linux  Comments Off on Netstat Cheat Sheet for Newbies
Dec 132014
 

Of the several command line tools available to Linux administrators, netstat ranks among the most useful.

Netstat displays network connections for Transmission Control Protocol (incoming and outgoing), routing tables, and several network interface and network protocol statistics.

Although some Linux administrators are known to grumble that ss is a newer, better and faster tool performing similar chores, netstat still rules with the majority of Linux systems administrators including yours truly.

Besides helping to resolve networking issues, the other reason netstat is a valuable tool for Linux systems administrators is because it can serve as a first line of defense in identifying potentially hostile visitors harboring malicious intentions.

Besides Linux, netstat can be used on BSD, Windows XP, Windows Vista, Windows 7 and Windows 8 operating systems.

Netstat – Key Commands

The various options available for netstat are far too numerous to be detailed in full here.

In this post, we’ll consider the most important netstat commands. These are commands no Linux administrator can do without.

Display All Connections
$ netstat -a

Above command lists all connections from different protocols like tcp, udp and unix sockets

List Only TCP connections
$ netstat -at
List Only UDP Connections
$ netstat -au
Show IP Address without Reverse DNS lookup
$ netstat -ant
List All Listening Conditions
$ netstat -l
List Only Listening TCP Ports
$ netstat -lt
List only listening UDP Ports
$ netstat -lu
Display Summary Statistics
$ netstat -s

The above command spits out a wealth of information including total packets received, incoming packets delivered, active TCP connections, failed TCP connection attempts etc.

You can spend the better part of a day analyzing the output. 😉

To print out statistics of only select protocols like TCP or UDP use the corresponding options like t and u along with the s option.

Display Statistics for TCP
$ netstat -st
Display Statistics for UDP
$ netstat -su
Displays Domain Name Where Possible for IP Address
$ netstat -F
Display Only IP address
$ netstat -n

Above command will display output without resolving host, port and user name.

Get Netstat Output Continuously
$ netstat -c

The -c option can be combined with other netstat options like -t (see below).

$ netstat -ct
Displays TCP Connections Continuously
$ netstat -tcp

Above command will output TCP connections along with PID continuously.

Display Process Identifier (PID)
$ netstat -p

Above command adds PID/program name to output.

The -p option can be combined with other options (see below).

Show Service Name with PID Number
$ netstat -tp

Continue reading »

Memory – Ultimate ‘Free’ Cheat Sheet

 Command Line, Linux  Comments Off on Memory – Ultimate ‘Free’ Cheat Sheet
Dec 122014
 

There’s nothing more crucial to a computer or server than memory.

Information on memory installed, memory used and memory free are indispensable data to any Linux system administrator.

Should memory on your system be inadequate for the load, the results will be most unpleasant to users.

The best way to understand memory use and availability on your Linux system is via the ‘free‘ command, a feature that comes with most Linux installations.

Understanding Memory

Before jumping into the nuances of the “free” command, let’s spend a few seconds to understand the basic memory concepts.
* Physical Memory – Amount of memory installed and currently used
* Real Memory – How much memory is used by the applications
* Swap Memory – Portion of virtual memory on hard disk that’s used when RAM is full (high swap memory usage is not good)
* Virtual Memory – Combination of RAM and disk space that running processes can leverage

Free – Basics

On the command line, we use free to get information about memory use on a Linux desktop or server.

In this post, let’s consider the various options for free.

usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
-b,-k,-m,-g show output in bytes, KB, MB, or GB
-l show detailed low and high memory statistics
-o use old format (no -/+buffers/cache line)
-t display total for RAM + swap
-s update every [delay] seconds
-c update [count] times
-V display version information and exit

Free – Various Commands

Let’s start with the basic command.

jason@ChristyPC ~ $ free
             total       used       free     shared    buffers     cached
Mem:       3968848    3352196     616652     200544     225512    2040400
-/+ buffers/cache:    1086284    2882564
Swap:      4022268       2016    4020252

In the above example from my Linux Mint desktop, the three lines represent physical memory, real memory and swap memory respectively.

The “used” memory in the first line is misleading because Linux systems take into account even buffer and cache.

So when you run the free command, the second line representing real memory is the most important line in understanding memory use on your computer.

In the above example, there’s still 2.88GB of free memory available, which means I’m in a comfortable zone on my Linux Mint desktop.

Display Free Output in Human Understandable Format

Sometimes command line outputs are needlessly complicated.

Thankfully, there are simple ways out.

jason@ChristyPC ~ $ free -h
             total       used       free     shared    buffers     cached
Mem:          3.8G       3.4G       387M       217M       219M       2.0G
-/+ buffers/cache:       1.1G       2.6G
Swap:         3.8G        68K       3.8G

The above command worked fine on Ubuntu and Linux Mint and by extension should work on all Debian systems.

Note: Unfortunately, on Red Hat Linux systems the free -h command does not work.

I got an an error message (see below) when I ran the free -h command on a Red Hat system:

jason@ChristyPC ~ $ free -h
free: invalid option -- h
Display Memory in Gigabytes

You have the option to display in gigabytes, megabytes etc.

Let’s look at the command for free in gigabyte format since it’s easy to understand at just a glance.

jason@ChristyPC ~ $ free -g
             total       used       free     shared    buffers     cached
Mem:             3          3          0          0          0          1
-/+ buffers/cache:          1          2
Swap:            3          0          3

Continue reading »