Tuesday, May 24, 2011

Reducing Swap on an LVM2 Logical Volume


To reduce an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend): Replace /dev/VolGroup00/LogVol01 with your HD partition.
  1. Disable swapping for the associated logical volume:
    # swapoff -v /dev/VolGroup00/LogVol01
  2. Reduce the LVM2 logical volume by 512 MB:
    # lvm lvreduce /dev/VolGroup00/LogVol01 -L -512M
  3. Format the new swap space:
    # mkswap /dev/VolGroup00/LogVol01
  4. Enable the extended logical volume:
    # swapon -va
  5. Test that the logical volume has been reduced properly:
    # cat /proc/swaps or # free
     
     
     
    !Enjoy
    Kuldeep Sharma 

Tuesday, May 17, 2011

15 Examples To Master Linux Command Line History

When you are using Linux command line frequently, using the history effectively can be a major productivity boost. In fact, once you have mastered the 15 examples that I’ve provided here, you’ll find using command line more enjoyable and fun.

1. Display timestamp using HISTTIMEFORMAT

Typically when you type history from command line, it displays the command# and the command. For auditing purpose, it may be beneficial to display the timepstamp along with the command as shown below.
# export HISTTIMEFORMAT='%F %T '
# history | more
1  2008-08-05 19:02:39 service network restart
2  2008-08-05 19:02:39 exit
3  2008-08-05 19:02:39 id
4  2008-08-05 19:02:39 cat /etc/redhat-release

2. Search the history using Control+R

I strongly believe, this may be your most frequently used feature of history. When you’ve already executed a very long command, you can simply search history using a keyword and re-execute the same command without having to type it fully. Press Control+R and type the keyword. In the following example, I searched for red, which displayed the previous command “cat /etc/redhat-release” in the history that contained the word red.

# [Press Ctrl+R from the command prompt,
which will display the reverse-i-search prompt]
(reverse-i-search)`red': cat /etc/redhat-release
[Note: Press enter when you see your command,
which will execute the command from the history]
# cat /etc/redhat-release
CentOS release 5.4 (Final)

Sometimes you want to edit a command from history before executing it.
For e.g. you can search for httpd, which will display service httpd stop 
from the command history, select this command and change the stop to start 
and re-execute it again as shown below.
 
# [Press Ctrl+R from the command prompt,
which will display the reverse-i-search prompt]
(reverse-i-search)`httpd': service httpd stop
[Note: Press either left arrow or right arrow key when you see your
command, which will display the command for you to edit, before executing it]
# service httpd start 
 

3. Repeat previous command quickly using 4 different methods

Sometime you may end up repeating the previous commands for various reasons. Following are the 4 different ways to repeat the last executed command.
  1. Use the up arrow to view the previous command and press enter to execute it.
  2. Type !! and press enter from the command line
  3. Type !-1 and press enter from the command line.
  4. Press Control+P will display the previous command, press enter to execute it

4. Execute a specific command from history

In the following example, If you want to repeat the command #4, you can do !4 as shown below.
 
# history | more
1  service network restart
2  exit
3  id
4  cat /etc/redhat-release

# !4
cat /etc/redhat-release
Fedora release 9 (Sulphur)
 

5. Execute previous command that starts with a specific word

Type ! followed by the starting few letters of the command that you would like to re-execute. In the following example, typing !ps and enter, executed the previous command starting with ps, which is ‘ps aux | grep firefox’.

# !ps
ps -ef |grep -i firefox
root      7851  8897  0 14:41 pts/4    00:00:00 grep -i firefox
root     18828     1  2 11:34 ?        00:03:52 /opt/firefox/firefox-bin
root     18870 18828  0 11:34 ?        00:01:51 /opt/firefox/plugin-container /usr/lib/flash-plugin/libflashplayer.so
18828 plugin true

6. Control the total number of lines in the history using HISTSIZE

Append the following two lines to the .bash_profile and relogin to the bash shell again to see the change. In this example, only 450 command will be stored in the bash history.
 
# vi ~/.bash_profile
HISTSIZE=450
HISTFILESIZE=450

7. Change the history file name using HISTFILE

By default, history is stored in ~/.bash_history file. Add the following line to the .bash_profile and relogin to the bash shell, to store the history command in .commandline_warrior file instead of .bash_history file. I’m yet to figure out a practical use for this. I can see this getting used when you want to track commands executed from different terminals using different history file name.

# vi ~/.bash_profile
HISTFILE=/root/.commandline_warrior
 
