How to Flush IPTables Chains Selectively

 Command Line, How To, Linux  Comments Off on How to Flush IPTables Chains Selectively
May 132015
 

IPtables are a priceless resource for system administrators to secure their servers.

Given the ceaseless attempt by hackers working for money or thrills, every Linux server administrator must grasp the basics of IPtables.

In this post, I will assume that you already have IPtables installed and running on your system.

Once in a while, there might be arise a situation where you’ll have to flush the IPtables rules.

What is flushing?

Flushing basically refers to deleting the IPtables rules in a single chain or all chains.

Now you should know the difference between flushing and deleting on the command line with reference to IPtables.

In flushing, you’re just deleting the rules in a chain. Continue reading »

How to Find Version of Packages on CentOS

 Command Line, How To, Linux  Comments Off on How to Find Version of Packages on CentOS
May 122015
 

Find Version of Packages on CentOS
Every now and then, there arises the necessity for Linux administrators to find out what version of a particular package is running on a CentOS, RedHat or Fedora system.

As is to be expected, the commands to find out which version of a package is installed on RedHat, CentOS and Fedora are different from the commands for Ubuntu and its derivatives like the popular Linux Mint.

There are multiple ways to get the version of packages installed on CentOS, RedHat and Fedora. You can do it via the command line or through GUI utilities.

In this post, we’ll check out five simple methods to determine package version via the command line.

1. The first command line option that comes to mind when checking for the version of an application or package on CentOS  is yum info package_name.

$ yum info PACKAGE_NAME

Let’s see what version of the clamtk anti-virus software is installed on our CentOS 7 desktop.

$ yum info clamtk
Installed Packages
Name        : clamtk
Arch        : noarch
Version     : 5.15
Release     : 1.el7
Size        : 1.3 M
Repo        : installed

2. The yumdb method provides more information compared to the previous option.

$ yumdb info PACKAGE_NAME

With yumdb info, you not only get the package version number but other details such as checksum of the package (and algorithm used to produce it, such as SHA-256), repository, which user installed it, or whether it landed on the system as a dependency.

Let’s check out the yumdb command with an example.

Why not see what version of python is installed on our Linux system.

$ yumdb info python
python-2.7.5-16.el7.x86_64
     checksum_data = b03c388fe3fe1c711249564c96902852d129a0f4faf8a27accd660bf42ebab4e
     checksum_type = sha256
     from_repo = anaconda
     from_repo_revision = 1404557011
     from_repo_timestamp = 1404557037
     installed_by = 4294967295
     reason = dep
     (and more)

3. There’s another easy to remember option, rpm -qa which queries all currently installed packages.

$ rpm -qa PACKAGE_NAME

One of my favorite newsreaders on Linux is quiterss.

In the below command, we’ll see which version of quiterss is installed. Continue reading »

Which Version of an App is Running on Ubuntu?

 Command Line, Linux  Comments Off on Which Version of an App is Running on Ubuntu?
May 122015
 

Many a time I’m flummoxed as to which version of an application/package is running on my Ubuntu (or Linux Mint) system.

For sure, finding the package version is not an issue when dealing with GUI apps like Libreoffice or the Cherrytree notes app. You just need to open the application and look under ‘about’ on the top menu bar. As simple as that!

Which App Version is Running on Ubuntu?

But for other non-GUI apps like, say the Guake terminal emulator or the Python version on your Ubuntu system, you must head to the command line.

So how do you find out the package version?

Thankfully, the command line provides several options to find out the package version installed on Ubuntu Linux.

On Ubuntu and its derivatives like Linux Mint, there are four ways to find out a package version.

1. The simplest way is the dpkg -l method.

$ dpkg -l PACKAGE_NAME

For instance, I know Cherrytree notes app is installed on my Linux desktop.

Let’s pull down our terminal and see what version of the notes appis running.

$ dpkg -l cherrytree
cherrytree  0.35.7-1~ppa1~trusty1 all  hierarchical note taking application

By the way, dpkg -s PACKAGE_NAME would work fine too.

2. There’s a second distinct method to check the installed version of a package on an Ubuntu, Kubuntu, Lubuntu or Linux Mint system.

$ apt-cache show PACKAGE_NAME

Let’s check out this command and see what version of the Guake terminal I have on my PC.

$ apt-cache show guake
Package: guake
Priority: optional
Section: universe/x11
Installed-Size: 762
Maintainer: Ubuntu Developers 
Original-Maintainer: Sylvestre Ledru 
Architecture: amd64
Version: 0.4.4-1ubuntu1
Provides: x-terminal-emulator

3. Now for the third method of finding out which version of an application is running on Ubunutu (and its derivatives). Continue reading »

8 Examples of Touch Command

 Command Line  Comments Off on 8 Examples of Touch Command
May 092015
 

Touch is a useful command to be aware for those new to Linux.

System administrators use touch to quickly create empty files.

But that’s not the only use for the touch command.

Linux and Unix administrators routinely use touch to change timestamp of files.

