Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday, July 6, 2012

Debian with Ubuntu Fonts

Here is how I configure my Debian system to use the same font config as Ubuntu.
Simply download, fontconfig-config_2.8.0-3ubuntu9_all.deb. The link will take you to Ubuntu 12.04 fontconfig-config deb package.
After you saved that deb file, extract it to get its contents:
$ dpkg-deb -x fontconfig-config_2.8.0-3ubuntu9_all.deb /tmp/extract/

then replace the content of Debian's /etc/fonts/* with data from /tmp/extract/etc/fonts/*

$ sudo cp -r /tmp/extract/etc/fonts/* /etc/fonts/

Logout and log back in to see the change.

Thursday, April 5, 2012

Disable Network Manager and Use Script to Connect to WPA2 Wireless Connection

I would like some of the computers at my work to be able to connect to a specific wireless access point with WPA2 encryption and keep trying to connect (indefinitely) if the Access Point (AP) is not on yet. When the AP is up and running, those computers should be able to connect without any human interaction. There is a possibility that the AP is turned off for a while or restarted, due to some reason, and those computers should be able to reconnect automatically when the AP is back online again.

The default behavior on Ubuntu and Fedora is a little bit different (but far from my need). When a computer is already connected to AP, and the AP suddenly becomes unavailable for a while, there will be a WEP/WPA password dialog. User has to click the connect button again and if the AP is not available yet it will keep showing password dialog. When the user click cancel button, it will stop trying to connect to that particular AP.

Finally I figured out how to set the computer to keep trying to connect indefinitely and no matter how many times the AP becomes unavailable, it will keep doing it until it is (re)connected.

Here is how I did it:
The main issue is with the default behavior of the NetworkManager. I have not found any NetworkManager configuration so I could set it the way I explained earlier. Please let me know if someone knows how to do the exact thing that I need using NetworkManager.

The first step is to disable NetworkManager:
To disable it temporarily, use the following command:
$ sudo service network-manager stop

To permanently disable NetworkManager, do the following:
edit /etc/init/network-manager.conf
comment "start on...", so it would be like the following:
# start on

Next step is to create a wpa supplicant configuration file, do the following:
Create "/etc/wpa_supplicant/wpa_supplicant.conf" file and make it executable.
Put the following configurations inside it:
########### wpa_supplicant.conf ############


ctrl_interface=/var/run/wpa_supplicant

network={
    ssid="your_wlan_essid"
    scan_ssid=1
    key_mgmt=WPA-PSK
    psk="your_wpa2_passphrase"
}


########### end of wpa_supplicant.conf ############

Now, I am not really comfortable to put my plain text wpa2 passphrase inside the config file. So, I use the following method:
$ wpa_passphrase your_wlan_essid your_plain_text_passphrase

Use the output of the command above for your encrypted passphrase

Third step is to edit the /etc/network/interfaces configuration file.
Here is how my config file looks:
############# /etc/network/interfaces ###########

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp
   wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
   wpa-action /etc/wpa_supplicant/action_wpa.sh

############# end of /etc/network/interfaces ###########

Notice that /etc/wpa_supplicant/wpa_supplicant.conf is the configuration file we just created previously, and /etc/wpa_supplicant/action_wpa.sh should exist from the default ubuntu (11.10) installation.

Now for the test:
Test #1
Make sure your AP is on.
Restart your computer, and after you logged in, you should be connected to AP.

Test #2

Make sure your AP is off.
Restart your computer, and after you logged in, you should not be connected to AP.

Turn on your AP.
Not long after that your computer should be connected to AP.

Test #2
Make sure your AP is on and your computer is connected to AP.
Turn off your AP.
Your computer should be disconnected from AP.
Wait for a while to be sure that your computer is not connected and the retry connection attempt failed.

Turn back your AP on.
Not long after that your computer should be reconnected to AP.


Now, this is exactly what I want for my setting at work.

Thursday, October 20, 2011

Permanently Set Network Interface Speed, Duplex or Auto Negotiate Settings on Linux


On RedHat (based) Linux:

Edit /etc/sysconfig/network-scripts/ifcfg-eth0 file for eth0 interface.
On my Fedora15, the file looks like the following:
/etc/sysconfig/network-scripts/ifcfg-Auto_wlan

So, open the corresponding file according to your need, then append the following line:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"

Save the file, and restart network interface by executing the following command:
# /etc/init.d/network restart

The previous example is for setting the NIC to 100Mbps, full duplex and no auto negotiation.


If you want 1000Mbs use the following configuration:
ETHTOOL_OPTS="speed 1000 duplex full autoneg off"
or
ETHTOOL_OPTS="speed 1000 duplex full autoneg on"



For Ubuntu and perhaps Debian and other Debian based Linux, edit /etc/network/interfaces, and add pre-up statment, so it will look like something like the following:

auto eth0
iface eth0 inet static
pre-up /usr/sbin/ethtool -s eth0 speed 1000 duplex full

Refer to this link for more information.

For Ubuntu:
Edit /etc/network/interfaces and add the following line:
pre-up /usr/sbin/ethtool -s $IFACE autoneg off 100 duplex full

Tuesday, October 18, 2011

IBM System x3650 M3 Disk Configuration

I just finished working with IBM System x3650 M3. In the beginning, I had trouble with both Ubuntu Server 10.04.3 LTS and Centos 6 not detecting internal harddisks. Doing a little bit search, some informed that the problem is due to the driver, but that is not the case, since Ubuntu Server 10.04.3 LTS already have it.
Then I tried with Centos 6 and faced the same problem, no harddisk detected. Fortunately, I found some info in a forum mention about one need to configure the harddisk in the BIOS first. Aha. This is actually where the issue exist.

In order to configure the harddisks in the BIOS, just boot up the server and wait until a screen mention about Megaraid WebBIOS Configuration, press Ctrl-H.
Then, configure the harddisks as Array RAID. After that, just use Configuration Wizard to set them as as many Disk Group as needed. At this point, Centos 6 could detect the harddisk.

Find official guide from IBM, Installation and User's Guide - IBM ServeRAID-M Software (WebBIOS, MegaRAID Storage Manager, and MegaCLI), here.

Friday, August 5, 2011

PS2 Keyboard Freeze

I faced a problem with random PS2 keyboard freeze on my ACER Aspire M3970, Ubuntu 10.10. Really frustrating, because the only way to fix this is by restarting the computer.
After doing a bit research, some people suggest to disable USB Legacy Support in the BIOS. I did it already and still monitoring the result.
Hopefully this would solve the random keyboard freeze issue.

Friday, March 12, 2010

Automatic Display Manager Login using nodm

My posting @ https://answers.launchpad.net/ubuntu/+question/101990

I tried your method and it worked. I have been playing around to get such result for two days. Well, actually there is a little bit of story before I get the result that I wanted. So, I tried some other similar method to Curtis', in my VirtualBox Ubuntu Guest OS. The strange thing is I kept getting problems. The X did not start, and the virtual console resolution got big and too wide.
I had a feeling that I might get different result in "real" system. So, I installed ubuntu 9.10 and applied Curtis' method. It worked. I am glad. What I noticed is that the X is running in virtual terminal #9 (instead of #7). No issue.

I have another method though. During my search, someone mentioned about 'nodm' for automatic display manager. Neat! Yesterday I tried it on VirtualBox with no success. Today I tested it in "real" system and all is well. I really recommend this method.
During 'nodm' installation, I had to remove existing display manager(s) first. Then, set the proper configuration in /etc/default/nodm. Enjoy!

Thursday, February 4, 2010

Send key in Linux (Ubuntu)

I have a dell mini 9 laptop which only have Fn keys from F1 to F10. Sometimes I need F11 key for fullscreen browsing, and maybe even F12 key, but they are missing. This little thing annoys me, so I was thinking about a way to send key in Linux.
I did not want to install any other piece of software for this little thing. So, I was thinking about using what is already there in my Ubuntu (default) installation.
xte is just the tool that I needed.
To give you an example, here is the command to send F11 key to active window.

$ xte "key F11"


Pretty neat.

Notes: I just figured out to use F11 and F12 in dell mini 9. Use Fn+z for F11, Fn+x for F12. I tested both keys in Ubuntu 9.04.

Saturday, July 18, 2009

Set super+l shortcut key for locking screen in gnome

The default shortcut keys to lock screen in gnome is <ctrl><alt>l (it is small caps 'L'). I do not like that shortcut and prefer to use the combination of "super key" and "l", which actually defined as <Mod4>l. The keybinding GUI setting somehow does not accept any combination of super key with other keys. So, to be able to do that, you need to use gconf-editor.
Perform the following:

run gconf-editor,
option 1, from CLI:
$ gconf-editor


option 2, from GUI:
press <Alt>F2 to get the 'run application' dialog and type in gconf-editor and click 'run'

In gconf-editor window, go to the following key location, by expanding the keys tree:
/apps/gnome_settings_daemon/keybindings


then, double click 'screensaver' key and change the value to: <Mod4>l

and you are done. Test it by pressing super key and l.

There is also feature to search the key name and value, by pressing <Ctrl>f in gconf-editor. Actually, I found the correct location of the 'screensaver' key by searching it.

Friday, July 10, 2009

backup and restore MBR

Partition Table backup

Perform the following command to backup the partition table:
sfdisk -d /dev/hdx > /part/to/pt_info.sfdisk



Partition Table restore

Perform the following command to restore the partition table:
sfdisk -d /dev/hdx < /part/to/pt_info.sfdisk



MBR backup

Perform the following command to backup the MBR:
dd if=/dev/hdx of=/path/to/image count=1 bs=512



MBR restore

Perform the following command to restore the MBR:
dd if=/path/to/image of=/dev/hdx count=1 bs=446

Notice that you need to include the option "count=1 bs=446", otherwise your partition table will be overwritten.

Wednesday, July 8, 2009

Install chromium browser with flash plugin in ubuntu

Install chromium browser with flash plugin in ubuntu

Add the following repository in your apt's sources.list
deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main


Add the key for it
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4E5E17B5


Perform the following
$ sudo aptitude update
$ sudo aptitude install chromium-browser


Chromium browser should be installed and ready to be used. If you already installed flashplugin you can add the plugin to chromium-browser. I noticed the browser takes a lot of resource after adding flashplugin, so I no longer user. To set flashplugin perform the following.
$ cd /usr/lib/chromium-browser/plugins
$ sudo ln -s /usr/lib/flashplugin-installer/libflashplayer.so

Monday, June 8, 2009

"service" like redhat

"service" like redhat

One of many things that I like in Redhat is "service" tool to start, stop registered service (daemons). I realised that in my current ubuntu 8.10, this tool is already installed by default, which is really good. I am pretty sure that it will still available in newer release.
What about in Debian? To have such tool, you need to install "sysvinit-utils" package.

# aptitude install sysvinit-utils


to use it, simply type like the following
# service  start
# service stop
# service restart
# service status


In ubuntu (also in debian, if I'm not mistaken), you can use "tab" command completion, when you are trying to enter the . Very neat!

Saturday, February 21, 2009

vnc over ssh

For those who like to use vnc to work with remote computer, you should be aware that the traffic is not encrypted. Please refer to tightvnc faq page for information about this. Just like what recommended in the faq, ssh is required to secure the traffic.

Create a tunnel between your local and remote computer, and one way to do this is:
$ ssh -CNT username@remote_computer -L 5901:127.0.0.1:5900

Now, simply set your vnc viewer to access localhost with port 5901.

An example of using vncviewer is:
$ vncviewer localhost:5901

Friday, February 20, 2009

ecryptfs == privacy

ecryptfs == privacy

Simple and nice way to protect your documents in linux.
Install ecryptfs by executing the following command:
$ sudo apt-get install ecryptfs-utils

Create a directory where you want to put those private documents. For example I will create a folder in my home, named "Personal", and set the permission only to owner.
$ mkdir ~/Personal
$ chmod 700 ~/Personal

Mount that directory as eCryptfs filesystem.

$ sudo mount -t ecryptfs ~/Personal ~/Personal
I chose passphrase, aes, and 16-bit. For plaintext passthrough I chose "no" (no non-ecrypted files allowed in the mount).

Move, copy, create all private documents into ~/Personal directory.

When done, umount ~/Personal by executing:
$ sudo umount ~/Personal

All the files inside that directory can not be opened unless you mount it as ecryptfs filesystem.

Next time you mount, use the following command, so it will only ask for passphrase.
$ sudo mount -t ecryptfs ~/Personal ~/Personal -o key=passphrase,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n

Thursday, February 19, 2009

ssh tunneling

ssh tunneling

In the client execute:
$ ssh -N -D user@CompB

where CompB is the server

To use this ssh tunneling with internet browser, for example firefox, change the "Connection Settings", under "Manual proxy configuration", update the "SOCKS Host:" to localhost:any_free_port. Notice that any_free_port here must be the same one as the one used in ssh.

Opera browser does not have socks proxy configuration. One way to do it is by using "tsocks."
Install tsocks:
$ sudo apt-get install tsocks

edit /etc/tsocks.conf, and change
server = 127.0.0.1 # this is localhost
server_port = # again, this must match with the port used in ssh.

screen

I work remotely a lot, and mostly using ssh, since it's more secure than telnet. There's a time when the process takes very long time, and I don't want to always be connected the whole time.
The problem is, when I put the process in the background (using ctrl-z and bg, or using "&" when executing), when I exited the remote shell, all processes belong to that remote shell will be terminated.

One way to resolve this issue is using "nohup". This is very useful when the process does not require any interaction. Still I'm not satisfied with "nohup."

Then I came across this very neat tool, "screen." Very elegant way to do things remotely.

Do the following:

$ screen

it will give you the session, and start to do any activity. So, when I want to leave the remote shell. Press --> ctrl-a, d. That command will detach the screen session, and it's save to exit the remote shell.

To resume that particular session. Login again to the remote computer, then look at the detached session, by:
$ screen -ls
$ screen -r <session_id>

rsync + ssh => resumable download

rsync + ssh => resumable download

Sometimes ago, I felt the necessity of being able to resume my download from another computer, specially if the file is quite big. In this case, it's time to use rsync. Since mostly I use ssh to access remote computer, so I combine rsync with ssh.

Here's how to do it:
$ rsync --partial --progress --rsh=ssh user@server:/serverpath/to/file /localpath/to/file

Now, what if you need to use non-standard ssh port? Let's say you need to connect to ssh via port 7890. The command will be like the following:
$ rsync --partial --progress --rsh='ssh -p7890' user@server:/serverpath/to/file /localpath/to/file

The neat thing is that there is also progress indicator shown.

Tuesday, February 17, 2009

Resolve Windows hostname in Linux

Resolve Windows hostname in Linux

I work a lot in heterogeneous environment, and ofcourse, windows is one of the system in that network. So, I would like to be able to resolve windows hostname (netbios) and access it's resource. In order to do that, there are packages needed to be installed first.

$ sudo apt-get install winbind

after that, edit /etc/nsswitch.conf configuration file.
Search for word "hosts", and add "wins" at the end of the line. Below is an example of "hosts" configuration after update.

# /etc/nsswitch.conf
#
# ....

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 wins

#....

after that, restart winbind service (if necessary). Now, windows computers should be able to be accessed using it's windows hostname. Pretty convenient way to access those windows computer in the network.

If you are still not able to resolve windows hostname, perhaps there is a firewall running in your computer. In that case you need to add extra rule to allow udp.

I use firestarter for my personal firewall, and what I did was edit the /etc/firestarter/inbound/setup configuration file.
Search for:
$IPT -A INBOUND -p udp -m state --state ESTABLISHED,RELATED -j ACCEPT
and put the following rule right after it:
$IPT -A INBOUND -s $NET -p udp -m state --state NEW -j ACCEPT

restart firestarter, to load the new config. Try to access windows computer using it's hostname again.


I just found out a way to configure UFW for this matter.
First edit: /etc/default/ufw
Search for:

IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_irc nf_nat_irc"

and change it to:
IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_irc nf_nat_irc nf_conntrack_netbios_ns"


Then: reload ufw
# sudo ufw reload

Next step: Configure UFW Rules
Allow outgoing UDP to port: 137, 138
Allow outgoing TCP to port: 139, 445


Sunday, February 15, 2009

convert bin to iso (linux)

convert bin to iso (linux)

To convert bin file to iso format, simply use bchunk tool in linux.
Check whether it's already in your system (ex. $ which bchunck).
If not, install the tool first by executing:
$ sudo apt-get bchunk


after that, let's convert bin to iso, by executing:
$ bchunk binimage.bin binimage.cue isoimage


Notice that bchucnk needs cue file (as second argument).
If there is no cue file, do not panic, since it's easy to create the cue file.

Below is a simple shell script to create cue file and convert bin to iso:
#!/bin/bash
printf "FILE $1.bin BINARY\nTRACK 01 MODE1/2352\nINDEX 01 00:00:00\n" > $1.cue
bchunk $1.bin $1.cue $1_
rm $1.cue


save the script to a file, don't forget to chmod +x, and run it.