Linux tutorials and more...
Easy way to create a Debian package and local package repository
This article describes a simple way on how to create a home made debian package and include it into a local package repository. Although we could use a existing Debian/Ubuntu package, we will start from scratch by creating our own minimalistic unofficial debian package. Once our package is ready, we will include it into our local package repository. This article illustrates very simplistic approach of creating debian package, however it may serve as a template in many different scenarios.
Creating a binary executable
First we need to create some simple program, compile it and test it. Our program will do nothing else just print "linuxconfig.org" on the screen. Here is a code:
#include <iostream> int main() { using namespace std; cout << "linuxconfig.org\n"; return 0; }
Save the above code as linuxconfig.cc. At this point make sure that you have compiler installed on your system by executing:
Add a commentRead more: Easy way to create a Debian package and local package repository
Batch image resize using linux command line
Question:
How can I batch resize of multiple images using ubuntu linux command line? Is there any tool which would help me with this and/or is there GUI application which makes image resizing easy. I have hundreds of images and therefore I'm in need of such a tool.
Answer:
The best and the easiest way to resize multiple images using linux command line is to use imagemagick tools. First you need to install imagemagick package:
# apt-get install imagemagick
Once installed you will have multiple image processing tools available to our disposal, such as convert, identify and etc.
Add a commentCalculate column average using bash shell
Question:
Is there a way to calculate a average of a single column stored in a text file? For example my file contains:
$ cat file.txt line1 4.5 line2 6
how do I get 5.25 ?
Answer:
One way to do this is to use combination of bash for loop, cut, echo and bc commands. Execute the code below, assuming that file.txt is in your current working directory:
Add a commentHow do I ping a specific port of a remote server?
Question:
How do I ping a specific port of a remote server? I need to find out whether the port on the remote server is open.
Answer:
ping utility does not allow you to ping specific port on you remote server. To see whether a specific port is open on a remote server you can use port-scanner such as nmap or simply try connect to a socket ( IP-address:port ) using telnet. In the example below we test whether a port number of TCP port 80 is open a host google.com:
# nmap -p 80 -sT google.com or # nmap -p 80 google.com
Add a comment
Read more: How do I ping a specific port of a remote server?
Remove all files and directories owned by a specific user
Question:
Hi, how do I remove all files owned by a certain user. What I need is to find all files and directories and remove them system wide.
Answer:
The tool which may come handy to is a find command. Find command will find all files and directories owned by a specific user and execute rm command to remove them. The following command will find and remove all files within /home/ directory owned by a user "student". The following command is executed as root user:
NOTE: replace /home with your target directory.
# find /home/ -user student -exec rm -fr {} \;
Add a comment
Read more: Remove all files and directories owned by a specific user
Iptables to reject all INPUT and OUTPUT except specific hosts
Question:
I have created a zone in my lan, where i have given 11 servers a dns address. But someone has connected 3 more(these three have only IP, not dns address), and i dont want to remove all servers to find out which ones it is.
Is there a way to make sure that only the servers with a dns-address provided by me is granted access to the internet? (block input and output)
Answer:
Reject all outgoing traffic from source IP address different than 222.111.111.222
iptables -A OUTPUT -t filter ! -s 222.111.111.222 -j REJECT
Add a comment
Read more: Iptables to reject all INPUT and OUTPUT except specific hosts
Enabling Ubuntu compiz 3D cube Desktop Effect
If you ever get bored of your ordinary default Ubuntu desktop or you feel that you do not utilize your Graphic card the way you should, you can try to enable Ubuntu compiz 3D cube Desktop Effect the give your desktop an extra spark. This article will provide you with a step-by-step configuration on how to enable Ubuntu compiz 3D cube Desktop Effect.
Step 1: Installation of VGA driver
You may skip this step if you have already installed restricted display drivers from Ubuntu's PPA repository. This step is optional even with a default Ubuntu installation. I recommend to proceed with Step 2 and let Ubuntu system will attempt to detect your VGA card and install appropriate VGA drivers for your card automatically. If that fails come back to Step 1 and do it manually as described below.
Installation of nVidia restricted driver
First add ubuntu PPA repository:
$ sudo add-apt-repository \ ppa:ubuntu-x-swat/x-updates $ sudo apt-get updateAdd a comment
Changing vmware vmnet bridged physical network interface
Question:
How do I change vmware bridged vmnet interface from eth0 to wlan0?
Answer:
During the vmware installation / configuration the vmware-config.pl script asks:
Your computer has multiple ethernet network interfaces available: eth0, eth1. Which one do you want to bridge to vmnet0? [eth0]
This configuration actually refers to a vmware configuration file /etc/vmware/locations.
Add a commentRead more: Changing vmware vmnet bridged physical network interface
Apache .htaccess directory access protection
If you would ever need to shield your website from a public access, know that apache .htaccess file provides a simple and yet powerful way to accomplish it. This article teaches you just that in simple to follow steps.
As a first step we need to make sure that our website configuration will read .htaccess files. To do that check your httpd.conf file or your website apache setting whether it contains a directive:
AllowOverride ALL
On a Ubuntu / Debian system this directive defaults to “none”.
Options Indexes FollowSymLinks MultiViews AllowOverride ALL Order allow,deny allow from all
If have made some changes restart your apache web server:
Add a commentExtract unique IP addresses from an apache log
Question:
Hi how do I extract all IP addresses from my httpd log. I need to extract only unique IP addresses from my apache log file.
Here is a my sample apache log entry:
XXX.64.70.XXX - - [26/Mar/2011:00:28:23 -0700] "GET / HTTP/1.1" 403 4609 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16"
Answer:
Upon the apache log entry format you have supplied, the easiest way to extract in IP addresses from this kind of apache log entries is to use a combination of awk, sort and uniq commands. First we need to get a long list of IP addresses. This can be done with awk command:
Add a commentInstalling Linux MINT 10 and partitioning harddrive
Question:
Hey, I'm new to this, I'm trying to install Linux MINT 10 to my Compaq Presario which has already crashed with Windows Vista on it. I used UNetBootin on my USB flash drive, the laptop will let me run MINT but when I try to install it my root system isn't defined.
So with that being said I'm trying to delete all partitions on my laptop and start fresh. How do I do that !?
Answer:
If you do not intent to have a dual boot ( windows and linux on the same box ) you may just simply remove all partitions on your hard drive and create new partitions just for Mint 10. From your question this appears to be exactly what you want. Therefore, you have two options:
Add a commentRead more: Installing Linux MINT 10 and partitioning harddrive
Date manipulation with yest
yest is a great tool which allows user to do some complex date manipulations by employing ab easy to understand syntax. It is not a competitor to a date command, rather it is a handy tool which has some features you may not find in date command. Name of the yest command is derived from its default no argument output which is yesterday’s date.
Add a commentInstallation of VMware-server 2.0.2 on Ubuntu Linux 10.04 ( lucid lynx )
This article is a step-by-step guide of VMware-server 2.0.2 installation on Ubuntu Linux Lucid Lynx 10.04. This guide assumes that a reader already obtained a copy of VMware-server 2.0.2 installation pack along with valid serial number. All commands below are executed as root user. To change to root user use:
$ sudo bash
Environment:
- 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux
- gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
- VMware-server-2.0.2-203138.i386.tar.gz
Read more: Installation of VMware-server 2.0.2 on Ubuntu Linux 10.04 ( lucid lynx )
Automatic HTML form submission using WWW::Mechanize
Here is a short tip on how to automatically submit a HTML form using a Linux command line and perl script. For this example we would need a WWW::Mechanize perl module and some basic PHP website. Let's start with simple PHP website. The website will consist of two files:
form.php:
<form action="submit.php" method="post"> First Name: <input name="fname" type="text" /> Last Name: <input name="lname" type="text" /> <input type="submit" /> </form>Add a comment
Read more: Automatic HTML form submission using WWW::Mechanize
Rename all files and prefix a time-stamp to all file names
Question:
Hi is there a way to rename all files in a directory and prefix a time-stamp to all files? thanks
Answer:
For that you can use a following set of commands:
First declare a time-stamp variable in a format to fit your needs. For example:
$ TS=$( date +%Y%m%d%H%M )
This will create a bash variable called TS with a value of current date and time:
Add a commentRead more: Rename all files and prefix a time-stamp to all file names
Wordpress Installation on Ubuntu Linux with Apache and MySQL
This article describes an installation of Wordpress on a Ubuntu Linux system using Apache web-server and MySQL database. Wordpress is an CMS ( Content Management System ), mostly used as a blog publishing web application. Wordpress is written in PHP language and uses MySQL database to store data.
Preliminary notes about the system used for this Wordpress installation:
- Ubuntu Linux 10.04 - Worpress 3.1 ( Reinhardt )
- Kernel 2.6.32-21-generic #32-Ubuntu SMP
- mysql Ver 14.14 Distrib 5.1.41
- Apache/2.2.14 (Ubuntu)
- PHP 5
Read more: Wordpress Installation on Ubuntu Linux with Apache and MySQL
Page 2 of 9













