sudo install, usage and sudoers config file basics

What if you want one user to run a command as an another system user without exchanging passwords. For example, you may want an user john to run a find command or custom bash shell script as an user greg or even as a user root ( superuser ) without password exchange. In this case a sudo utility with its /etc/sudoers configuration file will be your friend. This utility is very widely used but at the same time very little understood by Linux users of all levels.

This short article describes some basic of sudo usage and format of sudoers configuration file.

sudo install

First we need to make sure that sudo and /etc/sudoers the sudo configuration file is available. To do that run:

$ which sudo

or

$ sudo -V

The first command should reveal a location of a sudo binary executable and the second program will output a version number of sudo command its self. The sudo configuration file sudoers is in most cases located in /etc/sudoers. You can use ls command to locate this file.

$ ls -l /etc/sudoers
-r--r----- 1 root root 481 2010-04-08 21:43 /etc/sudoers

Read more

Image Processing, Linear stretch and OpenCV

In attempt to recognize objects by examining images, various Image processing and analysis techniques are applied. This article briefly describes linear stretch algorithm and its use within OpenCV.

Linear stretch technique can be applied to images where substantial lack of contrast can result in false identification of objects, its spacial relationship and significance. Contrast enhancement by linear stretch can be applied to images with very low or very high variations of brightness. To apply the Linear stretch algorithm an image needs to be converted into gray-scale and all 8bit pixels and its values are recorded into histogram.

Read more

Find by IP – Perl IP to location Example

In the next few lines we are going to describe a process of how to retrieve and geographical information from an IP address . For this we will use a MAxMind Perl API module. This company also provides a data file GeoLiteCity which is free but is less accurate than the paid version. As for a preparation part first we need to download a GeoIP perl module and data file:

$ cd
$ mkdir GeoIP
$ cd GeoIP
$ wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
$ wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

While in the GeoIP directory the next step is to extract both packages:

$ tar xzf Geo-IP-1.38.tar.gz
$ gunzip GeoLiteCity.dat.gz

It should be pointed out that this article assumes that your are running some distribution of Linux with PERL interpreter.

Read more

PROUHD: RAID for the end-user.

April 13, 2010
By Pierre Vignéras


Abstract:

RAID has still not been adopted by most end-users despite its inherent quality such as performance and reliability. Reasons such as complexity of RAID technology (levels, hard/soft), set-up, or support may be given. We believe the main reason is that most end-users own a vast amount of heterogeneous storage devices (USB stick, IDE/SATA/SCSI internal/external hard drives, SD/XD Card, SSD, …), and that RAID-based systems are mostly designed for homogenous (in size and technology) hard disks. Therefore, there is currently no storage solution that manages heterogeneous storage devices efficiently.

In this article, we propose such a solution and we call it PROUHD (Pool of RAID Over User Heterogeneous Devices). This solution supports heterogeneous (in size and technology) storage devices, maximizes the available storage space consumption, is tolerant to device failure up to a customizable degree, still makes automatic addition, removal and replacement of storage devices possible and remains performant in the face of average end-user workflow.

Although this article makes some references to Linux, the algorithms described are independent of the operating system and thus may be implemented on any of them.

Introduction

Whereas RAID1 has been massively adopted by the industry, it is still not common on end-users desktop. Complexity of RAID system might be one reason… among many others. Actually, in a state-of-the-art data center, the storage is designed according to some requirements (the ”top-bottom” approach already discussed in a previous article2). Therefore, from a RAID perspective, the storage is usually composed of a pool of disks of same size and characteristics including spares3. The focus is often on performance. The global storage capacity is usually not a big deal.

The average end-user case is rather different in that their global storage capacity is composed of various storage devices such as:

  • Hard drives (internal IDE, internal/external SATA, external USB, external Firewire);
  • USB Sticks;
  • Flash Memory such as SDCard, XDCard, …;
  • SSD.

On the opposite, performance is not the big deal for the end-user: most usage does not require very high throughput. Cost and capacity are main important factors along with ease of use. By the way, the end-user does not usually have any spare devices.

