feed-image  ISSN 1836-5930

linux

Linux eBooks FREE Download

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)

The GNU/Linux Advanced Administration

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

Advanced Bash-Scripting Guide


Poll

Do you care about your privacy when using a FACEBOOK?
 


Partner Linux Sites: TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

LINUX ADMINISTRATION NOTES & CODE SNIPPETS

Ubuntu and Debian google-talkplug installation howto

Installing this plugin on any Linux system should be a easy task. First download google-talkplugin_current_i386.deb package. On a Ubuntu system use: sudo dpkg -i google-talkplugin_current_i386.deb on a system where sudo is ...

Read more ...

WWW Mechanize - 401 Authorization Required

Here is a small script on how to login to a .htaccess protected page. Suppose that URL we want to login to is: http(:)//www(.)example(.)com/ and here are credentials required to login: username: www password: ...

Read more ...

Extract email address from a text file

A following perl script and regular expression extracts all email addresses from an given text file. Sample text: This perl script extracts all email addresses from an given text file. This email ...

Read more ...

Regular expression to validate credit card number

Credit card numbers contain four groups of numbers where each group contains 4 numbers. The following regular expression ( regexp ) will accept all credit card number in this format: ...

Read more ...

Regular Expression to validate US postal codes

Simple way to validate US postal codes using regular expression and optionally bash. US postall codes accept five digit ZIP number + optional 4 digit code. For example 32344-4444 and ...

Read more ...

vfat file system - unable to create uppercase directory name

Are you unable to create uppercase directory name on your storage device mounted as vfat file system. The reason for this behavior is that vfat filesystem is by default mounted ...

Read more ...

How To secure ssh

Here are couple ways on how to change your sshd default configuration settings to make ssh daemon more secure / restrictive and thus protecting your server from unwanted intruders. NOTE: Everytime you ...

Read more ...

Falling back to the standard locale - Solution

A following warning message may appear on your Linux terminal: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = ...

Read more ...

More in: Linux administration notes & code snippets

-
+
8
Linuxconfig.org
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.

 

Read more...
 
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.

Read more...
 
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.

Read more...
 
C++ : Understanding pointers

Author: Lubos Rendek

Date: 10.09.2009

Update: 04.03.2010 - Section 7.2 created 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.

Read more...
 
«StartPrev12345678910NextEnd»

Page 5 of 11