If you have a good reason to change the name of the history file, please
share it with me, as I’m interested in finding out how you are using this feature. 

8. Eliminate the continuous repeated entry from history using HISTCONTROL

In the following example pwd was typed three times, when you do history, you can see all the 3 continuous occurrences of it. To eliminate duplicates, set HISTCONTROL to ignoredups as shown below.

# pwd
# pwd
# pwd
# history | tail -4
44  pwd
45  pwd
46  pwd [Note that there are three pwd commands in history, after
executing pwd 3 times as shown above]
47  history | tail -4

# export HISTCONTROL=ignoredups
# pwd
# pwd
# pwd
# history | tail -3
56  export HISTCONTROL=ignoredups
57  pwd [Note that there is only one pwd command in the history, even after
executing pwd 3 times as shown above]
58  history | tail -4


9. Erase duplicates across the whole history using HISTCONTROL

The ignoredups shown above removes duplicates only if they are consecutive commands. To eliminate duplicates across the whole history, set the HISTCONTROL to erasedups as shown below.

# export HISTCONTROL=erasedups
# pwd
# service httpd stop
# history | tail -3
38  pwd
39  service httpd stop
40  history | tail -3

# ls -ltr
# service httpd stop
# history | tail -6
35  export HISTCONTROL=erasedups
36  pwd
37  history | tail -3
38  ls -ltr
39  service httpd stop
[Note that the previous service httpd stop after pwd got erased]
40  history | tail -6

10. Force history not to remember a particular command using HISTCONTROL

When you execute a command, you can instruct history to ignore the command by setting HISTCONTROL to ignorespace AND typing a space in front of the command as shown below. I can see lot of junior sysadmins getting excited about this, as they can hide a command from the history. It is good to understand how ignorespace works. But, as a best practice, don’t hide purposefully anything from history.

# export HISTCONTROL=ignorespace
# ls -ltr
# pwd
#  service httpd stop [Note that there is a space at the beginning of service,
to ignore this command from history]
# history | tail -3
67  ls -ltr
68  pwd
69  history | tail -3

11. Clear all the previous history using option -c

Sometime you may want to clear all the previous history, but want to keep the history moving forward.
 
# history -c

12. Subtitute words from history commands

When you are searching through history, you may want to execute a different command but use the same parameter from the command that you’ve just searched.
In the example below, the !!:$ next to the vi command gets the argument from the previous command to the current command.

# ls anaconda-ks.cfg
anaconda-ks.cfg
# vi !!:$
vi anaconda-ks.cfg

In the example below, the !^ next to the vi command gets the first argument from the previous command (i.e cp command) to the current command (i.e vi command).
 
# cp anaconda-ks.cfg anaconda-ks.cfg.bak
anaconda-ks.cfg
# vi  !^
vi anaconda-ks.cfg

13. Substitute a specific argument for a specific command.

In the example below, !cp:2 searches for the previous command in history that starts with cp and takes the second argument of cp and substitutes it for the ls -l command as shown below.
# cp ~/longname.txt /really/a/very/long/path/long-filename.txt
# ls -l !cp:2
ls -l /really/a/very/long/path/long-filename.txt
 
In the example below, !cp:$ searches for the previous command in history that 
starts with cp and takes the last argument (in this case, which is also the second 
argument as shown above) of cp and substitutes it for the ls -l command 
as shown below. 
# ls -l !cp:$
ls -l /really/a/very/long/path/long-filename.txt
 

14. Disable the usage of history using HISTSIZE

If you want to disable history all together and don’t want bash shell to remember the commands you’ve typed, set the HISTSIZE to 0 as shown below.
# export HISTSIZE=0
# history
# [Note that history did not display anything]
 

15. Ignore specific commands from the history using HISTIGNORE

Sometimes you may not want to clutter your history with basic commands such as pwd and ls. Use HISTIGNORE to specify all the commands that you want to ignore from the history. Please note that adding ls to the HISTIGNORE ignores only ls and not ls -l. So, you have to provide the exact command that you would like to ignore from the history.
 
# export HISTIGNORE="pwd:ls:ls -ltr:"
# pwd
# ls
# ls -ltr
# service httpd stop
# history | tail -3
79  export HISTIGNORE="pwd:ls:ls -ltr:"
80  service httpd stop
81  history
[Note that history did not record pwd, ls and ls -ltr]

 !Enjoyy..........
 
Kuldeep Sharma 

 

 

 

Monday, May 16, 2011

10 iozone Examples for Disk I/O Performance Measurement on Linux

