Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Friday, October 7, 2011

How to install kubuntu-desktop

I played with my laptop in struggling to install libgtk2.0-dev. Unfortunately my ubuntu-desktop crashed, I was unable to log-on via the GUI anymore and only able to have the command prompt.

I tried to reinstall ubuntu-desktop but the system doesn't happy at all.
Since I need to get this laptop going immediately, I tried to change the desktop with kbuntu.
here is the command i'm using
sudo apt-get install kubuntu-desktop

I also had to change my network setting to dhcp as well. It was using static before.

auto lo eth0
iface eth0 inet dhcp
iface lo inet loopback


Sunday, June 26, 2011

To find out what application is listening on a port

I keep forgotten the command as mentioned on the subject of this blog.
Hopefully I can find out this command easily without having to googling anymore.
lsof -i :80

Tuesday, June 22, 2010

How to install VPN Client on Ubuntu 10.04

I was trying to install Cisco VPN client to enable my laptop -which is runing on Ubuntu 10.04- to allow this machine connect to my office via VPN.

I got several error messages when I tried to compile this application.
Fortunately, I found the page below.

Thanks to L.A.M.N.K for documenting the step-by-step so that I'm now able to use Cisco VPN client on
my Ubuntu.

First, download the source from the tuxx website.
Then, follow the steps that I copied and pasted from the L.A.M.N.K below

Cisco module again doesn’t let us compile against the new kernel in Ubuntu 9.04 and 9.10 beta:

/home/lamnk/vpnclient/interceptor.c: In function ‘interceptor_init’:
/home/lamnk/vpnclient/interceptor.c:132: error: ‘struct net_device’ has no member named ‘hard_start_xmit’
/home/lamnk/vpnclient/interceptor.c:133: error: ‘struct net_device’ has no member named ‘get_stats’
/home/lamnk/vpnclient/interceptor.c:134: error: ‘struct net_device’ has no member named ‘do_ioctl’
/home/lamnk/vpnclient/interceptor.c: In function ‘add_netdev’:
/home/lamnk/vpnclient/interceptor.c:271: error: ‘struct net_device’ has no member named ‘hard_start_xmit’
/home/lamnk/vpnclient/interceptor.c:272: error: ‘struct net_device’ has no member named ‘hard_start_xmit’
/home/lamnk/vpnclient/interceptor.c: In function ‘remove_netdev’:
/home/lamnk/vpnclient/interceptor.c:294: error: ‘struct net_device’ has no member named ‘hard_start_xmit’
make[2]: *** [/home/lamnk/vpnclient/interceptor.o] Error 1
make[1]: *** [_module_/home/lamnk/vpnclient] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.31-1-generic'
make: *** [default] Error 2
Failed to make module "cisco_ipsec.ko".

Before installtion I assume that you have the latest version 4.8.02.0030 and the required packages for compiling ie gcc, libstdc++6 … The kernel version should be from 2.6.30 to 2.6.32

  • Download the client and extract it
  • Go to vpnclient folder:
    cd vpnclient

  • Download patch file for 64 bit and apply it (users on 32bit systems can skip this step):

    wget http://lamnk.com/download/vpnclient-linux-4.8.02-64bit.patch

    patch < ./vpnclient-linux-4.8.02-64bit.patch

    sed -i 's/^CFLAGS/EXTRA_CFLAGS' Makefile

  • Download patch file for newer kernel (2.6.30+) and apply it:

    wget http://lamnk.com/download/vpnclient-linux-2.6.31-final.diff

    patch < ./vpnclient-linux-2.6.31-final.diff

  • Next we must edit a kernel source file

    sudo sed -i 's/const\ struct\ net_device_ops\ \*netdev_ops;/struct\ net_device_ops\ \*netdev_ops;/' `find /usr/src -name netdevice.h`

    Yes, it is a one liner, you should copy & paste that command instead of typing ;)The command's translation into English: find the string const struct net_device_ops *netdev_ops; and change it to struct net_device_ops *netdev_ops; in the file locates at

    find /usr/src -name netdevice.h

  • And finally, install Cisco VPN Client:

    sudo ./vpn_install

The patch files are not from me. All credit goes to the people at tuxx-home.at forum

Sunday, May 30, 2010

SSH with PHP

I want to create an application that will be able to connect to an SSH server via PHP. I was thinking of using TCL expect and then integrate PHP and the expect script somehow. Fortunately, before I tried that, I did some searching on google and found that there is an SSH wrapper already that can suit my need.