So what are timestamps?

In the Unix and Linux environments, all files are associated with timestamps. Timestamps provide information about files such as their last access, modification and change time.

Timestamps are valuable in compiling source code, used in scripts, creating backups and for applications deployed or used across multiple time zones.

Also, commands like ls and find leverage timestamps for listing and finding files respectively.

With that brief introduction to touch, let’s consider a few key options for touch and then follow it up with some examples.

Key Touch Command Options

-a, change access time only
-c, if file does not exist, do not create it
-d, update access and modification times
-m, change modification time only
-r, use access and modification times of file
-t, creates a file using a specified time

Touch Illustrations

1. Create an Empty File

The most frequent use of touch is to quickly create an empty file.

Let’s start with an example.

$ touch Example.txt

Voila, you now have a file called Example.txt. Continue reading »

How To Find CPU Details on Linux

 Command Line, How To  Comments Off on How To Find CPU Details on Linux
Apr 292015
 

Which Processor Running on Linux?The command line interface is so versatile that you can find considerable information about even the hardware side of your Linux server or desktop.

In this post, we’ll take a look at a bunch of commands that provide details about the CPU inside a Linux computer.

We’ll dig down for information on the CPU vendor, check if it’s 32-bit or 64-bit, look for the number of cores, frequency, cache size and more.

1. Let’s start with lscpu, a favorite of both users and system administrators.

LSCPU Output
A quick glance at the above output tells us that our Linux box has an Intel, quad-core, 64-bit processor running at 2000MHz.

2. Another favorite of system administrators is /proc/cpuinfo.

Use it with the less prefix since the output is big and quickly vanishes beyond the top of the screen.

Using CPUInfo with less

As with the previous command, we see that the output of /proc/cpuinfo provides information about the processor, vendor, cores and frequency.

In the following two examples, we’ll tweak /proc/cpuinfo to get only the information we need.

3. If you’re interested in just knowing the CPU vendor, go with cat /proc/cpuinfo along with with the grep command.

$ cat /proc/cpuinfo | grep vendor | uniq
vendor_id       : GenuineIntel

The output spits out just the vendor name, nothing more.

4. Now that we have the vendor info (above) let’s dig into details of the Intel processor.

$ cat /proc/cpuinfo | grep 'model name' | uniq
model name	: Intel(R) Core(TM)2 Quad CPU    Q9400  @ 2.66GHz

Voila, your PC runs on a Core 2 Quad core Q9400 processor at 2.66GHz. Not the latest and greatest of processors but adequate for most users.

5. Hardinfo is another handy utility that provides a wealth of information about your Linux system.

Although installed on the command line, hardinfo is actually a GTK based GUI utility.

If hardinfo is not installed on your Linux box, you can do so with the following command on your Ubuntu system.

$ sudo apt-get install hardinfo

If you ask me, hardinfo is an embarras de richesses. Besides the CPU, it provides details on most aspects of the Linux box including memory, storage, PCI devices, storage, USB devices etc plus information on the OS, kernel, and networking.

An extremely handy tool, hardinfo also lets you quickly generate a HTML report that you can save to your machine.

I cannot recommend hardinfo strongly enough. Continue reading »

Tasks on Command Line – Simple as Pie

 Command Line, Products  Comments Off on Tasks on Command Line – Simple as Pie
Apr 242015
 

Newton, Galileo, Dante and Shakespeare never used todo lists or notes apps to accomplish great feats.

Stalin and Hitler killed tens of millions without a single todo or notes app.

But lesser mortals, these days, it seems can’t function or get through the day without a collection of notes apps or todo lists on their PCs and mobile devices.

And if these apps are not cloud-powered to enable synchronization of the notes and todo lists across devices, the collective wrath of users descends on the hapless developer.

Such are the unusual times we live in!

Although I’m as guilty as the next Joe in hoarding notes and todo apps on my PC, tablet and smartphone, I’ve never been an intensive user of any of these apps. On the Mac, I use the free versions of Evernote and Eisenpower and on my Linux desktop my preferences are Task Coach and CherryTree.

If you ask me, there’s nothing you can’t accomplish by jotting down tasks on an index card. Nabokov famously wrote his masterpieces on index cards.

But lately I’ve been drawn to a todo utility called Taskwarrior.

A big plus of Taskwarrior for Linux administrators who live and breathe on the command line is that it’s convenient since you don’t have to go outside the command line and open an application to get to your todo list.

You see, Taskwarrior works essentially on the command line.

Installing Taskwarrior

Taskwarrior is available for both CentOS 7 (RedHat and Fedora) and Ubuntu (LinuxMint 17) distributions.

The latest version of task for Ubuntu is 2.2.0-3 and for CentOS it’s 2.4.2.

If you’re running Fedora, CentOS or RedHat, use yum to install task.

$ sudo yum install task

If you’re on an Ubuntu system, go with the below command.

$ sudo apt-get install task

How Task Works

The beauty of task lies in its simplicity. Continue reading »