Along with Monitoring different aspects on Linux server measuring IO subsystem performance is also going to be very important.

       If someone is complaining that a database (or any application) running on one server (with certain filesystem, or RAID configuration) is running faster than the same database or application running on another server, you might want to make sure that the performance at the disk level is same on both the server. You can use iozone for this situation.
 
         If you are running your database (or any application) on certain SAN or NAS environment, and would like to migrate it to different SAN or NAS environment, you should perform filesystem benchmakring on both the systems and compare it. You can use iozone for this situation.

      If you know how to use iozone, you can pretty much use it for various filesystem benchmarking purpose.

Download and Install IOZone

Iozone is an open source file system benchmarking utility.

Follow the steps below to download and install iozone on your system.

wget http://www.iozone.org/src/current/iozone3_394.tar

tar xvf iozone3_394.tar

cd iozone3_394/src/current

make

make linux


What does IOzone utility measure?

IOzone performs the following 13 types of test. If you are executing iozone test on a database server, you can focus on the 1st 6 tests, as they directly impact the database performance.
  1. Read – Indicates the performance of reading a file that already exists in the filesystem.
  2. Write – Indicates the performance of writing a new file to the filesystem.
  3. Re-read – After reading a file, this indicates the performance of reading a file again.
  4. Re-write – Indicates the performance of writing to an existing file.
  5. Random Read – Indicates the performance of reading a file by reading random information from the file. i.e this is not a sequential read.
  6. Random Write – Indicates the performance of writing to a file in various random locations. i.e this is not a sequential write.
  7. Backward Read
  8. Record Re-Write
  9. Stride Read
  10. Fread
  11. Fwrite
  12. Freread
  13. Frewrite

10 IOZone Examples

1. Run all IOZone tests using default values

-a option stands for automatic mode. This creates temporary test files from sizes 64k to 512MB for performance testing. This mode also uses 4k to 16M of record sizes for read and write (more on this later) testing.

-a option will also execute all the 13 types of tests.

$ iozone -a

The first setion of the iozone output contains the header information, which displays information about the iozone utility, and all the iozone options that are used to generate this report, as shown below.
Iozone: Performance Test of File I/O
Version $Revision: 3.394 $
Compiled for 32 bit mode.
Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
Al Slater, Scott Rhine, Mike Wisner, Ken Goss

Run began: Sat Apr 23 12:25:34 2011

Auto Mode
Command line used: ./iozone -a
Output is in Kbytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.

The second section of the output contains the output values (in per second) of various tests.
1st column KB: Indicates the file size that was used for the testing.
2nd column reclen: Indicates the record length that was used for the testing.
3rd column until the last column: Indicates the various tests that are performed and its output values in per second.
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
64 4 495678 152376 1824993 2065601 2204215 875739 582008 971435 667351 383106 363588 566583 889465
64 8 507650 528611 1051124 1563289 2071399 1084570 1332702 1143842 2138827 1066172 1141145 1303442 2004783
64 16 587283 1526887 2560897 2778775 2366545 1122734 1254016 593214 1776132 463919 1783085 3214531 3057782
64 32 552203 402223 1121909 1388380 1162129 415722 666360 1163351 1637488 1876728 1685359 673798 2466145
64 64 551580 1122912 2895401 4911206 2782966 1734491 1825933 1206983 2901728 1207235 1781889 2133506 2780559
128 4 587259 1525366 1801559 3366950 1600898 1391307 1348096 547193 666360 458907 1486461 1831301 1998737
128 8 292218 1175381 1966197 3451829 2165599 1601619 1232122 1291619 3273329 1827104 1162858 1663987 1937151
128 16 650008 510099 4120180 4003449 2508627 1727493 1560181 1307583 2203579 1229980 603804 1911004 2669183
128 32 703200 1802599 2842966 2974289 2777020 1331977 3279734 1347551 1152291 684197 722704 907518 2466350
128 64 848280 1294308 2288112 1377038 1345725 659686 1997031 1439349 2903100 1267322 1968355 2560063 1506623
128 128 902120 551579 1305206 4727881 3046261 1405509 1802090 1085124 3649539 2066688 1423514 2609286 3039423
...

2. Save the output to a spreadsheet using iozone -b

To save the iozone output to a spreadsheet, use the -b option as shown below. -b stands for binary, and it instructs iozone to write the test output in binary format to a spreadsheet.
$ iozone -a -b output.xls

Note: The -b option can be used with any of the examples mentioned below.

