RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Linux tutorials and more...


USB stick encryption using Linux

Introduction

In case you will loose your USB stick, all data stored on it will be lost and what is more important they will be most likely in hands of some other person which will then have an access to your private information and use this information in any way s/he sees fit. This is one of many fears of USB stick users. One solution which can be easily applied is to not to store any private information on USB stick, however this will diminish a prime usage of your USB stick to a bare minimum as all non-private data usually do not have to be stored on USB since they can be almost always downloaded anytime and anywhere from the Internet. Another solution is to encrypt your USB stick so it will be accessible only to those users who posses a correct password which will fit to decrypt an used encryption method. This article will deal with the second solution and that is encryption of an USB stick device.

Although encrypting an USB stick seems to be the best and easiest solution it must be said that it also comes with number of disadvantages. The first disadvantage is that decryption of the USB key must be done using a Linux system with kernel version 2.6 and higher which has a "dm_crypt" module loaded in the running kernel. In other words, you cannot use your encrypted USB stick on any Windows machine and UNIX-like system with kernel version below 2.6. Therefore, to encrypt only a part of USB stick which holds only a private information seems to be a good solution. In this article we will use USB stick of capacity 16GB known to the system as a block device /dev/sdc. We first partition the disk to hold two partitions, one for encrypted data and the other for non-private data and then encrypt only single partition intended to hold private data.

NOTE:

All data on your USB stick will be destroyed so Back up your USB stick before continuing. Replace /dev/sdX with file name of your USB block device.

Partitioning an USB stick

Let's start with partitioning of our USB stick. Insert your USB stick into PC's USB slot and as a root user execute:

# parted -l

Search the output of parted command and retrieve a Disk's file name of your USB stick. As it was already mentioned before, in this article we will use /dev/sdc. Once we have a file name of our USB stick we can create partitions to be used for encryption and for storage of non-private data. In my case I will split the USB stick into two partitions, first with size of 2GB and the rest of the space will be used to create second partition and this will produce /dev/sdc1 and /dev/sdc2 respectively. Use any partition tool you see fit for this purpose, in this article I will use parted as it seems to be becoming a standard these days:

# parted /dev/sdX

Following commands are executed within a parted interactive mode:

(parted) mkpart primary 0.0 2GB
(parted) mkpartfs primary fat32 2GB -1s
(parted) quit

First parted command had created a primary partition with size of 2GB and this partition ( /dev/sdX1 ) will be used to store encrypted data. Second command created a second partition with fat32 file system ( /dev/sdX2 ) starting from 2GB up to last sector ( -1s ). The second partition will serve as a general storage. The final look of your USB stick partition table may look similar to the one below:

Disk /dev/sdc: 16.2 GB, 16236150784 bytes
255 heads, 63 sectors/track, 1973 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000cd7ef

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         243     1951866   83  Linux
/dev/sdc2             244        1974    13903718+   c  W95 FAT32 (LBA)

Write random data

To avoid pattern based encryption attacks it is advisable to write some random data to a partition before proceeding with an encryption. The following dd command can be used to write such data to your partition. It may take some time. Time depends on the entropy data generated by your system:

Share this linux post:

Submit USB stick encryption using Linux in Delicious Submit USB stick encryption using Linux in Digg Submit USB stick encryption using Linux in FaceBook Submit USB stick encryption using Linux in Google Bookmarks Submit USB stick encryption using Linux in Stumbleupon Submit USB stick encryption using Linux in Technorati Submit USB stick encryption using Linux in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: USB stick encryption using Linux

 

Install debian server in a linux chroot environment

Running Linux system inside a chroot environment allows a system admin to decrease an impact on a production server when the server gets compromised.  Change root will change root directory to all current running processes and its children to a chroot jail. Testing of various package installations and server configuration in a chrooted environment can be another handy way how to utilize a chroot jail.

This tutorial will provide a reader with step by step guide on how to install Debian with ssh daemon inside chroot environment using debootstrap.