To install the wrapper on Ubuntu, please find the steps below:

1. Install apache and PHP first
sudo apt-get install apache2 php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart
2. Make sure that the server/computer have a fully qualified domain name (FQDN). Otherwise, apache2 may not be able to start.
sudo vi /etc/hosts
sudo vi /etc/hostname

3. Install the library for ssh wrapper
sudo apt-get install libssh2-1-dev libssh2-php

4. Confirm that ssh has been installed correctly
php -m | grep ssh2

You are expecting to see "ssh2"

5. Finish

Now you can start to write PHP script to connect to an SSH server



Sunday, May 9, 2010

Linux system monitoring command

I was trying to remember what commands I will have to remember when monitoring performance of a Linux server. Luckily, I found this blog and it has the list of the commands.

The explanation and example on the blog is very good. However, it is too long for me as I will only need to recall the command in the future and don't need to many explanation. Therefore, I think it will be good for me if I summarize the command here for my reference in the future.

Here are the tools:
#1: top - Process Activity Command
#2: vmstat - System Activity, Hardware and System Information
#3: w - Find Out Who Is Logged on And What They Are Doing
#4: uptime - Tell How Long The System Has Been Running
#5: ps - Displays The Processes
#6: free - Memory Usage
#7: iostat - Average CPU Load, Disk Activity
#8: sar - Collect and Report System Activity
#9: mpstat - Multiprocessor Usage
#10: pmap - Process Memory Usage
#11 and #12: netstat and ss - Network Statistics
#13: iptraf - Real-time Network Statistics
#14: tcpdump - Detailed Network Traffic Analysis
#15: strace - System Calls
#16: /proc file system - Various Kernel Statistics

Reference : here

Sunday, April 18, 2010

Removing Ubuntu from dual-boot with Vista

My computer is now running dual-boot Ubuntu and Vista. I've been using Ubuntu on my day-to-day working and almost never coming back to Vista for a while.
However, I will give this machine to someone else, and therefore I need to remove Ubuntu from the machine and switch it back to Vista.

Before completely removing Ubuntu, I did a research of how to recover back the MBR. Luckily, I found this website, and here are the steps to restore the MBR for Vista:

1. Put the Windows Vista installation disc in the disc drive, and then start the computer.
2. Press a key when you are prompted.
3. Select a language, a time, a currency, a keyboard or an input method, and then click Next.
4. Click Repair your computer.
5. Click the operating system that you want to repair, and then click Next.
6. In the System Recovery Options dialog box, click Command Prompt.
7. Type Bootrec.exe /FixMbr, and then press ENTER.

I haven't tried that yet, I will try it when I'm ready to hand-over this machine. Hope it will works as expected.



Thursday, April 8, 2010

Remote Desktop on Linux


As previously mentioned on the previous post, I'm now trying to use my Ubuntu and leave Vista.
There were several small problems I experienced when I had to remove some servers which are running Windows 2003. The small problem is that I'm unable to copy some text on my destop and paste it into the remote server.

I've just discovered that this can be solved by using RDPv5.


Linux to Cisco console via USB

I've been moving to Ubuntu linux for a while on my daily work. Therefore I have to find a way of using my Ubuntu to do whatever I used to do with Vista.
Today I've just managed to connect my Ubuntu to Cisco console via USB. (note: I'm using USB-to-serial converter).

Here are the steps of make it works:
1. check what is the name of the USB tty
$ dmesg | grep ttyUSB
[ 4272.667300] usb 2-1: pl2303 converter now attached to ttyUSB0

2. Configure the mincom to connect to the port
$ minicom -s

3. Configure the setting below
speed = 9600
parity = none
stop bit = 1
serial = ttyUSB0

4. save setup as dfl
5. exit from mincom
5. start minicom
$ minicom

you should be able to see the Cisco console right now.

Thursday, September 24, 2009

My note on creating a user

To avoid wasting time and reinventing the wheel every time I created a new user on my server, I think I have to record the steps so I can save my time

Here are the steps:
1. adduser username
2. edit /etc/httpd/conf/extra/directadmin-vhosts.conf
3. create a new file, /etc/httpd/conf/extra/user-username.conf
4. Use :%s/oldstring/newstring/g to edit the file above
5. service httpd restart
6. Set quota for the user

If the user needs MySQL, need the following steps also:
1. mysql -u admin-name -p
2. create database;
3. grant all privileges on database.* to username@localhost identified by 'password';