From the data that is saved in the spreadsheet, you can use the create some pretty graphs using the graph functionality of the spreadsheet tool. The following is a sample graph that was created from iozone output.


3. Run only a specific type of test using iozone -i

If you are interested in running only a specific type of test, use the -i option.

Syntax:
iozone -i [test-type]

The test-type is a numeric value. The following are the various available test types and its numeric value.
0=write/rewrite
1=read/re-read
2=random-read/write
3=Read-backwards
4=Re-write-record
5=stride-read
6=fwrite/re-fwrite
7=fread/Re-fread,
8=random mix
9=pwrite/Re-pwrite
10=pread/Re-pread
11=pwritev/Re-pwritev
12=preadv/Re-preadv

The following example will run only the write tests (i.e both write and rewrite). As you see from the output the other columns are empty.

$ iozone -a -i 0

random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
64 4 353666 680969
64 8 477269 744768
64 16 429574 326442
64 32 557029 942148
64 64 680844 633214
128 4 187138 524591
Combine multiple iozone test types

You can also combine multiple test types by specifying multiple -i in the command line.

For example, the following example will test both read and write test types.

$ iozone -a -i 0 -i 1

random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
64 4 372112 407456 1520085 889086
64 8 385574 743960 3364024 2553333
64 16 496011 397459 3748273 1330586
64 32 499600 876631 2459558 4270078

4. Specify the file size using iozone -s

By default, iozone will automatically create temporary files of size from 64k to 512M, to perform various testing.

The 1st column in the iozone output (with the column header KB) indicates the file size. As you saw from the previous output, it starts with 64KB file, and will keep increasing until 512M (by doubling the file size every time).

Instead of running the test for all the file sizes, you can specific the file size using option -s.

The following example will perform write test only for file size 1MB (i.e 1024KB).

$ iozone -a -i 0 -s 1024
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
1024 4 469710 785882
1024 8 593621 1055581
1024 16 745286 1110539
1024 32 610585 1030184
1024 64 929225 1590130
1024 128 1009859 1672930
1024 256 1042711 2039603
1024 512 941942 1931895
1024 1024 1039504 706167

5. Specify the record size for testing using iozone -r

When you run a test, for a specific file size, it tests with different record sizes ranging from 4k to 16M.

If you like to do I/O performance testing of an I/O subsystem that hosts oracle database, you might want to set the record size in the iozone to the same value of the DB block size. The database reads and writes based on the DB block size.

reclen stands for Record Length. In the previous example, the 2nd column (with the column header “reclen”) indicates the record length that should be used for testing IOzone. In the previous example outout, for the file size of 1024KB, the iozone testing used various record sizes ranging from 4k to 16M to perform the write test.

Instead of using all these default record length sizes, you can also specify the record size you would like to test.

The example below will run write test only for record length of 32k. In the output, the 2nd column will now only display 32.
$ iozone -a -i 0 -r 32
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
64 32 566551 820553
128 32 574098 1000000
256 32 826044 948043
512 32 801282 1560624
1024 32 859116 528901
2048 32 881206 1423096
6. Combine file size with record size

You can also using both -s and -r option to specific a exact temporary file size, and exact record length that needs to be tested.

For example, the following will run the write test using a 2M file with a record length of 1M

$ iozone -a -i 0 -s 2048 -r 1024
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
2048 1024 1065570 1871841

7. Throughput test using iozone -t

To execute the iozone in throughput mode, use -t option. You should also specify the number of threads that needs to be active during this test.

The following example will execute the iozone throughput test for writes using 2 threads. Please note that you cannot combine -a option with -t option.

$ iozone -i 0 -t 2

Children see throughput for 2 initial writers 1= 433194.53 KB/sec
Parent sees throughput for 2 initial writers = 7372.12 KB/sec
Min throughput per process = 0.00 KB/sec
Max throughput per process = 433194.53 KB/sec
Avg throughput per process = 216597.27 KB/sec
Min xfer = 0.00 KB

Children see throughput for 2 rewriters = 459924.70 KB/sec
Parent sees throughput for 2 rewriters = 13049.40 KB/sec
Min throughput per process = 225610.86 KB/sec
Max throughput per process = 234313.84 KB/sec
Avg throughput per process = 229962.35 KB/sec
Min xfer = 488.00 KB

To perform throughput for all the test types, remove the “-i 0″ from the above example, as shown below.

$ iozone -t 2

8. Include CPU Utilization using iozone -+u

While performing the iozone testing, you can also instruct iozone to collect the CPU utilization using -+u option.