Install chroot environment

In the first step we will create a directory in which new chroot environment will reside. For convenience during the installation we also declare temporary bash shell variable CHROOT to hold a path to chroot environment.

# mkdir -p /mnt/chroot/squeeze
# CHROOT=/mnt/chroot/squeeze

When new chroot directory is ready we will use debootstrap to install new Debian system within chroot environment. Change the architecture and debian version according to your needs. The installation may take some time as debootstrap will use your specified mirror to download and install core packages. Choose the closest mirror as it will rapidly reduce the installation time.

# debootstrap --arch i386 squeeze \
$CHROOT <URL OF DEBIAN MIRROR>

At the end of the installation you should seed output similar to the one below:

I: Configuring debian-archive-keyring...
I: Configuring apt...
I: Configuring libept0...
I: Configuring apt-utils...
I: Configuring aptitude...
I: Configuring tasksel-data...
I: Configuring tasksel...
I: Base system installed successfully.

Share this linux post:

Submit Install debian server in a linux chroot environment in Delicious Submit Install debian server in a linux chroot environment in Digg Submit Install debian server in a linux chroot environment in FaceBook Submit Install debian server in a linux chroot environment in Google Bookmarks Submit Install debian server in a linux chroot environment in Stumbleupon Submit Install debian server in a linux chroot environment in Technorati Submit Install debian server in a linux chroot environment in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Install debian server in a linux chroot environment

 

Building Linux kernels the Debian way

This short article describes the quick and easy way on how to customize, build and install Linux kernel under Debian or Ubuntu Linux. First, we will install all prerequisites then download kernel source. Next step will be customization and as a last step we will create and install a Debian package with new Customized Linux kernel.

Prerequisites

Let's start with first step which is installation of all prerequisites:

# apt-get install bzip2  build-essential \ 
kernel-package libncurses5-dev

Kernel build and customization

Next step is to download kernel source code from kernel.org. Untar and cd inside the kernel's directory tree:

$ tar xvjf linux-2.6.34.tar.bz2
$ cd linux-2.6.34

At this point we will do the most important part of creating new customized kernel and building a Debian package. This is all done with a single make-kpkg command.

NOTE:

Optional step is to apply kernel patches before running a following command:

make-kpkg --rootcmd fakeroot --config menuconfig --initrd --us --uc kernel_image
  • --us do not sign source
  • --uc do not sign changelog
  • --initrd perform any actions necessary for a kernel loaded using initrd
  • -- rootcmd fakeroot command that provides a means of gaining super user access
  • --config menuconfig will use menuconfig as a configuration tool where default is oldconfig

Share this linux post:

Submit Building Linux kernels the Debian way in Delicious Submit Building Linux kernels the Debian way in Digg Submit Building Linux kernels the Debian way in FaceBook Submit Building Linux kernels the Debian way in Google Bookmarks Submit Building Linux kernels the Debian way in Stumbleupon Submit Building Linux kernels the Debian way in Technorati Submit Building Linux kernels the Debian way in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Building Linux kernels the Debian way

 

Linux WD EARS Advanced Hard Drive Format

Introduction

Nowadays hard drive manufactures are switching to a new hard drive technology which uses 4KB sectors size instead of conventional 512B.  This new technology requires little tweaks to get a better performance in comparison to out-of-the-box settings. This article will describe some simple to follow instructions on how to partition the WD EARS hard-drive to get better overall performance. Getting the partitioning part done by aligning each partition can rapidly increase a hard drive's performance.


512B sector size standard is here for over 30 years and therefore lots of the code written for a Linux OS has 512 number hard coded in its source.
The main idea in regards to the 4 096 B size sectors is to increase the bit density on each track by reducing the number of gaps which hold Sync/DAM and ECC ( Error Correction Code ) information between each data sectors.  Therefore, for 8 x 512 B sectors the track also holds 8 sector gaps.