We propose in this paper an algorithm for disk layout using (software) RAID that has the following characteristics:

  • it supports heterogeneous storage devices (size and technology);
  • it maximizes storage space;
  • it is tolerant to device failure up to a certain degree that depends on the number of available devices and on the RAID level chosen;
  • it still makes automatic addition, removal and replacement of storage devices possible under certain conditions;
  • it remains performant in the face of average end-user workflow.

Algorithm

Description

Conceptually, we first stack storage devices one over the other as shown in figure 1.

Stacking storage devices (same size, ideal RAID case).

Figure 1:Stacking storage devices (same size, ideal RAID case).

On that example with raid devices, each of capacity raid (terabytes), we end up with a global storage capacity of raid. From that global storage space, using RAID, you can get:

  • a 4 Tb (raid) virtual storage devices (called PV for Physical Volume4 in the following) using RAID0 (level 0), but then you have no fault tolerancy (if a physical device fail, the whole virtual device is lost).
  • a 1 Tb (raid) PV using RAID1; in that case, you have a fault tolerancy degree of 3 (the PV remains valid in the face of 3 drives failure, and this is the maximum).
  • a 3 Tb (raid) PV using RAID5; in that case, you have a fault tolerancy degree of 1;
  • a 2 Tb (raid) PV using RAID10; it that case, the fault tolerancy degree is also 15 (raid is the number of mirrored sets, 2 in our case).

Read more

Using Debian package archive as a configuration tool

Introduction

How often do you need to install your favorite Linux distribution in a single year either virtually or using real hardware? How frequently it happens that you just want to test new release of certain Linux distribution so you install it on different partition or simply virtually using your current system as a host. How often do you need to deploy a server which is a complete clone of the one you configured yesterday. The installation part of any Linux system today is a very straightforward process. Nonetheless, the hardest and the most tedious part comes with a fine tuning, customization and configuration of your system’s services as well as your own user environment. You can simply copy your custom system configuration files from one system to another but engaging in this concept this task can become quite disorganized, time consuming and most importantly error-prone.

In this article, we are going to take a different approach which involves a creation of a Debian package archive containing all required custom user and configuration files. First part of this article describes a rather simple way on how to create a Debian package archive containing all custom files followed by its installation. In the second part, we will look at the way on how to create our own very basic Debian Repository and use it to deploy a simple website including Apache webserver installation and configuration on a freshly installed Linux system.

Part1

In this section, we create and install simple Debian package. The package will accommodate some sample user data to serve as an example.

Creating a Debian Package

It took you a while to configure your desktop to have it the way it best suits your needs and convenience. In your custom environment, you may for example include some bash scripts, create several aliases using .bashrc file or changed default behavior of a vim text editor by altering .vimrc file. Furthermore, you may also have customized numerous system configuration files such as /etc/network/interfaces and so on. All this hard work can be saved within a Debian package and installed and removed from any system with a single dpkg command. As a first step we need to create a bare minimum skeleton for a Debian package. This is a fairly simple task as it only involves a single DEBIAN/control file. So let us start by creating a directory named “myenv”. This directory will hold all data for our own version 1.0 Debian package.

$ mkdir myenv

In the next step, we need to create a control file:

$ cd myenv
$ mkdir DEBIAN
$ vi DEBIAN/control

Read more

Introduction to Computer Vision with the OpenCV Library on Linux

Abstract

The purpose of this document is to help a reader to get started with Computer Vision library OpenCV on Linux system. OpencCV is a multi-platform library, but this article will be focused only on OpenCV using Linux operating system ( although, just the installation of the OpenCV library and video camera is platform-specific, all examples in this article should compile on any platform where OpenCV is properly installed such as Mac OS, MS Windows and etc.). Reader will be guided through a step-by-step guide on how to install and use some of the basic functions of OpenCV library such as displaying images, playing a video or using a video camera to process a video input stream.

Conventions used in this article:

  • $ – execution on the command line by a non-privileged user
  • # – execution on the command line by a superuser
  • the actual command to be executed on the command line or code of program to be compiled
  • OUTPUT: output produced on the command line by command execution
  • NOTE: general notes and additional information

Introduction