The -+ in front of the option might look little strange. But, you have to give the whole -+u (not just -u, or +u) for this to work properly.

The following example will execute all the test, and include the CPU utilization report as part of the excel spreadsheet output it generates.

$ iozone -a -+u -b output.xls

Note: This will display separate CPU utilization for each and every test it performs.

9. Increase the file size using iozone -g

This is important. If your system has more than 512MB of RAM, you should increase the temporary file size that iozone uses for testing. If you don’t, you might not get accurate results, as the system buffer cache will play a role in it.

For accurate disk performance, it is recommended to have the temporary file size 3 times the size of your system buffer cache.

The following example will run the iozone by increasing the maximum file size to 2GB, and run the automatic iozone testing for write tests.

$ iozone -a -g 2G -i 0
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
64 4 556674 1230677
64 8 278340 441320
64 16 608990 1454053
64 32 504125 1085411
64 64 571418 1279331
128 4 526602 961764
128 8 714730 518219
...
10. Test multiple mount points together using iozone -F

By combining several iozone options, you can perform disk I/O testing on multiple mount points as shown below.

If you have 2 mounts points, you can start 2 different iozone threads to create temporary files on both these mount points for testing as shown below.

$ iozone -l 2 -u 2 -r 16k -s 512M -F /u01/tmp1 /u02/tmp2
-l indicates the minimum number of iozone processes that should be started
-u indicates the maximum number of iozone processes that should be started
-F should contain multiple values. i.e If we specify 2 in both -l and -u, we should have two filenames here. Please note that only the mount points need to exists. The file specified in the -F option doesn’t need to exists, as iozone will create this temporary file during the testing. In the above example, the mount points are /u01, and /u02. The file tmp1 and tmp2 will be automatically created by iozone for testing purpose.


!Enjoy

Linux File Systems: Ext2 vs Ext3 vs Ext4

Linux File Systems: Ext2 vs Ext3 vs Ext4


ext2, ext3 and ext4 are all filesystems created for Linux. This article explains the following:
  • High level difference between these filesystems.
  • How to create these filesystems.
  • How to convert from one filesystem type to another.

Ext2

  • Ext2 stands for second extended file system.
  • It was introduced in 1993. Developed by Rémy Card.
  • This was developed to overcome the limitation of the original ext file system.
  • Ext2 does not have journaling feature.
  • On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB
  • Overall ext2 file system size can be from 2 TB to 32 TB

Ext3

  • Ext3 stands for third extended file system.
  • It was introduced in 2001. Developed by Stephen Tweedie.
  • Starting from Linux Kernel 2.4.15 ext3 was available.
  • The main benefit of ext3 is that it allows journaling.
  • Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB
  • Overall ext3 file system size can be from 2 TB to 32 TB
  • There are three types of journaling available in ext3 file system.
    • Journal – Metadata and content are saved in the journal.
    • Ordered – Only metadata is saved in the journal. Metadata are journaled only after writing the content to disk. This is the default.
    • Writeback – Only metadata is saved in the journal. Metadata might be journaled either before or after the content is written to the disk.
  • You can convert a ext2 file system to ext3 file system directly (without backup/restore).

Ext4

  • Ext4 stands for fourth extended file system.
  • It was introduced in 2008.
  • Starting from Linux Kernel 2.6.19 ext4 was available.
  • Supports huge individual file size and overall file system size.
  • Maximum individual file size can be from 16 GB to 16 TB
  • Overall maximum ext3 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte).
  • Directory can contain a maximum of 64,000 subdirectories (as opposed to 32,000 in ext3)
  • You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it).
  • Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc. All you need to know is that these new features have improved the performance and reliability of the filesystem when compared to ext3.
  • In ext4, you also have the option of turning the journaling feature “off”.

Warning: Don’t execute any of the commands given below, if you don’t know what you are doing. You will lose your data!

Creating an ext2, or ext3, or ext4 filesystem

Once you’ve partitioned your hard disk using fdisk command, use mke2fs to create either ext2, ext3, or ext4 file system.
Create an ext2 file system:
mke2fs /dev/sda1
Create an ext3 file system:
mkfs.ext3 /dev/sda1

(or)

mke2fs –j /dev/sda1
Create an ext4 file system:
mkfs.ext4 /dev/sda1

(or)

mke2fs -t ext4 /dev/sda1

Converting ext2 to ext3

For example, if you are upgrading /dev/sda2 that is mounted as /home, from ext2 to ext3, do the following.
umount /dev/sda2

tune2fs -j /dev/sda2