By having one single sector of size 4 096 B ( 8 x 512 B )  the track holds only 1 sector gap for each data sector thus reducing an overhead for a need to support multiple Sync/DAM and ECC blocks and at the same time increasing bit density.

Linux partitioning tools by default start each partition on sector 63 which leads to a bad performance of WD EARS hard-drives since they are not aligned to 4K sector from the beginning of the track.

For this article I'm using WDC WD10EARS-00Y5B1. This is a 1TB SATA hard-drive with 64MB cache memory.

WDC WD10EARS-00Y5B1 EARS WD advanced format

Share this linux post:

Submit Linux WD EARS Advanced Hard Drive Format in Delicious Submit Linux WD EARS Advanced Hard Drive Format in Digg Submit Linux WD EARS Advanced Hard Drive Format in FaceBook Submit Linux WD EARS Advanced Hard Drive Format in Google Bookmarks Submit Linux WD EARS Advanced Hard Drive Format in Stumbleupon Submit Linux WD EARS Advanced Hard Drive Format in Technorati Submit Linux WD EARS Advanced Hard Drive Format in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Linux WD EARS Advanced Hard Drive Format

 

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.

Share this linux post:

Submit Image Processing, Linear stretch and OpenCV in Delicious Submit Image Processing, Linear stretch and OpenCV in Digg Submit Image Processing, Linear stretch and OpenCV in FaceBook Submit Image Processing, Linear stretch and OpenCV in Google Bookmarks Submit Image Processing, Linear stretch and OpenCV in Stumbleupon Submit Image Processing, Linear stretch and OpenCV in Technorati Submit Image Processing, Linear stretch and OpenCV in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Image Processing, Linear stretch and OpenCV

 

Bash scripts to scan and monitor network

This article provides few simple scripts to scan and monitor network using combination of bash and ping command. Obviously, these scripts are no match to a full monitoring dedicated software like nagios but they could be useful for a small home brand networks, where implementing sophisticated monitoring system can become an overhead.

Scan network subnet

In this example the bash script will scan network for hosts attached to an IP address 10.1.1.1 - 255. The script will print message Node with IP: IP-address is up if ping command was successful. Feel free to modify the script to scan your hosts range.

#!/bin/bash

is_alive_ping()
{
  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo Node with IP: $i is up.
}

for i in 10.1.1.{1..255} 
do
is_alive_ping $i & disown
done

Execute:

./bash_ping_scan.sh

OUTPUT:

Node with IP: 10.1.1.1 is up.
Node with IP: 10.1.1.4 is up.
Node with IP: 10.1.1.9 is up.

Share this linux post:

Submit Bash scripts to scan and monitor network in Delicious Submit Bash scripts to scan and monitor network in Digg Submit Bash scripts to scan and monitor network in FaceBook Submit Bash scripts to scan and monitor network in Google Bookmarks Submit Bash scripts to scan and monitor network in Stumbleupon Submit Bash scripts to scan and monitor network in Technorati Submit Bash scripts to scan and monitor network in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Bash scripts to scan and monitor network

 

How to crack a wireless WEP key using AIR Crack

This article shortly describes simple steps on how to crack a wireless  WEP key using AIR Crack software. This can be done by sniffing a wireless network, capturing encrypted packets and running appropriate encryption cracking program in attempt to decrypt captured data.  WEP ( Wired Equivalent Privacy ) is quite easy to crack as it uses only one key to encrypt all traffic. Basic principle is that communication between two nodes on the network is based on the MAC address. Each host receives packets only intended for MAC address of its own interface. The same principle also applies for a wireless networks. However, if one node sets its own network card into promiscuous mode it will also receive packets which are not addressed for its own MAC address.


To crack the WEP key a hacker needs to capture sample packets not intended for his own network interface and run crack program to compare testing keys against WEP key bundled with captured packets in attempt of decryption. The key which fits to decrypt captured packets is the key used by wireless network to encrypt its entire wireless communication with its connected stations.

