When setting up networking, one of useful tool is the cidr tables, where you can refer the netmask and you can determine the cidr length for your netmask. Usually people will search the internet for network calculator or try to search for the cidr table. There is another easy way for you to have a cidr table installed in your computer and you can refer to it anytime you want using a single command. The package is perl-Net-IP. Install it using yum.
# yum install perl-Net-IP
After the installation finished, you can refer to the cidr table using the below command:
# iptab
There you go, a cidr table installed in your own computer for your own reference anytime. Have fun :-)
Wednesday, December 19, 2007
Tuesday, December 18, 2007
Sending message to users
To send message to a particular user, you have to know what is the user tty. You can do this by typing:
# w
This command is used to show who is logged on and what they are doing. The output of the above command is usually like below(Click to see the image clearly):
To send message to a specific user:
$ write username tty
Example, to send message to user user1:
$ write user1 pts/3
Write you messages, and then press Ctrl-d to exit 'write'
To send message to all connected user, use wall command:
$ wall
Type your message and Ctrl-d to exit 'wall'
# w
This command is used to show who is logged on and what they are doing. The output of the above command is usually like below(Click to see the image clearly):
To send message to a specific user:
$ write username tty
Example, to send message to user user1:
$ write user1 pts/3
Write you messages, and then press Ctrl-d to exit 'write'
To send message to all connected user, use wall command:
$ wall
Type your message and Ctrl-d to exit 'wall'
Wednesday, November 21, 2007
Mounting LVM Disk using Ubuntu livecd
Mounting is an easy process to do, provided the filesystem type you are using is supported. What happen when you have an LVM formatted disk, and you need to mount it because the disk cannot be booted and a hell lot of valuable data kept inside?? Do not worry, because the solution is here.......
1. Get a live cd, for example, Ubuntu. For this article, I use Ubuntu 6.06 (I cannot find any latest version of ubuntu at my place)
2. Boot using the live cd. Search for these tools: lvm2. If the cd do not have it, install it.
# apt-get install lvm2
3. To make sure the harddisk is recognised, you can use fdisk
# fdisk -lu
4. Once installed, run pvscan to scan all disks for physical volume. this to make sure your LVM harddisk is detected by Ubuntu
# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free]
Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]
5. After that run vgscan to scan disks for volume groups.
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
6. Activate all volume groups available.
# vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active
7. Run lvscan to scan all disks for logical volume. You can see partitions inside the hard disk now active.
# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit
8. Mount the partition to any directory you want, usually to /mnt
# mount /dev/VolGroup00/LogVol00 /mnt
9. You can access the partition in the /mnt directory and can backup your data
1. Get a live cd, for example, Ubuntu. For this article, I use Ubuntu 6.06 (I cannot find any latest version of ubuntu at my place)
2. Boot using the live cd. Search for these tools: lvm2. If the cd do not have it, install it.
# apt-get install lvm2
3. To make sure the harddisk is recognised, you can use fdisk
# fdisk -lu
4. Once installed, run pvscan to scan all disks for physical volume. this to make sure your LVM harddisk is detected by Ubuntu
# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free]
Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]
5. After that run vgscan to scan disks for volume groups.
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
6. Activate all volume groups available.
# vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active
7. Run lvscan to scan all disks for logical volume. You can see partitions inside the hard disk now active.
# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit
8. Mount the partition to any directory you want, usually to /mnt
# mount /dev/VolGroup00/LogVol00 /mnt
9. You can access the partition in the /mnt directory and can backup your data
Sunday, November 11, 2007
Combining multiple network interface into single interface (bond)
Bonding is a process of combining more multiple network interfaces as one interface. The main objective of bonding is to improve the performance of both network interface. Using this way, more load and data can be handled by the bonded network interface rather than using single network interface. In this how to, I will use only two interfaces as example.
1. Create bond configuration file (example bond0)
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
2. Put below configuration inside the bond0 configuration file
3. Open the first network interface configuration file
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
4. Append with the below details and save
# vim /etc/sysconfig/network-scripts/ifcfg-eth1
6. Edit the file to become like below and save
# vim /etc/modprobe.conf
8. Append below details and save
# modprobe bonding
10. Restart network
# /etc/init.d/network restart
11. You can check whether your bonding is ok by using ifconfig command
# ifconfig
The output should be something like below
1. Create bond configuration file (example bond0)
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
2. Put below configuration inside the bond0 configuration file
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
Replace above ip address, network and netmask with actual details and save the configuration file3. Open the first network interface configuration file
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
4. Append with the below details and save
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
5. Open the second network interface configuration file# vim /etc/sysconfig/network-scripts/ifcfg-eth1
6. Edit the file to become like below and save
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
7. Load bond module# vim /etc/modprobe.conf
8. Append below details and save
alias bond0 bonding
options bond0 mode=balance-alb miimon=100
9. Load the bonding module# modprobe bonding
10. Restart network
# /etc/init.d/network restart
11. You can check whether your bonding is ok by using ifconfig command
# ifconfig
The output should be something like below
bond0 Link encap:Ethernet HWaddr 00:0C:29:C6:BE:59
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:250825 (244.9 KiB) TX bytes:244683 (238.9 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:C6:BE:59
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251161 (245.2 KiB) TX bytes:180289 (176.0 KiB)
Interrupt:11 Base address:0x1400
eth1 Link encap:Ethernet HWaddr 00:0C:29:C6:BE:59
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:258 (258.0 b) TX bytes:66516 (64.9 KiB)
Interrupt:10 Base address:0x1480
Monday, November 5, 2007
Installing wireless on fedora 7 IBM Thinkpad r60 machine
You just bought a new laptop, IBM Thinkpad R60. Since you are an open source fans, you have decided to install the latest stable version of fedora, the fedora 7. After finish installing operating system, you try to access your office's wireless internet connection. but to your surprise there is no wireless options can you find on the start up menu. Don't panic, because there is a way how to configure your new laptop so that it can access wireless internet connection.
1. Check your wireless adapter.
$ cat /etc/sysconfig/hwconf | grep -i wireless
or
$ kudzu -p | grep -i wireless
2. The outcome usually will be like this: desc: "Intel Corporation 3945ABG Network Connection"
If your outcome of the command is also similar to the above, then you are in the right place :-).
3. The driver of that wireless device is not pre-installed on Fedora 7. So you have to install the driver from additional repository. Access you machine as root, and create file /etc/yum.repos.d/atrpms.repo
$ vim /etc/yum.repos.d/atrpms.repo
Insert the following content in the atrpms.repo
[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/fc$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
Import also the atrpms signing key
4. Install ipw3945 driver.
$ yum install ipw3945
5. You have to start the daemon in order for the driver to work. Add /sbin/ipw3945d to your /etc/rc.local
$ echo "/usr/sbin/ipw3945d" >> /etc/rc.local
6. Restart your machine.
7. You can also activate a service named NetworkManager to easily choose from GUI the wireless connection that you desire.
$ NetworkManager
$ chkconfig NetworkManager on - This command set NetworkManager to start on boot
8. You can scan for wireless network around you by using the below command
$ iwlist scan
1. Check your wireless adapter.
$ cat /etc/sysconfig/hwconf | grep -i wireless
or
$ kudzu -p | grep -i wireless
2. The outcome usually will be like this: desc: "Intel Corporation 3945ABG Network Connection"
If your outcome of the command is also similar to the above, then you are in the right place :-).
3. The driver of that wireless device is not pre-installed on Fedora 7. So you have to install the driver from additional repository. Access you machine as root, and create file /etc/yum.repos.d/atrpms.repo
$ vim /etc/yum.repos.d/atrpms.repo
Insert the following content in the atrpms.repo
[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/fc$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
Import also the atrpms signing key
rpm --import http://ATrpms.net/RPM-GPG-KEY.atrpms
4. Install ipw3945 driver.
$ yum install ipw3945
5. You have to start the daemon in order for the driver to work. Add /sbin/ipw3945d to your /etc/rc.local
$ echo "/usr/sbin/ipw3945d" >> /etc/rc.local
6. Restart your machine.
7. You can also activate a service named NetworkManager to easily choose from GUI the wireless connection that you desire.
$ NetworkManager
$ chkconfig NetworkManager on - This command set NetworkManager to start on boot
8. You can scan for wireless network around you by using the below command
$ iwlist scan
Thursday, October 25, 2007
Changing resolution and refresh rate in ubuntu
You boot up your ubuntu box as usual. Suddenly you notice something wrong: your resolution has changed without you changing it. You go to system preference and try to change the display resolution, but there is no optinon for your preferred setting. Don't panic, there still hope for your ubuntu machine besides reformat :-).
This is what you can do to repair back the display problem. You have to reconfigure Xorg. But before you do anything, please backup your configuration file just in case anything bad happens.
Backup your xorg.conf file
$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
This is how you can reconfigure Xorg
1. Stop your gdm (Gnome display manager), or kdm (KDE display manager) if you use kde desktop environment.
$ sudo /etc/init.d/gdm stop (or kdm for kde)
2. Reconfigure your xorg
$ dpkg-reconfigure xserver-xorg
3. Follow all the instruction. By default, choose 'yes' or 'ok' for every options
4. After finish reconfigure, start back gdm or kdm
$ sudo /etc/init.d/gdm start (or kdm for kde)
Hope this can help.
This is what you can do to repair back the display problem. You have to reconfigure Xorg. But before you do anything, please backup your configuration file just in case anything bad happens.
Backup your xorg.conf file
$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
This is how you can reconfigure Xorg
1. Stop your gdm (Gnome display manager), or kdm (KDE display manager) if you use kde desktop environment.
$ sudo /etc/init.d/gdm stop (or kdm for kde)
2. Reconfigure your xorg
$ dpkg-reconfigure xserver-xorg
3. Follow all the instruction. By default, choose 'yes' or 'ok' for every options
4. After finish reconfigure, start back gdm or kdm
$ sudo /etc/init.d/gdm start (or kdm for kde)
Hope this can help.
Tuesday, October 23, 2007
Postgresql quickstart
Reference on commands commonly used in postgresql administration. Enjoy....
1. To start postgres
# /etc/init.d/postgresql start
2. To stop postgres
# /etc/init.d/postgresql stop
3. To start using postgres, change to user postgres
$ su - postgres
4. To create new database
$ createdb dbname
5. To delete database
$ dropdb dbname
6. To access database
$ psql dbname
7. To dump database (backup)
$ pg_dump dbname > backup.out
8. Reload db from file
$ psql -d dbname -f db.out
9. To dump all database to file
$ pg_dumpall > dumpall.sql
10. Reload all from file
$ psql -f dumpall.sql
11. List database
$ psql -l
12. Clean all database
$ vacuumdb --quiet --all
Commands inside psql (PostgreSQL interactive terminal)
1. Access psql
# psql
2. Get help about commands
# \h
3. Quit psql
# \q
4. Import from file
# \i input.sql
5. Show databases
# \l
6. Show tables
# \dt
7. Show users
# \du
8. Connect to database
# \c dbname
9. Change user password
# \c template1
# ALTER USER postgres with password 'new_password';
10. Clean database
# VACUUM FULL;
11. Help on syntax command
# \h SYNTAXNAME
1. To start postgres
# /etc/init.d/postgresql start
2. To stop postgres
# /etc/init.d/postgresql stop
3. To start using postgres, change to user postgres
$ su - postgres
4. To create new database
$ createdb dbname
5. To delete database
$ dropdb dbname
6. To access database
$ psql dbname
7. To dump database (backup)
$ pg_dump dbname > backup.out
8. Reload db from file
$ psql -d dbname -f db.out
9. To dump all database to file
$ pg_dumpall > dumpall.sql
10. Reload all from file
$ psql -f dumpall.sql
11. List database
$ psql -l
12. Clean all database
$ vacuumdb --quiet --all
Commands inside psql (PostgreSQL interactive terminal)
1. Access psql
# psql
2. Get help about commands
# \h
3. Quit psql
# \q
4. Import from file
# \i input.sql
5. Show databases
# \l
6. Show tables
# \dt
7. Show users
# \du
8. Connect to database
# \c dbname
9. Change user password
# \c template1
# ALTER USER postgres with password 'new_password';
10. Clean database
# VACUUM FULL;
11. Help on syntax command
# \h SYNTAXNAME
Wednesday, September 26, 2007
Turning on bind query logging
If you want to turn on the query logging for bind, you can use the rndc command.
$ rndc querylog
To see whether your querylog is on or off, use this below command:
$ rndc status
or
$ /etc/init.d/named status
After running the above command, you can see these lines:
[root@secondary-dns ~]# rndc status
number of zones: 5
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is ON
recursive clients: 0/1000
tcp clients: 0/100
server is up and running
$ rndc querylog
To see whether your querylog is on or off, use this below command:
$ rndc status
or
$ /etc/init.d/named status
After running the above command, you can see these lines:
[root@secondary-dns ~]# rndc status
number of zones: 5
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is ON
recursive clients: 0/1000
tcp clients: 0/100
server is up and running
Tuesday, September 11, 2007
Converting flv files to avi and mpeg
In linux we have a good tool, although text based, to convert between various video format. The tool is ffmpeg. This article will guide you on how you can convert flv format video to avi and mpg.
1. change your directory to the directory where your flv video is located.
2. run ffmpeg command:
$ ffmpeg -i input.flv output.avi
where -i stands for input and output.avi is the output file in avi or mpg.
3. For more advanced setting, you can use the command below
$ ffmpeg -i input.flv -ab 56 -ar 22050 -b 500 -s 320x240 output.mpg
where -ab is audio bitrate with default of 64kbps
-ar is audio samplerate with default of 44100Hz
-b is video bitrate with delault of 2000kbps
-s is size with default of 160x128px
1. change your directory to the directory where your flv video is located.
2. run ffmpeg command:
$ ffmpeg -i input.flv output.avi
where -i stands for input and output.avi is the output file in avi or mpg.
3. For more advanced setting, you can use the command below
$ ffmpeg -i input.flv -ab 56 -ar 22050 -b 500 -s 320x240 output.mpg
where -ab is audio bitrate with default of 64kbps
-ar is audio samplerate with default of 44100Hz
-b is video bitrate with delault of 2000kbps
-s is size with default of 160x128px
Wednesday, September 5, 2007
Resetting mysql root password
Sometimes you have to access a mysql database and you somehow does not know the password or the user of the database. The last resort is you have to use the root password but the password is unknown. There is always the way to solve anything and the way to reset the root password is described below. Enjoy!
1. Open a terminal and stop mysqld daemon if it has been started: $ /etc/init.d/mysqld stop
2. Type this command: $ mysqld_safe --skip-grant-tables
3. Open a new terminal, and access mysql database using root:
$ mysql -u root mysql
4. Change root password to new password: mysql> update user set password=password('newpassword') where user='root';
5. flush mysql privileges: mysql> flush privileges;
6. Exit mysql: mysql> exit
7. Close the terminal with the mysqld_safe command
8. Restart mysql: $ /etc/init.d/mysqld start
1. Open a terminal and stop mysqld daemon if it has been started: $ /etc/init.d/mysqld stop
2. Type this command: $ mysqld_safe --skip-grant-tables
3. Open a new terminal, and access mysql database using root:
$ mysql -u root mysql
4. Change root password to new password: mysql> update user set password=password('newpassword') where user='root';
5. flush mysql privileges: mysql> flush privileges;
6. Exit mysql: mysql> exit
7. Close the terminal with the mysqld_safe command
8. Restart mysql: $ /etc/init.d/mysqld start
Thursday, August 23, 2007
Setting up your own ntp server
NTP or network time protocol is a protocol that will synchronize the time of a computer client or server to another server or reference time source, such as a radio or satellite receiver or modem. Typical NTP configurations utilize multiple redundant servers and diverse network paths in order to achieve high accuracy and reliability.
Follow the below setup to install your ntp server:
1. install ntp: $ yum install -y ntp
2. edit ntp.conf: $ vi /etc/ntp.conf
example of ntp.conf:
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
#server mst.sirim.my prefer
#server my.pool.ntp.org
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
#server mst.sirim.my prefer
#server my.pool.ntp.org
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
3. If the server you are setting up do not have internet connection, you can synchronize it with the local time of the server itself. Just comment the server part, and change it to 127.127.1.0. The sratum level is for determining what level this time server is set up for. Stratum 0 usually refers to real clock, for example atomic (cesium, rubidium) clocks or GPS clocks or other radio clocks. Stratum 1 is the machine connected to stratum 0 devices.
#server mst.sirim.my prefer
#server my.pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10
4. synchronize the server's time with the ntp server: $ ntpdate -du mst.sirim.my
5. start ntp service: $ /etc/init.d/ntpd start
In the client machine, just type: $ ntpdate -du ntpservername. You can also put this command in crontab for the client to be update frequently
Follow the below setup to install your ntp server:
1. install ntp: $ yum install -y ntp
2. edit ntp.conf: $ vi /etc/ntp.conf
example of ntp.conf:
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
#server mst.sirim.my prefer
#server my.pool.ntp.org
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
#server mst.sirim.my prefer
#server my.pool.ntp.org
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
3. If the server you are setting up do not have internet connection, you can synchronize it with the local time of the server itself. Just comment the server part, and change it to 127.127.1.0. The sratum level is for determining what level this time server is set up for. Stratum 0 usually refers to real clock, for example atomic (cesium, rubidium) clocks or GPS clocks or other radio clocks. Stratum 1 is the machine connected to stratum 0 devices.
#server mst.sirim.my prefer
#server my.pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10
4. synchronize the server's time with the ntp server: $ ntpdate -du mst.sirim.my
5. start ntp service: $ /etc/init.d/ntpd start
In the client machine, just type: $ ntpdate -du ntpservername. You can also put this command in crontab for the client to be update frequently
Thursday, August 2, 2007
Installing lighttpd in Centos 5 for x86_64
Lighttpd is a fast and optimized web server that prioritize performance. To install this web server application, some additional work need to be done because there is no rpm compiled version of this web server for x86_64 architecture yet. So we have to do the hard work by getting the spec file, compiling the source and all. Steps to be taken to successfully install lighttpd on Centos 5 x86_64 machine are as below:
- get the rpm source file for lighttpd from here
- install the requirement needed to compile the source: pcre-devel 6.6-1.1, mysql-devel 5.0.22-2.1 and lua-devel. The first two can be be installed from yum: $ yum install -y pcre-devel mysql-devel. The last one can be downloaded from here and its dependencies can downloaded from here. Install the last dependencies using: $ rpm -Uvh lua-5.1.2-1.el5.kb.x86_64.rpm lua-devel-5.1.2-1.el5.kb.x86_64.rpm
- Install the lighttpd rpm source file: $ rpm -Uvh lighttpd-1.4.16-1.el5.src.rpm
- The spec file for lighttpd will be saved into /usr/src/redhat/SPECS
- Compile the spec file: $ rpmbuild -bb /usr/src/redhat/SPECS/lighttpd.spec
- The rpm for lighttpd will be saved into /usr/src/redhat/RPMS/x86_64. Install lighttpd: $ rpm -Uvh /usr/src/redhat/RPMS/x86_64/lighttpd-1.4.16-1.x86_64.rpm
- Check whether your lighttpd has been installed: $ rpm -qa | grep lighttpd If the result is as picture, your lighttpd is installed
Tuesday, July 31, 2007
Using crontab scheduler
Crontab is a tool for scheduling tasks for the computer to run. It will automate the jobs that needs to be done but will be difficult to be done by human because of time limitation. There are only 4 options for crontab which are -u, -e, -l and -r and the usage is described below:
* * * * * command to be run
1st * is for minutes (0-59)
2nd * is for hour (0-23)
3rd * is for day of month (1-31)
4th * is for month of year (1-12)
5th * is for day of the week (0-7) where 0=Sunday and 7=Sunday
Example:
To backup your pc using rsnapshot everyday at 7.30 a.m.;
- crontab -l - list all the crontab on standard output
- crontab -e - edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables
- crontab -r - remove the current crontab
- crontab -u - specify the user
- example: $ crontab -u username -l - this command will list the crontab belongs to the username
* * * * * command to be run
1st * is for minutes (0-59)
2nd * is for hour (0-23)
3rd * is for day of month (1-31)
4th * is for month of year (1-12)
5th * is for day of the week (0-7) where 0=Sunday and 7=Sunday
Example:
To backup your pc using rsnapshot everyday at 7.30 a.m.;
- $ crontab -e
- 30 7 * * * /usr/local/bin/rsnapshot daily
- save your crontab setting
Tuesday, July 24, 2007
System backup using rsnapshot
Rsnapshot is a filesystem snapshot utility that we can use for free to backup our system. To use this tool, user must have perl, ssh and rsync installed in their machine. Rsnapshot is an ideal tool for backup because it saves a lot of hard disk space. This can be done because the space needed is roughly the size of one full backup plus a copy of each additional file that is changed. The installation is also simple as shown below:
- install rsnapshot
- -> yum install rcsnapshot
- after installation, do some setting in /etc/rsnapshot.conf . Some of the important settings are as below:
- snapshot_root - change it to your preferred directory
- cmd_cp - for linux user, uncomment this option
- backup script
- backup user@servername:/folder/to/backed-up destination/in/snapshot_root
- interval - set this to set the frequency of snapshot to be taken. Please note that it must be arranged from smaller unit(hourly) on top to bigger one. For example:
- interval daily 7 - this means snapshot will be taken 7 times a week
- interval weekly 4 - this means snapshot will be taken 4 times a month
- Test the validation of the config file
- -> rsnapshot configtest
- Test run your command
- -> rsnapshot -t daily
- To backup, just run the below command(for daily)
- -> rsnapshot daily
Friday, July 20, 2007
Setting system clock and date
To set system clock and date using command, date command can be used.
This is how to do it:
-> date mmddttttyyyy.ss where;
mm - month
dd - day
tttt - time in hours and minutes
yyyy - year
ss - seconds
For example, to set the current date to 17 July 2007, 11:15 a.m., this command below can be used:
-> date 071711152007
To see the current date, the date command without argument can be used.
-> date
This is how to do it:
-> date mmddttttyyyy.ss where;
mm - month
dd - day
tttt - time in hours and minutes
yyyy - year
ss - seconds
For example, to set the current date to 17 July 2007, 11:15 a.m., this command below can be used:
-> date 071711152007
To see the current date, the date command without argument can be used.
-> date
Thursday, July 12, 2007
Setting default editor in ubuntu
To change the default editor for your ubuntu machine, here is the step:
Another method to do the similar task is by using command select-editor:
1. type the command
$ select-editor
Select an editor. To change later, run 'select-editor'.
1. /usr/bin/vim.tiny
2. /bin/ed
3. /bin/nano <---- easiest
Choose 1-3 [3]:
2. Choose from the list given. In the case above, if you want vim to be your default editor, type '1' and press 'enter'
3. Finish
- type:
- $ update-alternatives --config editor
- Select which editor that you want to set as default by typing its number. For below example, vim(1) is chosen.
Another method to do the similar task is by using command select-editor:
1. type the command
$ select-editor
Select an editor. To change later, run 'select-editor'.
1. /usr/bin/vim.tiny
2. /bin/ed
3. /bin/nano <---- easiest
Choose 1-3 [3]:
2. Choose from the list given. In the case above, if you want vim to be your default editor, type '1' and press 'enter'
3. Finish
Tuesday, July 10, 2007
SSH without password
Using the below steps, you can ssh to the server from client without the entering any password.
The machine which run the ssh command is the client
The machine that the client access using ssh is the server
The machine which run the ssh command is the client
The machine that the client access using ssh is the server
- Run the following command on the client
- -> ssh-keygen -t dsa
- File id_dsa and id_dsa.pub will be created inside $HOME/.ssh
- Copy id_dsa.pub to the server's .ssh directory
- -> scp $HOME/.ssh/id_dsa.pub user@server:/home/user/.ssh
- Change to /root/.ssh and create file authorized_keys containing id_dsa content
- -> cd /home/user/.ssh
- -> cat id_dsa >> authorized_keys
- Change "StrictModes yes" in /etc/ssh/sshd_config to "StrictModes no"
- Restart ssh server
- You can try ssh to the server from the client and no password will be needed
- -> ssh user@server
- Run the following command on the client
- -> ssh-keygen -t dsa
- File id_dsa and id_dsa.pub will be created inside $HOME/.ssh
- Copy the id_dsa.pub to the server's .ssh directory
- -> ssh-copy-id -i ~/.ssh/id_dsa.pub user@server
- Change "StrictModes yes" in /etc/ssh/sshd_config to "StrictModes no"
- Restart ssh server
- You can try ssh to the server from the client and no password will be needed
- -> ssh user@server
Wednesday, July 4, 2007
Understanding Linux Runlevels
Unlike most non-unix operating system, Linux have many runlevels. They are numbered from 0-6 like below.
0 - halt
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot
This list is taken from /etc/inittab file where init will find its configuration setting. The default runlevel usually is set to runlevel 5 where it is the graphical mode of linux. Halt means shutdown and runlevels 1-3 are non graphical mode. You can switch your runlevel by using;
-> init
To check your current runlevel, you can use;
-> runlevel
To view this list;
-> vi /etc/inittab
0 - halt
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot
This list is taken from /etc/inittab file where init will find its configuration setting. The default runlevel usually is set to runlevel 5 where it is the graphical mode of linux. Halt means shutdown and runlevels 1-3 are non graphical mode. You can switch your runlevel by using;
-> init
To check your current runlevel, you can use;
-> runlevel
To view this list;
-> vi /etc/inittab
Friday, June 22, 2007
Amarok cannot play mp3
If after you have installed media player amarok, and the player cannot play mp3 files, you have to install one more library: libxine-extracodecs
Run
-> sudo apt-get install libxine-extracodecs
or
use synaptic package manager to install the library
Run
-> sudo apt-get install libxine-extracodecs
or
use synaptic package manager to install the library
Tuesday, June 19, 2007
To search for string in files
To search for a string in all files from the given directory, grep command can be used. Type:
-> grep -R "string" /path
For example, to search for string "default" in /tmp directory, use this command:
-> grep -R "default" /tmp
-> grep -R "string" /path
For example, to search for string "default" in /tmp directory, use this command:
-> grep -R "default" /tmp
Monday, June 18, 2007
Changing default editor for your linux machine
Below are the steps to be taken to change your default editor. Usually for Ubuntu, the default editor is pico and for Centos is vi.
- To change your default editor to vi, type:
- -> export VISUAL=/usr/bin/vi
- To make it permanent for current user, add the above line to /home/user/.bash_profile
- To make it permanent globally, add the above line to /etc/profile
How to format your flash drive
This is how you can format your flash drive(thumbdrive, pendrive) in any linux machine
1. To see what is the filesystem for your flashdrive
1. To see what is the filesystem for your flashdrive
- type -> df
Friday, June 15, 2007
Installing flash player to mozilla firefox on x86 64 bit machine
- Download nspluginwrapper here
- Once dowloaded, extract it.
- Open the folder extracted and the folder inside it, double-click on "GetFlash". Select "Run in Terminal".
- When finished, restart firefox.
Thursday, June 14, 2007
rpm building error
When you try to build rpm file from source, if this error comes out:
error: Legacy syntax is unsupported: copyright
error: line 10: Unknown tag: Copyright: distributable
This error can be settled by modifying the spec file. Usually the source will have the spec file.
-> vi filename.spec
Then; change this line "Copyright: GPL" to "License: GPL". Save the changes.
Run back rpmbuild.
error: Legacy syntax is unsupported: copyright
error: line 10: Unknown tag: Copyright: distributable
This error can be settled by modifying the spec file. Usually the source will have the spec file.
-> vi filename.spec
Then; change this line "Copyright: GPL" to "License: GPL". Save the changes.
Run back rpmbuild.
How to view the content of iso image
Sometimes we have an iso image in our computer. One of the way to view it is to burn it on a cd and then we can view it. The other method is we can use mount command.
Type this command on terminal:
-> mount -o loop filename.iso /path/to/directory
where;
/path/to/directory - directory where you want to deploy the iso
filename.iso - name of the iso file
Type this command on terminal:
-> mount -o loop filename.iso /path/to/directory
where;
/path/to/directory - directory where you want to deploy the iso
filename.iso - name of the iso file
Wednesday, June 13, 2007
Bug Buddy dialog box keeps opening on Ubuntu
I don't know what is the cause..... but sometimes this phenomenon happens. When the bug buddy keeps bugging you with this error message " The information about the crash has been successfully collected.
The application that crashed is not known to bug-buddy, therefore the bug report can not be sent to the GNOME Bugzilla. Please save the bug to a text file and report it to the appropriate bug tracker for this application.", the solution is,
The application that crashed is not known to bug-buddy, therefore the bug report can not be sent to the GNOME Bugzilla. Please save the bug to a text file and report it to the appropriate bug tracker for this application.", the solution is,
- Open your terminal. If cannot, press ctrl+alt+F1.
- Type this command -> rm ~/.recently-used.xbel
- Restart your pc.
Wednesday, May 30, 2007
Mounting cdrom
If you are using a pc with linux that does not have automount feature, here are the steps that you can do to mount it on linux terminal.
This command is for the user to see disk space usage.
- After inserting the cd, create a folder. Usually we create a folder inside folder /mnt. Type --> mkdir /mnt/cdrom.
- To mount it, type --> mount /dev/cdrom /mnt/cdrom. This step will mount the content of the cdrom to the folder /mnt/cdrom
- After you finish, just type --> umount /mnt/cdrom to unmount it from the folder.
This command is for the user to see disk space usage.
Wednesday, May 23, 2007
List your hardware
If you want to view the hardware spec of your pc, you can use this command
--> lshw
This is how you see the hardware spec on your pc.
By default, this command is installed on ubuntu linux but not installed on Centos. You can use you tools like yum to install it
--> yum install lshw
--> lshw
This is how you see the hardware spec on your pc.
By default, this command is installed on ubuntu linux but not installed on Centos. You can use you tools like yum to install it
--> yum install lshw
Tuesday, May 22, 2007
Creating translation for dotproject
Dotproject is an open source project management system. It is built by default based in English language but whomever wants to translate it to their own native language, dotproject provide language management where the user can use other language in their dotproject. There are two ways to do this translation. First, if available, you can download the pre-translated configuration files from the internet and embed it in your dotproject system. Second, if there is no translation for your language available, you can create your own translation files and do the translation yourself. In this guide, I would like to show you how to do the translation yourself.
The steps:
$LANGUAGE['aa_BB'] = array($dir, 'Language Name (in English)', 'Language name (in Language)', 'xxx');
$dir = basename(dirname(__FILE__));
$LANGUAGES['ms_MY'] = array($dir, 'Malay', 'Bahasa Melayu', 'msl');
2. Create file lang.php inside the newly created folder. The content of the file is similar to the locales.php
3. Log in as system admin to your dotproject system. Go to System Admin > Translation Management and choose your language from the drop down menu. Start translating. DO NOT attempt to edit the INC files directly to create your translation - it won't work.
The steps:
- Create a new directory under dotproject/locales directory and name it according to your language iso code. Give appropriate permission to this folder (ex: write permission for others). The code can be found at http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txtCreate locales.php inside yor newly created folder. This is the content of the file(put it inside php tags):
$LANGUAGE['aa_BB'] = array($dir, 'Language Name (in English)', 'Language name (in Language)', 'xxx');
- aa_BB is the iso 2 character language code 'aa', followed by the ISO 2 character country code 'BB' (http://www.bcpl.net/~j1m5path/isocodes.html)
- The first instance of the language name should be in English The second should be in the native language. The last field 'xxx' is the Microsoft language code (http://msdn2.microsoft.com/en-us/library/ms533052.aspx)
$dir = basename(dirname(__FILE__));
$LANGUAGES['ms_MY'] = array($dir, 'Malay', 'Bahasa Melayu', 'msl');
2. Create file lang.php inside the newly created folder. The content of the file is similar to the locales.php
3. Log in as system admin to your dotproject system. Go to System Admin > Translation Management and choose your language from the drop down menu. Start translating. DO NOT attempt to edit the INC files directly to create your translation - it won't work.
Saturday, May 12, 2007
How to install yum on SuSE Linux 10.2
People using suse are familiar with yast. But in this article, I want to show how you can install yum, on your suse machine.
1. Download yum and all its dependencies from this link:
http://download.opensuse.org/distribution/10.2/repo/oss/suse/i586/
python-urlgrabber
python-sqlite
rpm-python
yum-metadata-parser (used option --nodeps)
yum
2. Install them all using this command: -> rpm -Uvh (name of packages above)
but for yum-metadata-parser use -> rpm -Uvh --nodeps yum-metadata-parser
3. Prepare yum config file
a. -> cd /etc/yum.repos.d/
b. create file with .repo (ex: suse.repo) containing:
[base]
name=OpenSUSE_10.2 Base
type=rpm-md
baseurl=http://download.opensuse.org/distribution/10.2/repo/oss/suse/
gpgcheck=1
gpgkey=http://download.opensuse.org/distribution/10.2/repo
/oss/gpg-pubkey-a1912208-446a0899.asc
enabled=1
4. yum is ready for usage.
1. Download yum and all its dependencies from this link:
http://download.opensuse.org/distribution/10.2/repo/oss/suse/i586/
python-urlgrabber
python-sqlite
rpm-python
yum-metadata-parser (used option --nodeps)
yum
2. Install them all using this command: -> rpm -Uvh (name of packages above)
but for yum-metadata-parser use -> rpm -Uvh --nodeps yum-metadata-parser
3. Prepare yum config file
a. -> cd /etc/yum.repos.d/
b. create file with .repo (ex: suse.repo) containing:
[base]
name=OpenSUSE_10.2 Base
type=rpm-md
baseurl=http://download.opensuse.org/distribution/10.2/repo/oss/suse/
gpgcheck=1
gpgkey=http://download.opensuse.org/distribution/10.2/repo
/oss/gpg-pubkey-a1912208-446a0899.asc
enabled=1
4. yum is ready for usage.
Wednesday, May 9, 2007
how to check your kernel version
Sometimes you want to know the particulars about the kernel of your linux. This can be done using uname command.
To check kernel version:
->uname -v
To check kernel release:
->uname -r
To check kernel name:
->uname -s
To check kernel version:
->uname -v
To check kernel release:
->uname -r
To check kernel name:
->uname -s
Tuesday, April 24, 2007
Installing Package In ubuntu using dpkg
If you are using Redhat Linux, you are most probably using rpm or yum as your package manager. in ubuntu, you can use synaptic package manager as your package manager and thankfully it got GUI. But for those who like to learn command based package management in ubuntu, you can use apt or dpkg command.
If you already have any package with .deb extension in your computer, you can use dpkg to install it. First you have to change directory to the directory where the package is stored. Then run: -> dpkg -i namefile.deb
Remember you need to be superuser to do this.
Example on how to install flashplayer using dpkg from /home/oscc/Desktop/tools folder
(click on the picture to see image clearly)
To get more information about dpkg, type:
-> man dpkg
If you already have any package with .deb extension in your computer, you can use dpkg to install it. First you have to change directory to the directory where the package is stored. Then run: -> dpkg -i namefile.deb
Remember you need to be superuser to do this.
Example on how to install flashplayer using dpkg from /home/oscc/Desktop/tools folder
(click on the picture to see image clearly)
To get more information about dpkg, type:
-> man dpkg
Tuesday, April 17, 2007
Checking installed package
To check installed packages on you redhat machine, this command can be used:
-> rpm -qa
Using this command, all packages installed will be printed to the screen. To filter the view to print only the package that you desire, use this command:
-> rpm -qa | grep packagename
example: -> rpm -qa | grep -i bind
This command can also be used: -> rpm -qa bind*
-> rpm -qa
Using this command, all packages installed will be printed to the screen. To filter the view to print only the package that you desire, use this command:
-> rpm -qa | grep packagename
example: -> rpm -qa | grep -i bind
This command can also be used: -> rpm -qa bind*
Viewing system's running processes
To view running processes, you can use ps command to list out the running processes.
To see every process on the system:
ps -e
ps -ef
ps -eF
ps -ely
To find the process that you want to see:
-> ps -e | grep nameoftheprocess
example: -> ps -e | grep httpd
The above command will print only the httpd process.
To see every process on the system:
ps -e
ps -ef
ps -eF
ps -ely
To find the process that you want to see:
-> ps -e | grep nameoftheprocess
example: -> ps -e | grep httpd
The above command will print only the httpd process.
Yet another rpm building method
There is also another method of converting tarball to rpm instead of using rpmbuild -bb filename.spec. Using the method mentioned before requires the user to extract the tarball file first before we can use it. If we do not want to extract it first, we can use :
1. type ->rpmbuild -tb filename.tar.bz2
2. after the rpm file has been created; use ->rpm -Uvh filename.rpm to install it
That's all.
1. type ->rpmbuild -tb filename.tar.bz2
2. after the rpm file has been created; use ->rpm -Uvh filename.rpm to install it
That's all.
Wednesday, April 11, 2007
Knowing your linux release
Knowing what operating system and what is the release number are the basic of using any operating system. This information is usually stored in the /etc/ folder in linux. To view it you can type:
For Ubuntu:
cat /etc/lsb-release
For Redhat:
cat /etc/redhat-release
For SuSE:
cat /etc/SuSE-release
This line will be displayed(for Ubuntu):
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=6.10
DISTRIB_CODENAME=edgy
DISTRIB_DESCRIPTION="Ubuntu 6.10"
If you are not sure which file points to this info, you can go to the /etc file, and type:
ls *release
then:
cat lsb-release
For Ubuntu:
cat /etc/lsb-release
For Redhat:
cat /etc/redhat-release
For SuSE:
cat /etc/SuSE-release
This line will be displayed(for Ubuntu):
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=6.10
DISTRIB_CODENAME=edgy
DISTRIB_DESCRIPTION="Ubuntu 6.10"
If you are not sure which file points to this info, you can go to the /etc file, and type:
ls *release
then:
cat lsb-release
Tuesday, April 10, 2007
Building rpm from source file
This is for the Redhat, SuSE and CentOS user out there. Sometimes when you try to search for rpm packages, the only thing that you find is the source file. You create rpm file using this source file:
1. save the source file(usually in tar.gz or tar.bz2 format)
2. extract the files-> tar -xvzf filename.tar.gz or tar -xvjf filename.tar.bz2
3. open the folder of the extracted file and find .spec file
4. type-> rpmbuild -bb filename.spec
5. see the error and continue according to the error until you finish creating rpm files
6. type-> rpm -Uvh filename.rpm to install
Hope this one can help.
1. save the source file(usually in tar.gz or tar.bz2 format)
2. extract the files-> tar -xvzf filename.tar.gz or tar -xvjf filename.tar.bz2
3. open the folder of the extracted file and find .spec file
4. type-> rpmbuild -bb filename.spec
5. see the error and continue according to the error until you finish creating rpm files
6. type-> rpm -Uvh filename.rpm to install
Hope this one can help.