mount /dev/sda2 /home
Note: You really don’t need to umount and mount it, as ext2 to ext3 conversion can happen on a live file system. But, I feel better doing the conversion offline.

Converting ext3 to ext4

If you are upgrading /dev/sda2 that is mounted as /home, from ext3 to ext4, do the following.
umount /dev/sda2

tune2fs -O extents,uninit_bg,dir_index /dev/sda2

e2fsck -pf /dev/sda2

mount /dev/sda2 /home
 
Again, try all of the above commands only on a test system, where you can afford to lose all your data.


!Enjoy

Thursday, May 12, 2011

How to Increase Screen Size or Resolution in Virtualbox for Ubuntu or Linux



When a new Virtual Machine, or Virtual PC, is setup in Virtualbox for Ubuntu, or another Linux flavor, the screen size and screen resolution may be fixed smaller than your maximum resolution setting. This problem can be fixed by installing Guest Additions.
Guest Additions comes with Virtualbox, but is installed after you setup your Virtual Machine, or Guest OS, to add features such as increased screen size or screen resolution. On the test PC for this example the maximum resolution is 1280 x 1024. After loading Ubuntu under Virtualbox bring up the Display Preference by going into System -> Preferences -> Display. The maximum resolution option listed is 800 x 600.
Installing Guest Additions from Gnome Desktop

To get a bigger screen resolution we will need to install Guest Additions. On the Virtualbox File Menu click on Devices -> Install Guest Additions.
 
You should now see a vboxadditions_x file now located on your Ubuntu desktop.
 
To open the vboxadditions file either double click on the file, or right-click and then click Open.
 
Now double click the autorun.sh file. The vboxadditions file contains installation choices for a few different Linux versions including both 32 bit and 64 bit versions. By using the autorun.sh file you allow the script to automatically detect, and install the right software for your OS.



Now Click on Run
The autorun.sh will open a Shell window and begin installing the files.






 Once the autorun.sh file has completed installing the Guest Additions software all you have to do is hit Enter to close the Window.

 
Now reboot Ubuntu for the new files to load properly.
 
After you return to the Ubuntu desktop click System -> Preferences -> Display.


Under Display Preferences you will see the resolution is at 1152 x 864, which is still not the maximum resolution.
 
On the Virtualbox File Menu click on Machine -> Fullscreen Mode.




Once in Fullscreen Mode go to System -> Preferences -> Display again, and you will now see the maximum screen resolution is 1280 x 1024.
 



!Enjoy Virtual Box in Wide Screen :)
Kuldeep Sharma







Wednesday, May 11, 2011

Dovecot POP3/IMAP Server Setup Howto for RHEL/CentOS 5

 Dovecot:       Dovecot is an open source IMAP and POP3 email server for Linux/UNIX-like systems, written with security primarily in mind. Dovecot is an excellent choice for both small and large installations. It's fast, simple to set up, requires no special administration and it uses very little memory.

 

Install Dovecot:  Installing and setting up Dovecot in Red Hat Enterprise Linux 5 or CentOS 5 is easy. All we have to do is to enable the services we would like to provide and we are good to go.

 Make the use of yum or download dovecot and install it.

Here I have  installed it using yum. i.e use 

#yum install dovecot

Configure Postfix:

Go to the main configuration file dovecot.conf in /etc/dovecot.conf .We need to change a few key items. 

Find the following keys and change its values as follows
protocols = pop3 pop3s imap imaps
mail_location = maildir:~/Maildir/
pop3_uidl_format = %08Xu%08Xv
imap_client_workarounds = delay-newmail outlook-idle netscape-eoh
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh 
 
For 64-bit users: Add the line login_process_size = 64 
in the file /etc/dovecot.conf. 

Lines starting with # are comments. The last two line enables workarounds for various client bugs. Save the file after completing your changes.

Test Dovecot : Sample dovecot session. Replace ks and password with any valid user name and password.

 [root@fedora ~]# telnet localhost pop3
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user ks
+OK
pass ********
+OK Logged in.
list
+OK 1 messages:
1 472
.
retr 1
+OK 472 octets
Return-Path:
X-Original-To: ks
Delivered-To: ks@fedora.localdomain
Received: from list (localhost [IPv6:::1])
        by fedora.localdomain (Postfix) with ESMTP id 76BB020509
        for ; Wed, 11 May 2011 15:39:37 +0530 (IST)