The guide assumes that your have wireless network card installed and that it supports monitor mode. In this example I'm using Realtek Semiconductor Co., Ltd. RTL-8185 IEEE 802.11a/b/g Wireless LAN Controller.

AIR Crack installation

Debian:

# apt-get install aircrack-ng

Fedora:

# yum -y install aircrack-ng

Homepage:

aircrack-ng.org

Identify wireless network interface

First we need to identify name of our wireless network interface. If your wireless network card is installed correctly an iwconfig command will reveal the name of your wireless network interface:

$ /sbin/iwconfig
wlan0     IEEE 802.11  Mode:Monitor  Frequency:2.437 GHz  Tx-Power=20 dBm

Turn on Monitor mode

# airmon-ng start wlan0
Interface Chipset Driver
wlan0 rtl8180 - [phy0]
(monitor mode enabled on mon0)

Identify a wireless network BSSID

In this guide i'm are going to crack a wireless WEP key of my own network. In this step I need to identify BSSID of the network I'm  intending to crack and as well as its channel number:

Share this linux post:

Submit How to crack a wireless WEP key using AIR Crack in Delicious Submit How to crack a wireless WEP key using AIR Crack in Digg Submit How to crack a wireless WEP key using AIR Crack in FaceBook Submit How to crack a wireless WEP key using AIR Crack in Google Bookmarks Submit How to crack a wireless WEP key using AIR Crack in Stumbleupon Submit How to crack a wireless WEP key using AIR Crack in Technorati Submit How to crack a wireless WEP key using AIR Crack in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: How to crack a wireless WEP key using AIR Crack

 

Install Ubuntu Lucid Lynx Linux from USB stick

If from any reason you are not able to install Ubuntu Lucid Lynx Linux from conventional CD/DVD-ROM or you just do not want to walk around with cd's, there is always an option to use USB memory stick to do this job. This short tutorial will describe this simple task from preparing your USB stick, load a Ubuntu Lucid Lynx Linux image and finishing with boot process. Although this guide describes this procedure specifically for Ubuntu Lucid Lynx Linux i386, it can be used with simple modifications to create Ubuntu USB install stick for any Ubuntu versions available including different architectures.

Download boot images

First we need to download two files:

The current version of lucid-desktop-i386.iso image needed for installation can be downloaded from the Ubuntu Lucid Lynx mirror. Download it and save it somewhere into your home directory along with boot.img.gz which contains all installer files.

Prepare USB stick

Find USB device name Plug in your USB stick and find its device file name by:

fdisk -l

For the rest of this guide we are going to use /dev/sdb as our target.
WARNING: DO NOT COPY AND PASTE COMMANDS FROM THIS PAGE UNLESS YOUR TARGET DEVICE IS ALSO /dev/sdb !!

Create FAT16 partition

Next we need to create FAT16 partition. For this we can use cfdisk with -z option.

This command will completely remove all your data from your USB stick, so backup first !:

Share this linux post:

Submit Install Ubuntu Lucid Lynx Linux from USB stick in Delicious Submit Install Ubuntu Lucid Lynx Linux from USB stick in Digg Submit Install Ubuntu Lucid Lynx Linux from USB stick in FaceBook Submit Install Ubuntu Lucid Lynx Linux from USB stick in Google Bookmarks Submit Install Ubuntu Lucid Lynx Linux from USB stick in Stumbleupon Submit Install Ubuntu Lucid Lynx Linux from USB stick in Technorati Submit Install Ubuntu Lucid Lynx Linux from USB stick in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Install Ubuntu Lucid Lynx Linux from USB stick

 

Getting to know the hardware of your Linux box

When you buy a new PC, laptop or server and install a Linux you want to know what hardware is actually in the Linux box and more importantly which piece of hardware is supported by the kernel out of the box and which needs special tweaking with modules to get it work. Here is a list of commands which should help you to troubleshoot your hardware and find some information about it. This is not a ultimate troubleshooting guide but certainly will serve as a good starting point.

NOTE: some commands may not be avaiable for your platform after default installation as well as some commands may be distribution specific only.

