Continuing from the entry Using Powertop to save Battery Power (Part 1)
How do we reinstate the optimised settings for ac-power? I suggest we put the settings that take advantage of AC-Power back into the /etc/acpi/ac.d
# cd /etc/acpi/ac.d # touch 16.optimsation.sh
# chmod 755 16.optimsation.sh
# vim 16-optimisation.sh
#------------------------------------------------------
echo 500 > /proc/sys/vm/dirty_writeback_centisecs
echo 0 > /proc/sys/vm/laptop_mode
hal-disable-polling --device /dev/scd0 --enable-polling
ifconfig eth0 up
iwpriv eth1 set_power 1
#-------------------------------------------------------
For more tips on the settings, do visit the Tip and Tricks session under LessWatts.org
Showing posts with label Howto. Show all posts
Showing posts with label Howto. Show all posts
Friday, August 28, 2009
Wednesday, August 5, 2009
Simple Sudo on CentOS Linux (Part 1)
Sudo is generally considered a more secure way of controlling accessing to system commands. By default CentOS does not implement sudo by default
Note 1: To enable your userid to run any commands on CentOS,
# vim /etc/sudoers
youruserid ALL=(ALL) ALL (at /etc/sudoers)
(Youruserid can run any command)
#sudo -s (will prompt you for password before allowing you to have full admin rights)
Note 2: To enable users to use selected commands (at /etc/sudoers)
%users ALL=/sbin/mount/cdrecorder,/sbin/umount/cdrecorder
Note 3: Using the Cmnd_Alias at sudoers file
(Cmnd Alias helps to group a list of related commands)
youruserid ALL=(ALL) PROCESSES
$ sudo -l (Will list all the commands that youruserid have access to)
Note 4: Using User_Alias
User_Alias ADMIN = user1, user2, user3
ADMIN ALL=ALL
Note 1: To enable your userid to run any commands on CentOS,
# vim /etc/sudoers
youruserid ALL=(ALL) ALL (at /etc/sudoers)
(Youruserid can run any command)
#sudo -s (will prompt you for password before allowing you to have full admin rights)
Note 2: To enable users to use selected commands (at /etc/sudoers)
%users ALL=/sbin/mount/cdrecorder,/sbin/umount/cdrecorder
Note 3: Using the Cmnd_Alias at sudoers file
(Cmnd Alias helps to group a list of related commands)
youruserid ALL=(ALL) PROCESSES
$ sudo -l (Will list all the commands that youruserid have access to)
Note 4: Using User_Alias
User_Alias ADMIN = user1, user2, user3
ADMIN ALL=ALL
Tuesday, August 4, 2009
How to resolve unpingable host down status in Nagios
After installing nagios, you may face some issues
Some hosts are not able to be ping due to firewall. By default, Nagios use the check_host_alive by default at /etc/nagios/objects/template.cfg. check_host_alive uses ping to check whether the host is alive. So your nagios web admin will see a host down status.
To use another commands to replace the check_host_alive with check_http which is more useful as a "check-alive-status", change it at the /etc/nagios/objects/hosts.cfg file. This will override the default at /etc/nagios/objects/templates.cfg
We assume that check_http is already define in the /etc/nagios/objects/command.cfg
define host{
use windows-server
host_name xxxx
alias xxxx web server
check_command check_http
address xxx.com.sg
contact_groups admin
}
Some hosts are not able to be ping due to firewall. By default, Nagios use the check_host_alive by default at /etc/nagios/objects/template.cfg. check_host_alive uses ping to check whether the host is alive. So your nagios web admin will see a host down status.
To use another commands to replace the check_host_alive with check_http which is more useful as a "check-alive-status", change it at the /etc/nagios/objects/hosts.cfg file. This will override the default at /etc/nagios/objects/templates.cfg
We assume that check_http is already define in the /etc/nagios/objects/command.cfg
define host{
use windows-server
host_name xxxx
alias xxxx web server
check_command check_http
address xxx.com.sg
contact_groups admin
}
Monday, August 3, 2009
Notes to remembers when Installing Nagios 3.x on CentOS 5
This is a follow-up of the article of Using Nagios 2.x & 3.x on CentOS 5. If you follow closely you should get it up and running.
Some Issues to note during configuration
Note 1: First install EPEL. You can follow the following Blog Entry Red Hat Enterprise Linux / CentOS Linux Enable EPEL Repository
Note 2: Yum install nagios and all the plugins # yum install nagios, nagios-plugins-all, nagios-nrpe
(You will see not only nagios 3.x installing but also 55+ plugins too)
Note 3: Configure Objects Configuration File
(Make sure you include all the configuration file you are using to be listed)
OBJECT CONFIGURATION FILE(S)
cfg_file=/etc/nagios/contactgroups.cfg
cfg_file=/etc/nagios/contacts.cfg
cfg_file=/etc/nagios/hostgroups.cfg
cfg_file=/etc/nagios/hosts.cfg
cfg_file=/etc/nagios/services.cfg
cfg_file=/etc/nagios/timeperiods.cfg
Note 4: Make hosts.cfg file and fill up the information
define host{
use windows-server
host_name xxxx
alias xxx Web Server
check_command check_http
address www.xxx.com.sg
contact_groups admins
}
Note 5: Make the hostgroups.cfg and fill up the information
define hostgroup{
hostgroup_name windows-servers
alias Windows Servers
members xxxxx
}
Note 6: Define services.cfg to command.cfg and hostgroup.cfg
(Look at http://wiki.centos.org/HowTos/Nagios for more information)
Remember to list the services you wish to implement for nagios. It will interact with command.cfg, hostgroups.cfg to enable the service. Thus command.cfg and hostgroups.cfg must be properly written
define service{
use generic-service
service_description HTTP
notification_options n
check_command check_http
contact_groups admins
hostgroup_name windows-servers,linux-servers
}
Note 7: Test the nagios configuration before updating the services
# cd /etc/nagios/nagios -v nagios.cfg
Some Issues to note during configuration
Note 1: First install EPEL. You can follow the following Blog Entry Red Hat Enterprise Linux / CentOS Linux Enable EPEL Repository
Note 2: Yum install nagios and all the plugins # yum install nagios, nagios-plugins-all, nagios-nrpe
(You will see not only nagios 3.x installing but also 55+ plugins too)
Note 3: Configure Objects Configuration File
(Make sure you include all the configuration file you are using to be listed)
OBJECT CONFIGURATION FILE(S)
cfg_file=/etc/nagios/contactgroups.cfg
cfg_file=/etc/nagios/contacts.cfg
cfg_file=/etc/nagios/hostgroups.cfg
cfg_file=/etc/nagios/hosts.cfg
cfg_file=/etc/nagios/services.cfg
cfg_file=/etc/nagios/timeperiods.cfg
Note 4: Make hosts.cfg file and fill up the information
define host{
use windows-server
host_name xxxx
alias xxx Web Server
check_command check_http
address www.xxx.com.sg
contact_groups admins
}
Note 5: Make the hostgroups.cfg and fill up the information
define hostgroup{
hostgroup_name windows-servers
alias Windows Servers
members xxxxx
}
Note 6: Define services.cfg to command.cfg and hostgroup.cfg
(Look at http://wiki.centos.org/HowTos/Nagios for more information)
Remember to list the services you wish to implement for nagios. It will interact with command.cfg, hostgroups.cfg to enable the service. Thus command.cfg and hostgroups.cfg must be properly written
define service{
use generic-service
service_description HTTP
notification_options n
check_command check_http
contact_groups admins
hostgroup_name windows-servers,linux-servers
}
Note 7: Test the nagios configuration before updating the services
# cd /etc/nagios/nagios -v nagios.cfg
Wednesday, July 29, 2009
Installing Nvdia FX570 drivers on CentOS 5.x
I was trying out an installation on CentOS 5.3 (x86-64) on a workstation which have Nvidia Fx570 card.
The installation of CentOS was very smooth. No hiccups.
The installation of CentOS was very smooth. No hiccups.
- I've downloaded the Nvidia Drivers for Linux from Nvidia Site
- I did a "# yum install gcc" as Nvidia Drivers need gcc to compile
- I run the ./NVIDIA-Linux-x86_64-185.18.29-pkg2.run. But I seems to encounter the "No precompiled kernel interface was found to match your kernel; would you like the installer to attempt to download a kernel interface for your kernel" error
- I "yum install kernel-devel" and the error still appear
- Finally I run the application with the full kernel source path "./NVIDIA-Linux-x86_64-185.18.29-pkg2.run --kernel-source-path=/usr/src/kernels/2.6.18-128.2.1.el5-x86_64/"
Monday, July 27, 2009
Encrypting VNC Traffic with Putty

Assuming you are using a Windows Clients and you wish to have a Secure Shell Connection to Windows, you have to do the followings:
Step 1: Assuming you have launch the VNC Session at the vncserver Server
$ vncserver
New 'xxx.yourserverdomain.com:2 (root)' desktop is xxx.yourserverdomain.com:2 Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/xxx.yourserverdomain.com:2.log
Step 2: Configuration at the SSH Client
- At Putty Client, Enter the IP of hostname of the VNCServer
- On the left-hand pane, click Connection > SSH > Tunnels
- Source Port: 590x (depending on the return port above in step 1)
- Destination Port: xxx.serverhostname.com:590x (depending on the return port in step 1)
- Connect to the Server via SSH
Step 3: Use the VNC Client to connect to local VNC Port. On the TightVNC connection,
$ localhost:2
Sunday, July 26, 2009
SSH over Nautilus GUI file manager
Friday, July 24, 2009
Access Windows shares from Linux
To access Windows Shares from your Linux Box, do the following
Step 1: Create a Directory for mounting
Step 2: Mount the Windows File System
Step 3: To umount
Step 1: Create a Directory for mounting
# mkdir /mnt/Windows_share_on_Linux
Step 2: Mount the Windows File System
# mount -t cifs //server-ip-addr-or-server-domain-name/share -o username=(userid),password=(Password),domain=(AD Domain) /mnt/Windows_share_on_linux
Step 3: To umount
# umount /mnt/Windows_share_on_linux
Using xrandr to change screen resolution and orientation
X RandR is a useful tool to configure display ports, display modes and properties such as orientation, reflection and DPI.
Some simple usage of xrandr
$ xrandr -v (Server reports RandR version 1.3)
$ xrandr -q (query what screens are connected)
$ xrandr -s 1280x800 (screen resolution)
$ xrandr -o inverted (orientation inverted, left, right, normal)
Do note that for xrandr -0, your screen might freeze after the command, you may want to use xrandr --verbose to check the error.
To extend xrandr to utilise and join 2 monitor together, you may want to look at http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 for more information
Some simple usage of xrandr
$ xrandr -v (Server reports RandR version 1.3)
$ xrandr -q (query what screens are connected)
$ xrandr -s 1280x800 (screen resolution)
$ xrandr -o inverted (orientation inverted, left, right, normal)
Do note that for xrandr -0
To extend xrandr to utilise and join 2 monitor together, you may want to look at http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 for more information
Tuesday, July 21, 2009
Using PowerTop to save Battery Power (Part 1)
I was playing with PowerTop. Powertop is a tool to help you identify applications and programs that uses power even when the computer is idle. According to LessWatts.org, Powertop has these four basic goals:
So much for the introduction.
To install powertop, just use
# apt-get install powertop
# yum install powertop
It should be found in most distro.
# powertop
I'm pretty new to the powertop, so I follow the recommendation.
To make some of the recommedendation permanent, I've placed the configuration in the /etc/acpi/battery.d diretory and name is 16-optimisation.sh.
# cd /etc/acpi/battery.d # touch 16.optimsation.sh
# chmod 755 16.optimsation.sh
# vim 16-optimisation.sh
#------------------------------------------------------
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
echo 5 > /proc/sys/vm/laptop_mode
iwpriv eth1 set_power 5
hal-disable-polling --device /dev/scd0
#-------------------------------------------------------
To continue Using PowerTop to save Battery Power (Part 2)
- Show how well your system is using the various hardware power-saving features
- Show you the culprit software components that are preventing optimal usage of your hardware power savings
- Help Linux developers test their application and achieve optimal behavior
- Provide you with tuning suggestions to achieve low power consumption
So much for the introduction.
To install powertop, just use
# apt-get install powertop
# yum install powertop
It should be found in most distro.
# powertop
I'm pretty new to the powertop, so I follow the recommendation.
To make some of the recommedendation permanent, I've placed the configuration in the /etc/acpi/battery.d diretory and name is 16-optimisation.sh.
# cd /etc/acpi/battery.d # touch 16.optimsation.sh
# chmod 755 16.optimsation.sh
# vim 16-optimisation.sh
#------------------------------------------------------
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
echo 5 > /proc/sys/vm/laptop_mode
iwpriv eth1 set_power 5
hal-disable-polling --device /dev/scd0
#-------------------------------------------------------
To continue Using PowerTop to save Battery Power (Part 2)
Wednesday, July 15, 2009
Using rdesktop for access to Windows PC via RDP
One of my most frequently used application is rdesktop. It currently runs on most UNIX and of course with X Windows. With just a command line and including a few essential parameter, you can have access to your Windows PC very efficiently
$ rdesktop -g (Size of the screen) -u (your AD userid) -d (AD Domain) -r disk:desktop=/home/(your linux account)/ -a (colour depth) (PC Name according to Active Directory)
Some notes:
$ rdesktop -g (Size of the screen) -u (your AD userid) -d (AD Domain) -r disk:desktop=/home/(your linux account)/ -a (colour depth) (PC Name according to Active Directory)
Some notes:
- Just a little explanation of the -r parameter. It is to do a mapping between the file system from the linux box to the Remote desktop. This will allow you to transfer file to and from the system
- It seems rdesktop can go to maximum colour depth of 16 only. It is sufficient for a clear windows-like view.
- If you get this error "ERROR: getaddrinfo: Name of Service not known" It is due to the DNS of your PC not being able to resolve properly. To resolve it quickly, you may want to modify the /etc/resolv.conf to include the required DNS.
Sunday, July 12, 2009
Open Source Tools to integrate with MS Active Directory
MS Active Directory is very widely deployed in many industries. To take the pain out of integration with MS Active Directory with your Linux Box, take a look at Likewise Open. Some of the key features are
- Joins non-Windows systems to Active Directory domains in a single step from the command line or from a GUI
- Authenticates users with a single user name and password on both Windows and non-Windows
- Enforces the same password policies for non-Windows users and Windows users
- Caches credentials in case your domain controller goes down
- Provides single sign-on for SSH and Putty
- No schema changes to Active Directory required
Monday, June 22, 2009
Using wget to download entire website
This article is taken from Downloading an Entire Web Site with wget by Linux Journal dated 5th Sept 08. The purpose is for off-line viewing or backup.
Remember that downloading entire website that is not yours is unethical and illegal as well.
# wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
www.mywebsite.org/
Remember that downloading entire website that is not yours is unethical and illegal as well.
# wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
www.mywebsite.org/
The options are:
--recursive: download the entire Web site.
--domains website.org: don't follow links outside website.org.
--no-parent: don't follow links outside the directory tutorials/html/.
--page-requisites: get all the elements that compose the page (images, CSS and so on).
--html-extension: save files with the .html extension.
--convert-links: convert links so that they work locally, off-line.
--restrict-file-names=windows: modify filenames so that they will work in Windows as well.
--no-clobber: don't overwrite any existing files (used in case the download is interrupted and
resumed).
Monday, May 11, 2009
Auto SSH Login without Password
The SSH daemon validates SSH client access by Linux system verification via /etc/passwd, or by public/private key cryptography approach.
By using the public/private cryptography approach, we can do a SSH without password.
In my write-up it is for root-to-root connection. You can use it for user connections
Steps 1: At the Host Machine
Step 2: At the Remote Machine, test it out
By using the public/private cryptography approach, we can do a SSH without password.
In my write-up it is for root-to-root connection. You can use it for user connections
Steps 1: At the Host Machine
- Logon to the root home directory.
- Make sure the hidden .ssh directory has the permission 700. If not execute the command
chmod 700 .ssh
- Change Directory to .ssh directory by executing the command
cd .ssh
- Generate the public-private keys using the ssh-keygen command.
# ssh-keygen -t rsa
- The resulting file id_rsa and id_rsa.pub rsa type public key
# ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host(ssh-copy-id appends the keys to the remote-host’s .ssh/authorized_key)

Step 2: At the Remote Machine, test it out
# ssh remote-host (It should automatically login)
Thursday, April 16, 2009
How to setup new Harddisk on LINUX
Here's a quick tutorial on how to setup new harddisk on linux taken from "Adding a Hard Disk in LINUX" by Erik Rodriguez
Step 1: First check after the Harddisk is installed, can it found under /dev/sdb or /dev/sdc. If yes. This means that the new HDD device has been detected
Step 2: Set up the Partition
# fdisk /dev/sdb
Step 2a: Go to Fdisk menu
Step 2c: Create New Partition
Step 2d: Check the the print Partition Specification which we have entered.
Step 2e: Finalise the Partition
# mkfs -t ext3 /dev/sdb1
# mount /dev/sdb1 /home1 (assuming /home1 has been created)
Step 1: First check after the Harddisk is installed, can it found under /dev/sdb or /dev/sdc. If yes. This means that the new HDD device has been detected
Step 2: Set up the Partition
# fdisk /dev/sdb
Step 2a: Go to Fdisk menu
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help):
Step 2b: Print Existing PartitionCommand (m for help): p
Disk /dev/sdb: 50.0 GB, 50019202560 bytes
255 heads, 63 sectors/track, 6081 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help):
Step 2c: Create New Partition
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6081, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081
Command (m for help)Step 2d: Check the the print Partition Specification which we have entered.
Command (m for help): p
Disk /dev/sdb: 50.0 GB, 50019202560 bytes
255 heads, 63 sectors/track, 6081 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 6081 48845601 83 Linux
Command (m for help): Step 2e: Finalise the Partition
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Step 3: Format the Disk# mkfs -t ext3 /dev/sdb1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6111232 inodes, 12211400 blocks
610570 blocks (5.00%) reserved for the super user
First data block=0
373 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Step 4: Mount the File System# mount /dev/sdb1 /home1 (assuming /home1 has been created)
Tuesday, April 14, 2009
Agedu - Combing Files with Agedu
Agedu is a toolkits that help system administrators or users to help identify old files, and hence to delete them. Although like most administrator, we often use
# du -s. But du only tells you what is big and not what's too big
Step 1: To begin with, start getting the source packager from Agedu
# tar -zxvf agedu-rversion.tar.gz
#./configure
#make
#make install
Step 2: Scan the directory you want agedu to catalogue
# ./agedu --scan /directory
#./agedu --web
(A URL: 127.164.xxx.xxx:xxxxx). You can copy and paste the links on the LINUX Web Browser and you have it.
For more information, you can also see Agedu Man Page
# du -s. But du only tells you what is big and not what's too big
Step 1: To begin with, start getting the source packager from Agedu
# tar -zxvf agedu-rversion.tar.gz
#./configure
#make
#make install
Step 2: Scan the directory you want agedu to catalogue
# ./agedu --scan /directory
#./agedu --web
(A URL: 127.164.xxx.xxx:xxxxx). You can copy and paste the links on the LINUX Web Browser and you have it.
For more information, you can also see Agedu Man Page
Subscribe to:
Posts (Atom)