Message-Id: <20110511100949.76BB020509@fedora.localdomain>
Date: Wed, 11 May 2011 15:39:37 +0530 (IST)
From: fedora@fedora.localdomain
To: undisclosed-recipients:;

Hi This is the Mail from User *** fedora ** to ks
.
list
+OK 1 messages:
1 472
.
quit
+OK Logging out.
Connection closed by foreign host.
[root@fedora ~]#

NoteIf you encounter any problems, check the log file at /var/log/maillog.

Feel free to comment

!Enjoy
Kuldeep Sharma


 

 

 

 

Postfix MTA Configuration

Firstly Lets Introduce with Term POSTFIX:

Postfix:  In computing, Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail. It is intended as a fast, easier-to-administer, and secure alternative to the widely-used Sendmail MTA.

Install Postfix:

Make the use of yum or download postfix and install it.

Here I have  installed it using yum. i.e use 

#yum install postfix

 

Configure Postfix:

Go to the main configuration file main.cf in /etc/postfix/ directoy We need to make it listen to network request, accept mails bound to our domain and use maildir which is a better mailbox format than mbox the default. 

Find the following keys and change its values as follows.

inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/

 In main.cf, lines starting with # are comments. Save the file after completing your changes.Make sure that all mail_spool_directory lines are commented out. Otherwise, it will override the setting in the home_mailbox line above.

Now Restart the postfix service.

Sample postfix session. Replace fedora with any valid user account. The dot after the line test is a command that should be typed in.

[root@fedora ~]# telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 fedora.localdomain ESMTP Postfix
ehlo list
250-fedora.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:fedora
250 2.1.0 Ok
rcpt to:ks
250 2.1.5 Ok
data
354 End data with .
Hi This is the Mail from User *** fedora ** to ks
.
250 2.0.0 Ok: queued as 76BB020509
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@fedora ~]#
 

To check if the mail indeed exists

[root@fedora ~]# cd /home/ks/Maildir/new/
[root@fedora new]# ls
1305108617.Vfd00I2050eM84839.fedora
[root@fedora new]# vi 1305108617.Vfd00I2050eM84839.fedora
[root@fedora new]# cat 1305108617.Vfd00I2050eM84839.fedora
Return-Path:
X-Original-To: ks
Delivered-To: ks@fedora.localdomain
Received: from list (localhost [IPv6:::1])
        by fedora.localdomain (Postfix) with ESMTP id 76BB020509
        for ; Wed, 11 May 2011 15:39:37 +0530 (IST)
Message-Id: <20110511100949.76BB020509@fedora.localdomain>
Date: Wed, 11 May 2011 15:39:37 +0530 (IST)
From: fedora@fedora.localdomain
To: undisclosed-recipients:;

Hi This is the Mail from User *** fedora ** to ks
[root@fedora new]#

NoteIf you encounter any problems, check the log file at /var/log/maillog.


!Enjoy
Kuldeep Sharma

 

 

Sunday, May 8, 2011

DNS Server Interview Questions And Answers for linux admin

DNS Server Interview Questions And Answers for linux admin


Q: - which are the important configuration files for DNS server ?
BIND uses /etc/named.conf as its main configuration file, the /etc/rndc.conf file as the
configuration file for name server control utility rndc, and the /var/named/ directory for zone files and the like.

Q: - What is BIND ?

BIND stands for Berkeley Internet Name Domain which is the most commonly used Domain Name System (DNS) server on the Internet.

Q: - On which version of bind u have worked ?

BIND 9

Q: - What is the role of DNS ?

A DNS server, or name server, is used to resolve an IP address to a hostname or vice versa.

Q: - On which port DNS server works ?

DNS servers use port 53 by default. Incoming and outgoing packets should be allowed on
port 53. Also allow connections on port 921 if you configure a lightweight resolver server.
The DNS control utility, rndc, connects to the DNS server with TCP port 953 by default. If
you are running rndc on the name server, connections on this TCP port from localhost
should be allowed. If you are running rndc on additional systems, allow connections to
port 953 (or whatever port you have chosen to configure) from these additional systems.
Q: - What is round robin DNS?

Round robin DNS is usually used for balancing the load of geographically distributed Web servers. For example, a company has one domain name and three identical home pages residing on three servers with three different IP addresses. When one user accesses the home page it will be sent to the first IP address. The second user who accesses the home page will be sent to the next IP address, and the third user will be sent to the third IP address. In each case, once the IP address is given out, it goes to the end of the list. The fourth user, therefore, will be sent to the first IP address, and so forth. 
Q: - What is Name Server?