What hardware is in my Linux box:

$ lspci

or

# dmidecode

Share this linux post:

Submit Getting to know the hardware of your Linux box in Delicious Submit Getting to know the hardware of your Linux box in Digg Submit Getting to know the hardware of your Linux box in FaceBook Submit Getting to know the hardware of your Linux box in Google Bookmarks Submit Getting to know the hardware of your Linux box in Stumbleupon Submit Getting to know the hardware of your Linux box in Technorati Submit Getting to know the hardware of your Linux box in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Getting to know the hardware of your Linux box

 

PROUHD: RAID for the end-user.

April 13, 2010
By Pierre Vignéras More stories by this author:


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).

 

Share this linux post:

Submit PROUHD: RAID for the end-user. in Delicious Submit PROUHD: RAID for the end-user. in Digg Submit PROUHD: RAID for the end-user. in FaceBook Submit PROUHD: RAID for the end-user. in Google Bookmarks Submit PROUHD: RAID for the end-user. in Stumbleupon Submit PROUHD: RAID for the end-user. in Technorati Submit PROUHD: RAID for the end-user. in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: PROUHD: RAID for the end-user.

 

Install Debian Linux from USB boot memory stick

There are more and more Laptops nowadays which do not have a CD/DVD-ROM facility build in but are able to boot from USB memory stick. This small guide provides all needs on how to create a bootable USB memory stick to install a Debian without a need for CD/DVD drive.

Before you continue make sure that you have backed up all your data from your USB memory stick. After completing this guide your USB memory stick will contain a new partition table and all your data will be lost.

This guide also assumes that you have a running linux system and USB memory stick with minimal size of 512MB which you will use for the process of creating Debian boot installation USB stick.

Find USB device name

Plug in your USB stick and find its device file name by:

fdisk -l

For the rest of this guide we are going to use /dev/sdb as our target.

WARNING: DO NOT COPY AND PASTE COMMANDS FROM THIS PAGE UNLESS YOUR TARGET DEVICE IS ALSO /dev/sdb !!

Create FAT16 partition

Next we need to create FAT16 partition. For this we can use cfdisk with -z option. This command will completely remove all your data from your USB stick, so backup first !:

cfdisk -z /dev/sdb

and create a first primary partition with the minimal size of 260MB and leave the rest unpartitioned or create second partition with some other filesystem for normal use of your USB stick. The size of 260 MB will fit a current Debian stable boot.img.gz and and Debian netinst ISO image.

 

Share this linux post:

Submit Install Debian Linux from USB boot memory stick in Delicious Submit Install Debian Linux from USB boot memory stick in Digg Submit Install Debian Linux from USB boot memory stick in FaceBook Submit Install Debian Linux from USB boot memory stick in Google Bookmarks Submit Install Debian Linux from USB boot memory stick in Stumbleupon Submit Install Debian Linux from USB boot memory stick in Technorati Submit Install Debian Linux from USB boot memory stick in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Install Debian Linux from USB boot memory stick

 

touch

Author: Lubos Rendek

Date: 21.03.2010

Name

touch [man page] - change file timestamps

Usage

When working with a Linux operating system, sometimes a need arises to create an empty file. Some service, which an administrator is configuring, requires a certain file to be created before the service can start and what is more this file may need to have certain access time stamp. If you are, for example, running a photo album web application which automatically adds your images to the album and sorts them according to the image creation time, the images you upload must have set accurate creation time in order this can work. What if the time set in your camera is incorrect?

A tool which comes handy in both scenarios is the touch command. Touch command not only provides a simple way to create files, but it also allows a user to alter access and modification time for a given file.

NOTE: Linux system does not store a file creation time. The information stored instead is the access time. The access time does not necessarily represent creation time and in many situations it represents access time only. This is because access time gets updated every time a file is accessed / read.

NOTE: In this article, we are going to use the stat command to observe changes to file's access and modification time made by touch command.

File creation