In simple words a Computer Vision is a scientific field which attempts to provide a sight to the machine. This scientific field has expanded rapidly in recent years. Among researchers this growth is because of many improvements of vision algorithms and among the computer vision hobbyists this is due to the cheaper hardware components and processing power. OpenCV library plays a great role in the Computer Vision field as it helps greatly to reduce cost and preparation time of computer vision research environment needed by university students, hobbyists and professionals. OpenCV also provides a simple to use functions to get the work done in a simple, effective and elegant manner. OpenCV was started by Intel, and later it was transformed to an open source project now available on SourceForge.net. OpenCV library has multi-platform availability, and it is partially written in C++ and C language. Despite the fact that this library is available on many Linux distributions from its relevant package repositories, in this article we will attempt to install and use OpenCV library compiled from a source code downloaded from SourceForge.net web site.

The reasons for compiling a source code may include:

  • new version 2.0.0 recently released and more features available
  • some bugs fixed which affected Linux OpenCV 1.0.0 versions ( such as cvGetCaptureProperty() etc. )
  • more support is available for OpenCV 2.0.0 version than for former 1.0.0 version

This article will start with installation of OpenCV on Debian 5.0 ( Lenny ). Later a reader will be guided through a number of examples on how to use OpenCV to display an image, play a video and use camera to capture the video input stream.

Read more

Choosing the right Linux File System Layout using a Top-Bottom Process

July 31, 2009
By Pierre Vignéras


Abstract:

As you may probably know, Linux supports various filesystems such as ext2, ext3, ext4, xfs, reiserfs, jfs among others. Few users really consider this part of a system, selecting default options of their distribution’s installer. In this article, I will give some reasons for a better consideration of the file-system and of its layout. I will suggest a top-bottom process for the design of a “smart” layout that remains as stable as possible over time for a given computer usage.

Introduction

The first question that you may ask is why are there so many file-systems, and what are their differences if any? To make it short (see wikipedia for details):

  • ext2: it is THE Linux fs, I mean, the one that was specifically designed for linux (influenced by ext and Berkeley FFS). Pro: fast; Cons: not journalized (long fsck).
  • ext3: the natural ext2 extension. Pro: compatible with ext2, journalized; Cons: slower than ext2, as many competitors, obsolete today.
  • ext4: the last extension of the ext family. Pro: ascending-compatibility with ext3, big size; good read performance; cons: a bit too recent to know?
  • jfs: IBM AIX FS ported to Linux. Pro: mature, fast, light and reliable, big size; Cons: still developed?
  • xfs: SGI IRIX FS ported to Linux. Pro: very mature and reliable, good average performance, big size, many tools (such as a defragmenter); Cons: none as far as I know.
  • reiserfs: alternative to ext2/3 file-system on linux. Pro: fast for small files; Cons: still developed?

There are other file-systems, in particular new ones such as btrfs, zfs and nilfs2 that may sound very interesting too. We will deal with them later on in this article.

So now the question is: which file-system is the most suitable for your particular situation? The answer is not simple. But if you don’t really know, if you have any doubt, I would recommend XFS for various reasons:

Read more

Create disk image with dd

Howto CREATE BUNDLE UPLOAD and ACCESS custom Debian AMI using ubuntu

Introduction

This guide will provide all necessary steps on how to create, bundle, upload, run and connect Debian ETCH AMI on Amazon Elastic Compute Cloud (Amazon EC2). For this guide we have used a Ubuntu 9.04. However, any other Linux distribution can also be used as long as it contains java and ruby packages. For more information about Amazon EC2 read  here.

This page is not in any way an affiliate to Amazon Web Services. !

Prerequisites

  • Internet connection
  • registered user account for S3 and EC2 services with Amazon Web Services (AWS) 
  • Amazaon Access Key ID
  • Amazon Secret Access Key
  • Amazon Account Number
  • Amazon X.509 Certificate
  • at least 1GB free hard drive space
  • following packages need to be installed:
apt-get install ssh debootstrap ruby 
sun-java6-bin libopenssl-ruby curl

Before we start

 As you will see in the next sections of this guide many different files are required to successfully use Amazon’s EC2 Web Services. For the sake of simplicity, we will create a directory “aws” in ~/ and store all necessary files there for a quick access. There will be three exceptions:

Read more

move vim text editor cursor left with h, move vim text editor cursor right with l, move vim text editor cursor up with k ,move vim text editor cursor down with j