A name server keeps information for the translation of domain names to IP addresses   and IP addresses to domain names. The name server is a program that performs the translation at the request of a resolver or another name server.
Q: - What is Primary name server or primary master server?

Primary name server/primary master is the main data source for the zone. It is the authoritative server for the zone. This server acquires data about its zone from databases saved on a local disk. The primary server must be published as an authoritative name server for the domain in the SOA resource record, while the primary master server does not need to be published.
Q: - What is Secondary name server/slave name server?

Secondary name server/slave name server acquires data about the zone by copying the data from the primary name server (respectively from the master server) at regular time intervals. It makes no sense to edit these databases on the secondary name servers, although they are saved on the local server disk because they will be rewritten during further copying.
Q: - what is Root name server?

Root name server is an authoritative name server for the root domain (for the dot). Each root name server is a primary server, which differentiates it from other name servers.
Q: - what is Stealth name server?

Stealth name server is a secret server. This type of name server is not published anywhere. It is only known to the servers that have its IP address statically listed in their configuration. It is an authoritative server. It acquires the data for the zone with the help of a zone transfer. It can be the main server for the zone. Stealth servers can be used as a local backup if the local servers are unavailable.

Q: - What do you mean by "Resource Records"?

Information on domain names and their IP addresses, as well as all the other information distributed via DNS is stored in the memory of name servers as Resource Records (RR). 

Q: - Explain "TTL"? 

Time to live. A 32-bit number indicating the time the particular RR can be kept valid in a server cache. When this time expires, the record has to be considered invalid. The value 0 keeps nonauthoritative servers from saving the RR to their cache memory.
Q: - Tell me 5 Types of DNS records?

A, NS, CNAME, SOA, PTR, MX.
Q:- explain "SOA Record"?

The Start of Authority (SOA) record determines the name server that is an authoritative source of information for the particular domain. There is always only one SOA record in the file, and it is placed at the beginning of the file of authoritative resource records. 
Q: - what is "A Record"

A (Address) records assign IP addresses to domain names of computers. The IP address cannot have a dot at the end.
Q: - Explain "CNAME Record"?

Synonyms to domain names can be created using CNAME records. This is often referred to as 'creating aliases for computer names'.
Q: - What are "HINFO and TXT Records"?

HINFO and TXT records are for information only. An HINFO record has two items in its data part. The first item is information about hardware, and the second one is information about software. A TXT record contains a general data string in its data part.
Example :
test.com IN SOA ...
...
mail IN A 192.1.1.2
IN HINFO My_Server UNIX
IN TXT my server
Q: - what are "MX Records"?

MX records specify the mailing server of the domain. An MX record shows to which computer a mail of a particular domain should be sent. The MX record also includes a priority number, which can be used to determine several computers where the mail for the domain can be sent. The first attempt is to deliver the mail to the computer with the highest priority (lowest value). If this attempt fails, the mail goes to the next computer (with a higher priority value), and so on.

test.com IN SOA ...
...
mail               IN        A         192.1.1.2
                       IN       HINFO    AlphaServer UNIX
                       IN        TXT       my  server
                       IN         MX   30    mail2.nextstep4it.com
                       IN         MX   20    mail3.nextstep4it.com
                       IN         MX   10    mail2.nextstep4it.com

Q: - Explain "PTR Records"?

A Pointer Record (PTR) is used to translate an IP address into a domain name.
Q: - What is Dynamic DNS?

Dynamic DNS a method of keeping a domain name linked to a changing IP address as not all computers use static IP addresses. Typically, when a user connects to the Internet, the user's ISP assigns an unused IP address from a pool of IP addresses, and this address is used only for the duration of that specific connection. This method of dynamically assigning addresses extends the usable pool of available IP addresses. A dynamic DNS service provider uses a special program that runs on the user's computer, contacting the DNS service each time the IP address provided by the ISP changes and subsequently updating the DNS database to reflect the change in IP address.
Q: - What is the role of "named-checkconf Utility"?

The named-checkconf utility checks the syntax of the named.conf configuration file.
Syntax: named-checkconf    [-t directory] [filename] 

Q: - what is the role of "named-checkzone Utility"?

The named-checkzone utility checks the syntax and consistency of the zone file.
Syntax:     named-checkzone [-dgv]   [-c class] zone   [filename]

Kubernetes 1.31 || Testing the Image Volume mount feature using Minikube

With Kubernetes new version 1.31 ( https://kubernetes.io/blog/2024/08/13/kubernetes-v1-31-release/ ) there are so many features releases for...