As it was already mentioned a touch command provides a simple way of creating empty files. The syntax is rather simple:

linuxconfig.org:~$ ls
linuxconfig.org:~$ touch fileA
linuxconfig.org:~$ ls
fileA
linuxconfig.org:~$

Execution of touch command with an argument fileA will produce a single empty file named fileA. Touch command can accept more than one argument and as result:

linuxconfig.org:~$ touch fileB fileC fileD
linuxconfig.org:~$ ls
fileA fileB fileC fileD
linuxconfig.org:~$

it will create three additional files called fileB fileC and fileD. It is important to understand that all files created by touch command are empty, which means that touch command does not add any characters to newly created files.

Change file timestamps

At this point, we need to have a close look at earlier created files. stat command will return verbose information associated to a file given to it as its argument.

linuxconfig.org:~$ stat fileA
File: `fileA'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 1867780 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1001/linuxconfig) Gid: ( 1001/linuxconfig)
Access: 2010-03-21 06:22:52.000000000 +1100
Modify: 2010-03-21 06:22:52.000000000 +1100
Change: 2010-03-21 06:22:52.000000000 +1100
linuxconfig.org:~$

stat command returned detailed information about fileA status in regard to a present file system. The only interesting bit connected to this article is access and modify time.

Access time

Access time refers to a time when to file was last time accessed. In other words, every time some utility reads a content of fileA, fileA will change its access time. Following example demonstrates this point:

linuxconfig.org:~$ date
Sun Mar 21 06:23:08 EST 2010
linuxconfig.org:~$ stat -c %x fileA
2010-03-21 06:22:52.000000000 +1100
linuxconfig.org:~$ cat fileA
linuxconfig.org:~$ stat -c %x fileA
2010-03-21 06:23:19.000000000 +1100
linuxconfig.org:~$

First, we have used the date command to retrieve a current date and time. Next command executed is stat command which returns an access time of fileA. Cat command is used to access / read a content of fileA. There is no output since fileA is an empty file. Executing a stat command again with fileA as an argument indicates that access time has been changed.

Modify time

Modify time is altered when the content of a file itself has been modified. In the following example, we use echo command to modify a content of fileA:

linuxconfig.org:~$ date
Sun Mar 21 06:23:23 EST 2010
linuxconfig.org:~$ stat -c %y fileA
2010-03-21 06:22:52.000000000 +1100
linuxconfig.org:~$ echo addline > fileA
linuxconfig.org:~$ stat -c %y fileA
2010-03-21 06:23:35.000000000 +1100
linuxconfig.org:~$

Once again, we have used a date command to show a current system time. Next command executed was a stat command which in this case displayed modify time of a fileA. Next, we have used an echo command to add new line into fileA. Lastly, stat command confirms that modify time has been changed. As a side-note it should be mentioned that modifying content of file will alter also file's change time.

Change time

In regard to a touch command, we are not interested in change time. Nevertheless, just for a completeness we shortly examine also change time. Change time holds a time when file's meta data or inode information is altered. Meta data includes change of permissions or file ownership. Following example illustrates this idea:

linuxconfig.org:~$ date
Sun Mar 21 06:23:40 EST 2010
linuxconfig.org:~$ stat -c %z fileA
2010-03-21 06:23:35.000000000 +1100
linuxconfig.org:~$ chmod +x fileA
linuxconfig.org:~$ stat -c %z fileA
2010-03-21 06:23:51.000000000 +1100
linuxconfig.org:~$

Same as in both preceding examples date command displays a current date and time. stat command reveals a current value of file's change time. chmod command added executable permissions to a file. When comparing both time values, it is clear that a modification of fileA's permissions resulted in updating a change time value to a current system time.

Share this linux post:

Submit touch in Delicious Submit touch in Digg Submit touch in FaceBook Submit touch in Google Bookmarks Submit touch in Stumbleupon Submit touch in Technorati Submit touch in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: touch

 

Introduction to Computer Vision with the OpenCV Library on Linux

Author: Lubos Rendek

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.

Share this linux post:

Submit  Introduction to Computer Vision with the OpenCV Library on Linux in Delicious Submit  Introduction to Computer Vision with the OpenCV Library on Linux in Digg Submit  Introduction to Computer Vision with the OpenCV Library on Linux in FaceBook Submit  Introduction to Computer Vision with the OpenCV Library on Linux in Google Bookmarks Submit  Introduction to Computer Vision with the OpenCV Library on Linux in Stumbleupon Submit  Introduction to Computer Vision with the OpenCV Library on Linux in Technorati Submit  Introduction to Computer Vision with the OpenCV Library on Linux in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: Introduction to Computer Vision with the OpenCV Library on Linux

 

C++ : Understanding pointers

Author: Lubos Rendek

Date: 10.09.2009

Update: 04.03.2010 - Section 7.2 was created to clarify relation between Pointers and Arrays in C++

Introduction

This article is intended to all programing enthusiasts on all levels who do wish to understand pointers in C++ language.  All code presented here is not a compiler specific and all examples will be written in plain ANSI C++. Debate about pointers can stretch for miles, and you would need to go really far to master it all. If you really want to run that far, this article gives you a clear understanding of fundamental concepts about pointers and prepares you for that journey. However, those who are new to C++ programming make sure that  you are able to write and run your own C++ “hello world” program, and also it is recommended that you have a basic understanding of C++ functions and classes. If you need to refresh your knowledge about how to compile and run C++ program, use functions and classes, please read an appendix at the end of this document before you continue reading this article.

What is a Pointer?

Pointer is a variable that stores a memory address. OK, that is simple ! But, what is a memory address then? Every variable is located under unique location within a computer's memory and this unique location has its own unique address, the memory address. Normally, variables hold values such as 5 or “hello” and these values are stored under specific location within computer memory. However, pointer is a different beast, because it holds the memory address as its value and has an ability to “point” ( hence pointer ) to certain value within a memory, by use of its associated memory address.

Retrieving a Variable's Memory Address

OK, enough talking and let's get down to the pointer business. To retrieve a variable's memory address, we need to use address-of operator &.

#include <iostream>
int main()
{
using namespace std;
// Declare an integer variable and initialize it with 99
unsigned short int myInt = 99;
// Print out value of myInt
cout << myInt << endl;
// Use address-of operator & to print out
// a memory address of myInt

cout << &myInt << endl;

return 0;
}

OUTPUT:

99
0xbff26312

The first line of the output contains an integer value 99 and on the second line, there is a memory address of myInt printed out. Please note that your output will be different.

 

Assigning a Variable's Memory Address to a Pointer

Before we can assign a memory address to a pointer, we need to declare one. Declaring a pointer in C++ is as simple as to declare any other variable with one single difference. Asterix symbol " * " needs to be add and located after variable type and before a variable name. One rule has to be followed when assigning memory address to a pointer: pointer type has to match with variable type it will point to. One exception is a pointer to void, which can handle different types of variables it will point to. To declare a pointer pMark of type unsigned short int a following syntax is to be used:

#include <iostream>

int main()
{
using namespace std;

// Declare and initialize a pointer.
unsigned short int * pPointer = 0;
// Declare an integer variable and initialize it with 35698
unsigned short int twoInt = 35698;
// Declare an integer variable and initialize it with 77
unsigned short int oneInt = 77;
// Use address-of operator & to assign a memory address of twoInt to a pointer
pPointer = &twoInt;
// Pointer pPointer now holds a memory address of twoInt

// Print out associated memory addresses and its values
cout << "pPointer's memory address:\t\t" << &pPointer << endl;
cout << "Integer's oneInt memory address:\t" << &oneInt << "\tInteger value:\t" << oneInt << endl;
cout << "Integer's twoInt memory address:\t" << &twoInt << "\tInteger value:\t" << twoInt << endl;
cout << "pPointer is pointing to memory address:\t" << pPointer << "\tInteger value:\t" << *pPointer << endl;

return 0;
}

OUTPUT:

pPointer's memory address:              0xbff43314
Integer's oneInt memory address: 0xbff43318 Integer value: 77
Integer's twoInt memory address: 0xbff4331a Integer value: 35698
pPointer is pointing to memory address: 0xbff4331a Integer value: 35698

C++ pointer example diagram

The diagram above is a high level visual abstraction of how are variables stored within a computer memory. Pointer pPointer starts at memory address 0xbff43314 and takes 4 bytes. Pointer pPointer holds as a value a memory address of a short int twoInt ( 2 bytes ) which is 0xbff4331a. This address is stored as a binary data within a pointer's memory space allocation. Therefore, dereferencing a pointer with a memory address 0xbff4331a will indirectly access a value of twoInt which is in this case a positive integer 36698.

Share this linux post:

Submit C++ : Understanding pointers in Delicious Submit C++ : Understanding pointers in Digg Submit C++ : Understanding pointers in FaceBook Submit C++ : Understanding pointers in Google Bookmarks Submit C++ : Understanding pointers in Stumbleupon Submit C++ : Understanding pointers in Technorati Submit C++ : Understanding pointers in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: C++ : Understanding pointers

 

APACHE web server and SSL authentication

Author: Jaroslav Imrich


apache mod SSLThis article describes configuration techniques of module mod_ssl, which extends a functionality of Apache HTTPD to support SSL protocol. The article will deal with authentication of server (One-way SSL authentication), as well as it will also include authentication of clients by using certificates (Two-way SSL authentication).

Introduction

If you have decided to enable a SSL ( Secure Sockets Layer ) protocol on your web server it may be because you would like to extend its functionality to achieve an integrity and confidentiality for a data transferred on unsecured networks. However, this protocol with the combination of PKI ( Public Key Infrastructure ) principles can also along the side of integrity and confidentiality provide authentication between both sides involved in the client-server communication.

One-way SSL authentication allows a SSL client to confirm an identity of SSL server. However, SSL server cannot confirm an identity of SSL client. This kind of SSL authentication is used by HTTPS protocol and many public servers around the world this way provides services such as webmail or Internet banking. The SSL client authentication is done on a “application layer” of OSI model by the client entering an authentication credentials such as username and password or by using a grid card.

Two-way SSL authentication also known as mutual SSL authentication allows SSL client to confirm an identity of SSL server and SSL server can also confirm an identity of the SSL client. This type of authentication is called client authentication because SSL client shows its identity to SSL server with a use of the client certificate. Client authentication with a certificate can add yet another layer of security or even completely replace authentication method such us user name and password.

In this document, we will discuss configuration of both types of SSL authentication one-way SSL authentication and two-way SSL authentication.

Share this linux post:

Submit APACHE web server and SSL authentication in Delicious Submit APACHE web server and SSL authentication in Digg Submit APACHE web server and SSL authentication in FaceBook Submit APACHE web server and SSL authentication in Google Bookmarks Submit APACHE web server and SSL authentication in Stumbleupon Submit APACHE web server and SSL authentication in Technorati Submit APACHE web server and SSL authentication in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

Read more: APACHE web server and SSL authentication

 

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

July 31, 2009
By Pierre Vignéras More stories by this author:


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 (see 5

).

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:

Share this linux post:

Submit Choosing the right Linux File System Layout using a Top-Bottom Process in Delicious Submit Choosing the right Linux File System Layout using a Top-Bottom Process in Digg Submit Choosing the right Linux File System Layout using a Top-Bottom Process in FaceBook Submit Choosing the right Linux File System Layout using a Top-Bottom Process in Google Bookmarks Submit Choosing the right Linux File System Layout using a Top-Bottom Process in Stumbleupon Submit Choosing the right Linux File System Layout using a Top-Bottom Process in Technorati Submit Choosing the right Linux File System Layout using a Top-Bottom Process in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment

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

 

Page 7 of 9