Vim Tutorial

Introduction

This tutorial has been written for both vi and vim. It starts with real basics, such as cursor navigation and ends with more advanced techniques like merging files.

For every section of this tutorial there is a short video with hints to help you understand how vim / vi works. Even that I have divided this tutorial into parts from novice to the expert user, there is plenty more what vim can do to make your work with vim editor easier and more efficient.

However completing this tutorial you will give sufficient knowledge about vim / vi and its features for your daily tasks.

Vim Novice level ( Vim Basics )

Moving cursor around

 move vim text editor cursor left with h, move vim text editor cursor right with l, move vim text editor cursor up with k ,move vim text editor  cursor down with j

In vim you can move cursor around with following keys h, l, k, j which is left, right, up and down respectively.

You can move cursor around also with arrow keys, however this is possible only if they are available.

Vim was designed for all kinds of terminals where arrow keys may not be available for you. Moreover, once you get used to using vim with h, l, k, j you will move more quickly than using arrow keys.

Open some text file and try use above keys now:

vim yourfile.txt

NOTE: You do not have to create a file prior to execution of the above command. If the file does not exists it will be created. If the file does exists it will be opened.

Read more

sakis3g the mobile broadband internet connection scrip

Mobile Broadband Internet connection and Sakis3G

This article is just a continuation of my first article about my experience with mobile broadband Internet on a Linux system. To cut the long story short a current network managers are trying to do a pretty good job by establishing a Mobile Broadband connection in a Plug & Play manner, however, they are not always successful to do so and user ends up with frustration and full hands of debugging and guessing what might went wrong instead of spending time with intended work.

Read more

IPwatchD an IP conflict detection tool for Linux

IPwatchD an IP conflict detection tool for Linux

IPwatchD an IP conflict detection tool for Linux

Project name: IPwatchD – IP conflict detection tool
Author: Jaroslav Imrich
Project’s Home Page: IPwatchD

 

Introduction

When using a GNU/Linux operating system, from time to time you may come across a situation where network connectivity was interrupted due to the IP conflict. An IP conflict event occurs when two or more hosts on the same network are configured with identical IP addresses. At the present, there appears to be no code in the Linux kernel to take care of this situation by means of appropriate Gratuitous ARP response . Very often a network administrator is left in the complete ignorance by the Linux kernel and needs to troubleshoot IP conflict the hard way. An IP Address Conflict GUI dialog triggered by IPwatchD Daemon Fortunately, there is a simple daemon called IPwatchD which main purpose is to catch and evaluate packets on the network and this way is able to prevent an IP conflict occurrence. This is done by help of libpcap library. IPwatchD daemon is written in C language and can run in passive or active modes. The difference between a passive and active mode is that in the passive mode IPwatchD only logs every IP conflict event by engaging syslog daemon, and in active mode IPwatchD takes one step further and responds to Gratuitous ARP request which is the main construction block when it comes to the IP conflict prevention. This article will explore this simple daemon in terms of installation, configuration and usage.

Prerequisites

Before we can install IPwatchD under the GNU/Linux operating system it is recommended to confirm that all prerequisites needed by IPwatchD are installed on the system. Here is a list of packages you would need to install on Ubuntu 8.10.

 * build-essential - C compiler and other development tools
* libpcap-dev - Network packet capture library
* libnet1-dev - Network packet construction library
* libnotify-dev - sends desktop notifications to a notification daemon

On ubuntu or debian linux you can install those packages with a following linux command:

# apt-get install build-essential libpcap-dev libnet1-dev libnotify-dev 

Read more

Drupal how to install guide

How To install Drupal 7 on Fedora Linux

Drupal how to guideThis installation guide provides step-by-step instructions on how to install Drupal 7 on a Fedora Linux system. The guide consists of 6 easy to follow steps to conclude whole installation. If you are just little bit curious about the new Drupal 7 release it is time to see what it is about. Be aware that installation of web applications on Linux systems using SELinux such as Fedora or RedHat is now little bit more complicated since changing permissions with chmod command may not always solve the problem. This guide could also be used by RedHat and CentOS Linux users.

Ubuntu users visit: Drupal 7 Installation guide for Ubuntu

Read more