Monthly Archives: February 2012

Shared library linking error on Linux.

If you face the following error while execution:

error while loading shared libraries: cannot open shared object file: No such file or directory

Then editing or creating /etc/ file then put the path where locates.

include /etc/*.conf


Then sudo ldconfig

Linux Tips: take control of your bash_history

source from:

1. Don’t save duplicates:
This is my favorite…


this causes any lines matching the previous history entry not to be saved.
Other options for HISTCONTROL: ignorespace, lines which begin with a space character are not saved in the history list; erasedups causes all previous lines matching the current line to be removed from the history list before that line is saved.

2. Size of the history:
HISTSIZE: The number of commands to remember in the command history. The default value is 500.


You can set this to 0 and disable the usage of the history file.

3. Others:
HISTFILE: The name of the file in which command history is saved. The default value is ~/.bash_history.
HISTIGNORE: A colon-separated list of patterns used to decide which command lines should be saved on the history list.

How do you set these options? Either export them in your environment in your personal bash configuration file (~/.bashrc) or in the global bash configuration file (/etc/bash.bashrc). The name of the configuration files can depend from your Linux distribution and bash version (the ones included are from Debian Linux), but you can always see your particular options using man bash. So, you can add in your configuration files the parameters you want like this:

export HISTCONTROL=ignoreboth
export HISTSIZE=500>

You will need to restart your bash session in order to activate the settings. You can check if your configuration were entered correctly by typing env at the command prompt. If you don’t see your configuration in the environment variables than you have done something wrong. If you see your configuration option, then all is ok, and your setting is active already.

Note: to my students (Bogdan and Alin) that attend my Linux Sysadmin course, I hope that this responds your question. Let me know if you have any other questions regarding this issue.

Here is a great note by one Digg user: burke
“the most efficent way to search your history is to hit Ctrl R and type the start of the command. It will autocomplete as soon as there’s a match to a history entry, then you just hit enter”


Ad-Hoc setting on Ubuntu (Linux)

You can setup ad-hoc networking to make two computers communicate or share an internet connection. The following scripts serve as an example. You will have to change the interface names for this to work on your system.

On the server

The server script works for a wireless card with an atheros driver. To make it work with a different card is trivial. More info there: If you just want to connect two computers with no sharing of internet connection, you can leave out the iptables bit in the server script.

####### this part should change or simply be removed depending on the network card
#recreates the ath0 interface in ad hoc mode
modprobe -r ath_pci
modprobe ath_pci autocreate=adhoc
wlanconfig ath0 destroy
wlanconfig ath create wlandev wifi0 wlanmode adhoc

#starts the ad hoc server
ifconfig ath0 down
iwconfig ath0 mode ad-hoc
iwconfig ath0 channel 4
iwconfig ath0 essid 'mine'
ifconfig ath0 up

#forwards the ad hoc network to the router
iptables -A FORWARD -i ath0 -o eth0 -s -m state --state NEW -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Here is a WPA Supplicant config file WPA based adhoc network.


On the client

Run the following on the client. If you want multiple clients, you will have to change the IP address to be unique.

iwconfig eth1 essid mine
iwconfig eth1 mode Ad-Hoc
ifconfig eth1 up
route add default gw

To share an internet connection, you need to tell the clients about the DNS servers. See the /etc/resolv.conf file on the server.