That's it.

Quota in Linux

To set quota for the user, use the command below:
/usr/sbin/setquota

Then to see the quota, use the command below:
/usr/sbin/repquota

Tuesday, April 7, 2009

Command of the day

date +"%m-%d-%y" | awk '{print "filename filename" $1}'| xargs mv

The command above will rename a filename into filename with date of the day.

Wednesday, March 18, 2009

Command of the day

ps aux | grep http | awk '{print $2}' | xargs kill

Wednesday, March 11, 2009

Install FreeTDS on Ubuntu

I've been struggling to install FreeTDS on Ubuntu. Fortunately, google is still the best friend. I found the link below and manged to install it.

http://ubuntuforums.org/showthread.php?p=6823026

I copied the posting here as well. Thanks for Mahalie for the post.

-----------------------------------------------------------------------------------------------
After a lot of doc reading at PHP.net, FreeTDS and here and trying and then backing out of several attempts to get my Ubuntu Lamp on Dapper Drake LTS to connect via ODBC to a Microsoft SQL Server on our corporate network I found a step-by-step tutorial that worked for me here:http://benlinus.blogspot.com/2007/08...module-in.html

Here is how I did it - already running working LAMP with PHP5. 

Code:
sudo apt-get install freetds-dev sudo apt-get source php5 cd php5-5.1.2/ext/mssql sudo apt-get install php5-dev sudo phpize sudo ./configure --with-mssql sudo make cd modules cp mssql.so /usr/lib/php5/20051025 sudo vi /etc/php5/apache2/php.ini
add the following line:
Code:
extension = mssql.so
Code:
sudo /etc/init.d/apache2 restart
To confirm if MSSQL support is available, create a new php file and execute phpinfo() function. 

To test my connection tried code from PHP.net using MSSQL_CONNECT
PHP Code:
// Server in the this format: \ or  
// , when using a non default port number 

$server 'DBSERVERNAME.corp.DOMAIN.com'

$link mssql_connect($server'UserName''UserPassword'); 

if(!
$link

    die(
'Something went wrong while connecting to MSSQL'); 

?> 

Test

If you don't have errors, it's working. If you have 'cannot open default DB' then make sure your permissions for the user is set property on the MS SQL server and that their default database is the one you are pointing at.

Monday, October 27, 2008

How-To Change Time Zone in Linux

I was looking for how-to change time-zone in my linux box.
Fortunately, I found the website below:


Steps

  1. Logged in as root, check which timezone your machine is currently using by executing `date`. You'll see something like Mon 17 Jan 2005 12:15:08 PM PST, PST in this case is the current timezone.
  2. Change to the directory /usr/share/zoneinfo here you will find a list of time zone regions. Choose the most appropriate region, if you live in Canada or the US this directory is the "America" directory.
  3. If you wish, backup the previous timezone configuration by copying it to a different location. Such as
    mv /etc/localtime  /etc/localtime-old 
  4. Create a symbolic link from the appropiate timezone to /etc/localtime. Example:
    ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime 
  5. If you have the utility rdate, update the current system time by executing
    /usr/bin/rdate -s time-a.nist.gov 
  6. Set the ZONE entry in the file /etc/sysconfig/clock file (e.g. "America/Los_Angeles")
  7. Set the hardware clock by executing:
    /sbin/hwclock --systohc

Thursday, September 25, 2008

Install Exim with DKIM and Domainkeys on DirectAdmin

Installing Exim on DirectAdmin makes my day today. I have to dig several sites in order to finish the installation. I think It will be better to document it here. I may need it again in the future, or perhaps you may need this when you need to compile Exim with DKIM and domainkeys on Centos.

First, compile and install the DKIM:
wget http://duncanthrax.net/exim-experimental/libdkim-1.0.16-tk.tar.gz
tar zxvf libdkim-1.0.16-tk.tar.gz
cd libdkim-1.0.16-tk
cd src
make
make install
cd ..
cp lib/libdkim.a /usr/lib
cp include/dkim.h /usr/include/
Compline and Install Domainkeys:
tar zxvf libdomainkeys-0.69.tar.gz
cd libdomainkeys-0.69
make
echo -lresolv > dns.lib
make
make install
cp *.h /usr/local/include/
cp *.a /usr/local/lib
Download Exim:
wget http://files.directadmin.com/services/all/exim/exim-4.69.tar.gz
tar xvzf exim-4.69.tar.gz
cd exim-4.69/Local
wget http://www.directadmin.com/Makefile
perl -pi -e 's/^EXTRALIBS/#EXTRALIBS/' Makefile
Edit the Makefile:
EXPERIMENTAL_DKIM=yes
CFLAGS  += -I/usr/include
LDFLAGS += -ldkim -lssl -lstdc++ -L/usr/lib
EXPERIMENTAL_DOMAINKEYS=yes
CFLAGS  += -I/usr/local/include
LDFLAGS += -ldomainkeys -L/usr/local/lib
#added April 9, 2008
HAVE_ICONV=yes
CFLAGS=-O -I/usr/local/include
EXTRALIBS_EXIM=-L/usr/local/lib -liconv
#end add
Compile and Install it:
cd ..
make
make install
Last job, you need to rename the compiled exim and restart:
cp -f /usr/sbin/exim-4.69-12 /usr/sbin/exim
/sbin/service restart exim
That's it, you have exim with domainkeys on DirectAdmin now.




Monday, February 18, 2008

Apache prompt for pass-phrase on every start up

My Apache wasn't start when I rebooted the machine. It was prompting for pass-phrase while nobody was sitting in front of the machine. I'd better get rid off the the pass-phrase dialog to be prompted.

Found the solution as below.

How can I get rid of the pass-phrase dialog at Apache startup time?

The reason this dialog pops up at startup and every re-start is that the RSA private key inside your server.key file is stored in encrypted format for security reasons. The pass-phrase is needed decrypt this file, so it can be read and parsed. Removing the pass-phrase removes a layer of security from your server - proceed with caution!

  1. Remove the encryption from the RSA private key (while keeping a backup copy of the original file):

    $ cp server.key server.key.org
    $ openssl rsa -in server.key.org -out server.key

  2. Make sure the server.key file is only readable by root:

    $ chmod 400 server.key

Now server.key contains an unencrypted copy of the key. If you point your server at this file, it will not prompt you for a pass-phrase. HOWEVER, if anyone gets this key they will be able to impersonate you on the net. PLEASE make sure that the permissions on this file are such that only root or the web server user can read it (preferably get your web server to start as root but run as another user, and have the key readable only by root).

As an alternative approach you can use the ``SSLPassPhraseDialog exec:/path/to/program'' facility. Bear in mind that this is neither more nor less secure, of course.


source: http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#removepassphrase

Thursday, February 14, 2008

Instal Apache SSL on Ubuntu

Here are the list of installing Apache (version 1) with SSL on Ubuntu.
  • apt-get install apache libapache-mod-ssl
  • dpkg-reconfigure libapache-mod-ssl
  • fill in all details with your details
  • cp /usr/share/doc/libapache-mod-ssl/examples/mod-ssl.conf /etc/apache/conf.d/
  • cp /usr/share/doc/libapache-mod-ssl/examples/vhost.conf.gz /etc/apache/conf.d/
  • cd /etc/apache/conf.d/
  • gzip -d vhost.conf.gz
  • edit vhost.conf and change all snakeoil references to server. ie. snakeoil-dsa.crt = server.crt
  • stop apache
  • start apache
Have fun !!!

Saturday, December 22, 2007

Installing SSLeay on Ubuntu

I had a very hard time to install SSLeay on Ubuntu either by using cpan or compiling it directly from the source. It looks like that some headers were missing on the compilation process so I got so many errors and unable to compile the module.

I finally realized that there are always an easy way to do it on Ubuntu, as usual, by using apt-get.
Here is the command to install SSLeay on Ubuntu
sudo apt-get install libnet-ssleay-perl
sudo apt-get install libcrypt-ssleay-perl

Tuesday, November 13, 2007

Installing Debian without any CD installer

I really wanted to install Debian on my machine but I didn't have any CD installer of Debian. I was thinking of downloading the image from the web, but unfortunately I didn't have any empty CD to burn the image.
Finally I found a very good page on Debian website, telling that it is possible to install Debian without any Debian CD. It said that Debian can be installed over the network as long as I have a working *NIX OS on my machine. It is a very good solution to me since I have Ubuntu already on my machine. Then I only need to create another partition for Debian, follow the steps, and then now I'm running Debian.

The complete instructions can be found here

There are some additional steps need to be done on my machine since the instructions above will only install Debian without the GUI.
Here are the steps:
1) Login as root
2) apt-get install x-windows-system-core
3) apt-get install gdm
4) apt-get install gnome

That's it. Have a nice try.