<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4565261699505124804</id><updated>2024-08-28T08:02:46.030-07:00</updated><category term="configuration"/><category term="linux"/><category term="linux server"/><category term="system administrator"/><category term="20 Linux System Monitoring Tools"/><category term="hat"/><category term="howto paksnaps.com"/><category term="monitoring tools"/><category term="proxy"/><category term="proxy server"/><category term="red"/><category term="samba"/><category term="server"/><category term="server configuration"/><category term="squid"/><category term="transparent proxy"/><title type='text'>Linux Configurations for System Administrator</title><subtitle type='html'>linux configuration for system and network administrators and linux users who are interested in linux</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-883650636732671446</id><published>2010-10-23T01:06:00.000-07:00</published><updated>2010-10-23T01:06:43.095-07:00</updated><title type='text'>SNap(R) Traditions &amp; Cultures: Welcome to my Sindh</title><content type='html'>&lt;a href=&quot;http://culturesntraditions.blogspot.com/2009/12/welcome-to-my-sindh.html&quot;&gt;SNap(R) Traditions &amp;amp; Cultures: Welcome to my Sindh&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/883650636732671446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/snapr-traditions-cultures-welcome-to-my.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/883650636732671446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/883650636732671446'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/snapr-traditions-cultures-welcome-to-my.html' title='SNap(R) Traditions &amp; Cultures: Welcome to my Sindh'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-3799136649190013418</id><published>2010-10-23T01:02:00.000-07:00</published><updated>2010-10-23T01:02:32.747-07:00</updated><title type='text'>http://paksnaps.com/wp-content/uploads/2010/09/4a6424dbd912f.jpg</title><content type='html'>&lt;a href=&quot;http://paksnaps.com/wp-content/uploads/2010/09/4a6424dbd912f.jpg&quot;&gt;http://paksnaps.com/wp-content/uploads/2010/09/4a6424dbd912f.jpg&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/3799136649190013418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/httppaksnapscomwp-contentuploads2010094.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/3799136649190013418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/3799136649190013418'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/httppaksnapscomwp-contentuploads2010094.html' title='http://paksnaps.com/wp-content/uploads/2010/09/4a6424dbd912f.jpg'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-4948078073693357055</id><published>2010-10-22T05:42:00.000-07:00</published><updated>2010-10-22T05:42:50.685-07:00</updated><title type='text'>Ranikot Fort in Kirthar Range, Sindh | PakSnaps</title><content type='html'>&lt;a href=&quot;http://paksnaps.com/ranikot-fort-in-kirthar-range-sindh/&quot;&gt;Ranikot Fort in Kirthar Range, Sindh | PakSnaps&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/4948078073693357055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/ranikot-fort-in-kirthar-range-sindh.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/4948078073693357055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/4948078073693357055'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/ranikot-fort-in-kirthar-range-sindh.html' title='Ranikot Fort in Kirthar Range, Sindh | PakSnaps'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-6815698669139528343</id><published>2010-10-16T08:59:00.000-07:00</published><updated>2010-10-16T09:02:32.903-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="20 Linux System Monitoring Tools"/><category scheme="http://www.blogger.com/atom/ns#" term="linux server"/><category scheme="http://www.blogger.com/atom/ns#" term="monitoring tools"/><category scheme="http://www.blogger.com/atom/ns#" term="system administrator"/><title type='text'>20 Linux System Monitoring Tools</title><content type='html'>&lt;div class=&quot;headline_area&quot;&gt; 					&lt;h1 class=&quot;entry-title&quot;&gt;20 Linux System Monitoring Tools Every SysAdmin Should Know&lt;/h1&gt; 					&lt;p class=&quot;headline_meta&quot;&gt;by &lt;span class=&quot;author vcard fn&quot;&gt;Vivek Gite&lt;/span&gt; · &lt;span&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html#comments&quot; rel=&quot;nofollow&quot;&gt;162 comments&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; 				&lt;/div&gt; 				 &lt;div style=&quot;float: right; margin-top: 0px; margin-left: 5px;&quot;&gt;&lt;a title=&quot;See all GNU/Linux related tips/articles&quot; href=&quot;http://www.cyberciti.biz/tips/category/linux&quot;&gt;&lt;img src=&quot;http://figs.cyberciti.biz/3rdparty/linux-logo.png&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt; &lt;p&gt;Need to monitor Linux server performance? Try these built-in command  and a few add-on tools. Most Linux distributions are equipped with tons  of monitoring. These tools provide metrics which can be used to get  information about system activities. You can use these tools to find the  possible causes of a performance problem. The commands discussed below  are some of the most basic commands when it comes to system analysis and  debugging server issues such as:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Finding out bottlenecks.&lt;/li&gt;&lt;li&gt;Disk (storage)  bottlenecks.&lt;/li&gt;&lt;li&gt;CPU and memory bottlenecks.&lt;/li&gt;&lt;li&gt;Network bottlenecks.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;span id=&quot;more-4934&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;a name=&quot;1&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#1: top - Process Activity Command&lt;/h2&gt; &lt;p&gt;The  top  program provides a dynamic real-time view of a running  system i.e.  actual process activity. By default, it displays the most  CPU-intensive tasks running on the server and updates the list every  five seconds.&lt;/p&gt; &lt;div id=&quot;attachment_5179&quot; class=&quot;wp-caption aligncenter&quot; style=&quot;width: 269px;&quot;&gt; 	&lt;a rel=&quot;attachment wp-att-5179&quot; href=&quot;http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html/top-output&quot;&gt;&lt;img class=&quot;size-medium wp-image-5179&quot; title=&quot;Fig.01: Linux top command&quot; src=&quot;http://files.cyberciti.biz/uploads/tips/2009/06/top-output-269x300.png&quot; alt=&quot;Fig.01: Linux top command&quot; width=&quot;269&quot; height=&quot;300&quot; /&gt;&lt;/a&gt; 	&lt;p class=&quot;wp-caption-text&quot;&gt;Fig.01: Linux top command&lt;/p&gt; &lt;/div&gt; &lt;h3&gt;Commonly Used Hot Keys&lt;/h3&gt; &lt;p&gt;The top command provides several useful hot keys:&lt;/p&gt; &lt;table border=&quot;0&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;Hot Key&lt;/th&gt; &lt;th&gt;Usage&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;t&lt;/td&gt; &lt;td&gt;Displays summary information off and on.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;m&lt;/td&gt; &lt;td&gt;Displays memory information off and on.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;Sorts the display by top consumers of various system resources.  Useful for quick identification of performance-hungry tasks on a system.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;f&lt;/td&gt; &lt;td&gt;Enters an interactive configuration screen for top. Helpful for setting up top for a specific task.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;o&lt;/td&gt; &lt;td&gt;Enables you to interactively select the ordering within top.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;r&lt;/td&gt; &lt;td&gt;Issues renice command.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;k&lt;/td&gt; &lt;td&gt;Issues kill command.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;z&lt;/td&gt; &lt;td&gt;Turn on or off color/mono&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; &lt;a href=&quot;http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html&quot;&gt;How do I Find Out Linux CPU Utilization?&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;2&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#2: vmstat - System Activity, Hardware and System Information&lt;/h2&gt; &lt;p&gt;The command vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.&lt;br /&gt;&lt;code&gt;# vmstat 3&lt;/code&gt;&lt;br /&gt;Sample Outputs:&lt;/p&gt; &lt;pre&gt;procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st  0  0      0 2540988 522188 5130400    0    0     2    32    4    2  4  1 96  0  0  1  0      0 2540988 522188 5130400    0    0     0   720 1199  665  1  0 99  0  0  0  0      0 2540956 522188 5130400    0    0     0     0 1151 1569  4  1 95  0  0  0  0      0 2540956 522188 5130500    0    0     0     6 1117  439  1  0 99  0  0  0  0      0 2540940 522188 5130512    0    0     0   536 1189  932  1  0 98  0  0  0  0      0 2538444 522188 5130588    0    0     0     0 1187 1417  4  1 96  0  0  0  0      0 2490060 522188 5130640    0    0     0    18 1253 1123  5  1 94  0  0&lt;/pre&gt; &lt;h3&gt;Display Memory Utilization Slabinfo&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# vmstat -m&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Get Information About Active / Inactive Memory Pages&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# vmstat -a&lt;/code&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; &lt;a href=&quot;http://www.cyberciti.biz/tips/linux-resource-utilization-to-detect-system-bottlenecks.html&quot;&gt;How do I find out Linux Resource utilization to detect system bottlenecks?&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;3&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#3: w - Find Out Who Is Logged on And What They Are Doing&lt;/h2&gt; &lt;p&gt;w command displays information about the users currently on the machine, and their processes.&lt;br /&gt;&lt;code&gt;# w username&lt;br /&gt;# w vivek&lt;/code&gt;&lt;br /&gt;Sample Outputs:&lt;/p&gt; &lt;pre&gt; 17:58:47 up 5 days, 20:28,  2 users,  load average: 0.36, 0.26, 0.24 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT root     pts/0    10.1.3.145       14:55    5.00s  0.04s  0.02s vim /etc/resolv.conf root     pts/1    10.1.3.145       17:43    0.00s  0.03s  0.00s w&lt;/pre&gt; &lt;p&gt;&lt;a name=&quot;4&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;#4: uptime - Tell How Long The System Has Been Running&lt;/h3&gt; &lt;p&gt;The uptime command can be used to see how long the server has been  running. The current time, how long the system has been running, how  many users are currently logged on, and the system load averages for the  past 1, 5, and 15 minutes.&lt;br /&gt;&lt;code&gt;# uptime&lt;/code&gt;&lt;br /&gt;Output:&lt;/p&gt; &lt;pre&gt; 18:02:41 up 41 days, 23:42,  1 user,  load average: 0.00, 0.00, 0.00&lt;/pre&gt; &lt;p&gt;1 can be considered as optimal load value. The load can change from  system to system. For a single CPU system 1 - 3 and SMP systems 6-10  load value might be acceptable.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;5&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#5: ps - Displays The Processes&lt;/h2&gt; &lt;p&gt;ps command will report a snapshot of the current processes. To select all processes use the -A or -e option:&lt;br /&gt;&lt;code&gt;# ps -A&lt;/code&gt;&lt;br /&gt;Sample Outputs:&lt;/p&gt; &lt;pre&gt;  PID TTY          TIME CMD     1 ?        00:00:02 init     2 ?        00:00:02 migration/0     3 ?        00:00:01 ksoftirqd/0     4 ?        00:00:00 watchdog/0     5 ?        00:00:00 migration/1     6 ?        00:00:15 ksoftirqd/1 .... .....  4881 ?        00:53:28 java  4885 tty1     00:00:00 mingetty  4886 tty2     00:00:00 mingetty  4887 tty3     00:00:00 mingetty  4888 tty4     00:00:00 mingetty  4891 tty5     00:00:00 mingetty  4892 tty6     00:00:00 mingetty  4893 ttyS1    00:00:00 agetty 12853 ?        00:00:00 cifsoplockd 12854 ?        00:00:00 cifsdnotifyd 14231 ?        00:10:34 lighttpd 14232 ?        00:00:00 php-cgi 54981 pts/0    00:00:00 vim 55465 ?        00:00:00 php-cgi 55546 ?        00:00:00 bind9-snmp-stat 55704 pts/1    00:00:00 ps&lt;/pre&gt; &lt;p&gt;ps is just like top but provides more information.&lt;/p&gt; &lt;h3&gt;Show Long Format Output&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -Al&lt;/code&gt;&lt;br /&gt;To turn on  extra full mode (it will show command line arguments passed to process):&lt;br /&gt;&lt;code&gt;# ps -AlF&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;To See Threads ( LWP and NLWP)&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -AlFH&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;To See Threads After Processes&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -AlLm&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Print All Process On The Server&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps ax&lt;br /&gt;# ps axu&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Print A Process Tree&lt;/h3&gt; &lt;p&gt;&lt;code&gt;#  ps -ejH&lt;br /&gt;#  ps axjf&lt;br /&gt;#  pstree&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Print Security Information&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -eo euser,ruser,suser,fuser,f,comm,label&lt;br /&gt;# ps axZ&lt;br /&gt;# ps -eM&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;See Every Process Running As User Vivek&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -U vivek -u vivek u&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Set Output In a User-Defined Format&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm&lt;br /&gt;# ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm&lt;br /&gt;# ps -eopid,tt,user,fname,tmout,f,wchan&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Display Only The Process IDs of Lighttpd&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -C lighttpd -o pid=&lt;/code&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;code&gt;# pgrep lighttpd&lt;/code&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;code&gt;# pgrep -u vivek php-cgi&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Display The Name of PID 55977&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -p 55977 -o comm=&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Find Out The Top 10 Memory Consuming Process&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -auxf | sort -nr -k 4 | head -10&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Find Out top 10 CPU Consuming Process&lt;/h3&gt; &lt;p&gt;&lt;code&gt;# ps -auxf | sort -nr -k 3 | head -10&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;6&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#6: free - Memory Usage&lt;/h2&gt; &lt;p&gt;The command free displays the total amount of free and used physical  and swap memory in the system, as well as the buffers used by the  kernel.&lt;br /&gt;&lt;code&gt;# free &lt;/code&gt;&lt;br /&gt;Sample Output:&lt;/p&gt; &lt;pre&gt;            total       used       free     shared    buffers     cached Mem:      12302896    9739664    2563232          0     523124    5154740 -/+ buffers/cache:    4061800    8241096 Swap:      1052248          0    1052248&lt;/pre&gt; &lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; :&lt;/p&gt; &lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/faq/linux-check-the-size-of-pagesize/&quot;&gt;Linux Find Out Virtual Memory PAGESIZE&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/faq/cpu-usage-limiter-for-linux/&quot;&gt;Linux Limit CPU Usage Per Process&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/how-much-ram-does-my-linux-system.html&quot;&gt;How much RAM does my Ubuntu / Fedora Linux desktop PC have?&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;a name=&quot;7&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#7: iostat -  Average CPU Load, Disk Activity&lt;/h2&gt; &lt;p&gt;The command iostat report Central Processing Unit (CPU) statistics  and input/output statistics for devices, partitions and network  filesystems (NFS).&lt;br /&gt;&lt;code&gt;# iostat &lt;/code&gt;&lt;br /&gt;Sample Outputs:&lt;/p&gt; &lt;pre&gt;Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in) 	06/26/2009  avg-cpu:  %user   %nice %system %iowait  %steal   %idle            3.50    0.09    0.51    0.03    0.00   95.86  Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn sda              22.04        31.88       512.03   16193351  260102868 sda1              0.00         0.00         0.00       2166        180 sda2             22.04        31.87       512.03   16189010  260102688 sda3              0.00         0.00         0.00       1615          0&lt;/pre&gt; &lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; : &lt;a href=&quot;http://www.cyberciti.biz/faq/howto-linux-track-nfs-client-disk-metrics/&quot;&gt;Linux Track NFS Directory / Disk I/O Stats&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;8&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#8: sar - Collect and Report System Activity&lt;/h2&gt; &lt;p&gt;The sar command is used to collect, report, and save system activity information. To see network counter, enter:&lt;br /&gt;&lt;code&gt;# sar -n DEV | more&lt;/code&gt;&lt;br /&gt;To display the network counters from the 24th:&lt;br /&gt;&lt;code&gt;# sar -n DEV -f /var/log/sa/sa24 | more&lt;/code&gt;&lt;br /&gt;You can also display real time usage using sar:&lt;br /&gt;&lt;code&gt;# sar 4 5&lt;/code&gt;&lt;br /&gt;Sample Outputs:&lt;/p&gt; &lt;pre&gt;Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in) 		06/26/2009  06:45:12 PM       CPU     %user     %nice   %system   %iowait    %steal     %idle 06:45:16 PM       all      2.00      0.00      0.22      0.00      0.00     97.78 06:45:20 PM       all      2.07      0.00      0.38      0.03      0.00     97.52 06:45:24 PM       all      0.94      0.00      0.28      0.00      0.00     98.78 06:45:28 PM       all      1.56      0.00      0.22      0.00      0.00     98.22 06:45:32 PM       all      3.53      0.00      0.25      0.03      0.00     96.19 Average:          all      2.02      0.00      0.27      0.01      0.00     97.70&lt;/pre&gt; &lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; :  &lt;a href=&quot;http://www.cyberciti.biz/tips/howto-write-system-utilization-data-to-file.html&quot;&gt;How to collect Linux system utilization data into a file&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;9&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#9: mpstat -  Multiprocessor Usage&lt;/h2&gt; &lt;p&gt;The  mpstat  command displays activities for each available  processor, processor 0 being the first one.  mpstat -P ALL to display  average CPU utilization per processor:&lt;br /&gt;&lt;code&gt;# mpstat -P ALL&lt;/code&gt;&lt;br /&gt;Sample Output:&lt;/p&gt; &lt;pre&gt;Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in)	 	06/26/2009  06:48:11 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s 06:48:11 PM  all    3.50    0.09    0.34    0.03    0.01    0.17    0.00   95.86   1218.04 06:48:11 PM    0    3.44    0.08    0.31    0.02    0.00    0.12    0.00   96.04   1000.31 06:48:11 PM    1    3.10    0.08    0.32    0.09    0.02    0.11    0.00   96.28     34.93 06:48:11 PM    2    4.16    0.11    0.36    0.02    0.00    0.11    0.00   95.25      0.00 06:48:11 PM    3    3.77    0.11    0.38    0.03    0.01    0.24    0.00   95.46     44.80 06:48:11 PM    4    2.96    0.07    0.29    0.04    0.02    0.10    0.00   96.52     25.91 06:48:11 PM    5    3.26    0.08    0.28    0.03    0.01    0.10    0.00   96.23     14.98 06:48:11 PM    6    4.00    0.10    0.34    0.01    0.00    0.13    0.00   95.42      3.75 06:48:11 PM    7    3.30    0.11    0.39    0.03    0.01    0.46    0.00   95.69     76.89&lt;/pre&gt; &lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; : &lt;a href=&quot;http://www.cyberciti.biz/faq/linux-mpstat-command-report-processors-related-statistics/&quot;&gt;Linux display each multiple SMP CPU processors utilization individually&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;10&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#10: pmap - Process Memory Usage&lt;/h2&gt; &lt;p&gt;The command pmap report memory map of a process. Use this command to find out causes of memory bottlenecks.&lt;br /&gt;&lt;code&gt;# pmap -d PID&lt;/code&gt;&lt;br /&gt;To display process memory information for pid # 47394, enter:&lt;br /&gt;&lt;code&gt;# pmap -d 47394&lt;/code&gt;&lt;br /&gt;Sample Outputs:&lt;/p&gt; &lt;pre&gt;47394:   /usr/bin/php-cgi Address           Kbytes Mode  Offset           Device    Mapping 0000000000400000    2584 r-x-- 0000000000000000 008:00002 php-cgi 0000000000886000     140 rw--- 0000000000286000 008:00002 php-cgi 00000000008a9000      52 rw--- 00000000008a9000 000:00000   [ anon ] 0000000000aa8000      76 rw--- 00000000002a8000 008:00002 php-cgi 000000000f678000    1980 rw--- 000000000f678000 000:00000   [ anon ] 000000314a600000     112 r-x-- 0000000000000000 008:00002 ld-2.5.so 000000314a81b000       4 r---- 000000000001b000 008:00002 ld-2.5.so 000000314a81c000       4 rw--- 000000000001c000 008:00002 ld-2.5.so 000000314aa00000    1328 r-x-- 0000000000000000 008:00002 libc-2.5.so 000000314ab4c000    2048 ----- 000000000014c000 008:00002 libc-2.5.so ..... ...... .. 00002af8d48fd000       4 rw--- 0000000000006000 008:00002 xsl.so 00002af8d490c000      40 r-x-- 0000000000000000 008:00002 libnss_files-2.5.so 00002af8d4916000    2044 ----- 000000000000a000 008:00002 libnss_files-2.5.so 00002af8d4b15000       4 r---- 0000000000009000 008:00002 libnss_files-2.5.so 00002af8d4b16000       4 rw--- 000000000000a000 008:00002 libnss_files-2.5.so 00002af8d4b17000  768000 rw-s- 0000000000000000 000:00009 zero (deleted) 00007fffc95fe000      84 rw--- 00007ffffffea000 000:00000   [ stack ] ffffffffff600000    8192 ----- 0000000000000000 000:00000   [ anon ] mapped: 933712K    writeable/private: 4304K    shared: 768000K&lt;/pre&gt; &lt;p&gt;The last line is very important:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;mapped: 933712K&lt;/strong&gt; total amount of memory mapped to files&lt;/li&gt;&lt;li&gt;&lt;strong&gt;writeable/private: 4304K&lt;/strong&gt; the amount of private address space&lt;/li&gt;&lt;li&gt;&lt;strong&gt;shared: 768000K&lt;/strong&gt; the amount of address space this process is sharing with others&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 51, 102);&quot;&gt;=&gt; Related:&lt;/span&gt;&lt;/strong&gt; : &lt;a href=&quot;http://www.cyberciti.biz/tips/howto-find-memory-used-by-program.html&quot;&gt;Linux find the memory used by a program / process using pmap command&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;11&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#11 and #12: netstat and ss -  Network Statistics&lt;/h2&gt; &lt;p&gt;The command netstat displays network connections, routing tables,  interface statistics, masquerade connections, and multicast memberships.   ss command is used to dump socket statistics. It allows showing  information similar to netstat. See the following resources about ss and  netstat commands:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/linux-investigate-sockets-network-connections.html&quot;&gt;ss: Display Linux TCP / UDP Network and Socket Information&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/netstat-command-tutorial-examples.html&quot;&gt;Get Detailed Information About Particular IP address Connections Using netstat Command&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;13&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#13: iptraf - Real-time Network Statistics&lt;/h2&gt; &lt;p&gt;The iptraf command is interactive colorful IP LAN monitor.  It is an  ncurses-based IP LAN monitor that generates various network statistics  including TCP info, UDP counts, ICMP and OSPF information, Ethernet load  info, node stats, IP checksum errors, and others. It can provide the  following info in easy to read format:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Network traffic statistics by TCP connection&lt;/li&gt;&lt;li&gt;IP traffic statistics by network interface&lt;/li&gt;&lt;li&gt;Network traffic statistics by protocol&lt;/li&gt;&lt;li&gt;Network traffic statistics by TCP/UDP port and by packet size&lt;/li&gt;&lt;li&gt;Network traffic statistics by Layer2 address&lt;/li&gt;&lt;/ul&gt; &lt;div id=&quot;attachment_5196&quot; class=&quot;wp-caption aligncenter&quot; style=&quot;width: 600px;&quot;&gt; 	&lt;a rel=&quot;attachment wp-att-5196&quot; href=&quot;http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html/iptraf3&quot;&gt;&lt;img class=&quot;size-full wp-image-5196&quot; title=&quot;Fig.02: General interface statistics: IP traffic statistics by network interface &quot; src=&quot;http://files.cyberciti.biz/uploads/tips/2009/06/iptraf3.png&quot; alt=&quot;Fig.02: General interface statistics: IP traffic statistics by network interface &quot; width=&quot;600&quot; height=&quot;347&quot; /&gt;&lt;/a&gt; 	&lt;p class=&quot;wp-caption-text&quot;&gt;Fig.02: General interface statistics: IP traffic statistics by network interface &lt;/p&gt; &lt;/div&gt; &lt;div id=&quot;attachment_5195&quot; class=&quot;wp-caption aligncenter&quot; style=&quot;width: 600px;&quot;&gt; 	&lt;a rel=&quot;attachment wp-att-5195&quot; href=&quot;http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html/iptraf2&quot;&gt;&lt;img class=&quot;size-full wp-image-5195&quot; title=&quot;Fig.03 Network traffic statistics by TCP connection&quot; src=&quot;http://files.cyberciti.biz/uploads/tips/2009/06/iptraf2.png&quot; alt=&quot;Fig.03 Network traffic statistics by TCP connection&quot; width=&quot;600&quot; height=&quot;416&quot; /&gt;&lt;/a&gt; 	&lt;p class=&quot;wp-caption-text&quot;&gt;Fig.03 Network traffic statistics by TCP connection&lt;/p&gt; &lt;/div&gt; &lt;p&gt;&lt;a name=&quot;14&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#14: tcpdump - Detailed Network Traffic Analysis&lt;/h2&gt; &lt;p&gt;The tcpdump is simple command that dump traffic on a network.  However, you need good understanding of TCP/IP protocol to utilize this  tool.  For.e.g to display traffic info about DNS, enter:&lt;br /&gt;&lt;code&gt;# tcpdump -i eth1 &#39;udp port 53&#39;&lt;/code&gt;&lt;br /&gt;To display all IPv4 HTTP packets to and from port 80, i.e. print only  packets that contain data, not, for example, SYN and FIN packets and  ACK-only packets, enter:&lt;br /&gt;&lt;code&gt;# tcpdump &#39;tcp port 80 and (((ip[2:2] - ((ip[0]&amp;amp;0xf)&lt;&lt;2))&gt;&gt;2)) != 0)&#39;&lt;/code&gt;&lt;br /&gt;To display all FTP session to 202.54.1.5, enter:&lt;br /&gt;&lt;code&gt;# tcpdump -i eth1 &#39;dst 202.54.1.5 and (port 21 or 20&#39;&lt;/code&gt;&lt;br /&gt;To display all HTTP session to 192.168.1.5:&lt;br /&gt;&lt;code&gt;# tcpdump -ni eth0 &#39;dst 192.168.1.5 and tcp and port http&#39;&lt;/code&gt;&lt;br /&gt;Use &lt;a href=&quot;http://www.cyberciti.biz/faq/linux-unix-bsd-apache-tcpdump-http-packets-sniffing/&quot;&gt;wireshark to view detailed&lt;/a&gt; information about files, enter:&lt;br /&gt;&lt;code&gt;# tcpdump -n -i eth1 -s 0 -w output.txt src or dst port 80&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;15&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#15: strace -  System Calls&lt;/h2&gt; &lt;p&gt;Trace system calls and signals. This is useful for debugging  webserver and other server problems. See how to use to &lt;a href=&quot;http://www.cyberciti.biz/tips/linux-strace-command-examples.html&quot;&gt;trace the process and&lt;/a&gt; see What it is doing.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;16&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#16: /Proc file system - Various Kernel Statistics&lt;/h2&gt; &lt;p&gt;/proc file system provides detailed information about various hardware devices and other Linux kernel information. See &lt;a href=&quot;http://www.cyberciti.biz/files/linux-kernel/Documentation/filesystems/proc.txt&quot;&gt;Linux kernel /proc&lt;/a&gt; documentations for further details. Common /proc examples:&lt;br /&gt;&lt;code&gt;# cat /proc/cpuinfo&lt;br /&gt;# cat /proc/meminfo&lt;br /&gt;# cat /proc/zoneinfo&lt;br /&gt;# cat /proc/mounts&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;17&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;17#: Nagios - Server And Network Monitoring&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;http://www.nagios.org/&quot; target=&quot;_blank&quot;&gt;Nagios&lt;/a&gt; is a  popular open source computer system and network monitoring application  software. You can easily monitor all your hosts, network equipment and  services. It can send alert when things go wrong and again when they get  better. &lt;a href=&quot;http://fannagioscd.sourceforge.net/drupal/&quot; target=&quot;_blank&quot;&gt;FAN is&lt;/a&gt;   &quot;Fully Automated Nagios&quot;. FAN goals are to provide a Nagios  installation including most tools provided by the Nagios Community. FAN  provides a CDRom image in the standard ISO format, making it easy to  easilly install a Nagios server. Added to this, a wide bunch of tools  are including to the distribution, in order to improve the user  experience around Nagios.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;18&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;18#: Cacti -  Web-based Monitoring Tool&lt;/h2&gt; &lt;p&gt;Cacti is a complete network graphing solution designed to harness the  power of RRDTool&#39;s data storage and graphing functionality. Cacti  provides a fast poller, advanced graph templating, multiple data  acquisition methods, and user management features out of the box. All of  this is wrapped in an intuitive, easy to use interface that makes sense  for LAN-sized installations up to complex networks with hundreds of  devices. It can provide data about network, CPU, memory, logged in  users, Apache, DNS servers and much more. See how &lt;a href=&quot;http://www.cyberciti.biz/faq/fedora-rhel-install-cacti-monitoring-rrd-software/&quot;&gt;to install and configure Cacti network graphing&lt;/a&gt; tool under CentOS / RHEL.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;19&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#19: KDE System Guard -  Real-time Systems Reporting and Graphing&lt;/h2&gt; &lt;p&gt;KSysguard is a network enabled task and system monitor application  for KDE desktop. This tool can be run over ssh session. It provides lots  of features such as  a client/server architecture that enables  monitoring of local and remote hosts. The graphical front end uses  so-called sensors to retrieve the information it displays. A sensor can  return simple values or more complex information like tables. For each  type of information, one or more displays are provided. Displays are  organized in worksheets that can be saved and loaded independently from  each other. So, KSysguard is not only a simple task manager but also a  very powerful tool to control large server farms.&lt;/p&gt; &lt;div id=&quot;attachment_5215&quot; class=&quot;wp-caption aligncenter&quot; style=&quot;width: 600px;&quot;&gt; 	&lt;a rel=&quot;attachment wp-att-5215&quot; href=&quot;http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html/kde-systemguard-screenshot&quot;&gt;&lt;img class=&quot;size-full wp-image-5215&quot; title=&quot;Fig.05 KDE System Guard KDE task manager and performance monitor.&quot; src=&quot;http://files.cyberciti.biz/uploads/tips/2009/06/kde-systemguard-screenshot.png&quot; alt=&quot;Fig.05 KDE System Guard&quot; width=&quot;600&quot; height=&quot;462&quot; /&gt;&lt;/a&gt; 	&lt;p class=&quot;wp-caption-text&quot;&gt;Fig.05 KDE System Guard {Image credit: Wikipedia}&lt;/p&gt; &lt;/div&gt; &lt;p&gt;See &lt;a href=&quot;http://docs.kde.org/stable/en/kdebase-workspace/ksysguard/index.html&quot;&gt;the KSysguard handbook&lt;/a&gt; for detailed usage.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;20&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;#20: Gnome System Monitor - Real-time Systems Reporting and Graphing&lt;/h2&gt; &lt;p&gt;The System Monitor application enables you to display basic system  information and monitor system processes, usage of system resources, and  file systems. You can also use System Monitor to modify the behavior of  your system. Although not as powerful as the KDE System Guard,  it  provides the basic information which may be useful for new users:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; Displays various basic information about the computer&#39;s hardware and software.&lt;/li&gt;&lt;li&gt; Linux Kernel version&lt;/li&gt;&lt;li&gt; GNOME version&lt;/li&gt;&lt;li&gt; Hardware&lt;/li&gt;&lt;li&gt; Installed memory&lt;/li&gt;&lt;li&gt; Processors and speeds&lt;/li&gt;&lt;li&gt; System Status&lt;/li&gt;&lt;li&gt; Currently available disk space&lt;/li&gt;&lt;li&gt; Processes&lt;/li&gt;&lt;li&gt; Memory and swap space&lt;/li&gt;&lt;li&gt; Network usage&lt;/li&gt;&lt;li&gt; File Systems&lt;/li&gt;&lt;li&gt; Lists all mounted filesystems along with basic information about each.&lt;/li&gt;&lt;/ul&gt; &lt;div id=&quot;attachment_5220&quot; class=&quot;wp-caption aligncenter&quot; style=&quot;width: 600px;&quot;&gt; 	&lt;a href=&quot;http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html/gnome-system-monitor&quot; rel=&quot;attachment wp-att-5220&quot;&gt;&lt;img src=&quot;http://files.cyberciti.biz/uploads/tips/2009/06/gnome-system-monitor.png&quot; alt=&quot;Fig.06 The Gnome System Monitor application&quot; title=&quot;Fig.06 The Gnome System Monitor application&quot; class=&quot;size-full wp-image-5220&quot; width=&quot;600&quot; height=&quot;451&quot; /&gt;&lt;/a&gt; 	&lt;p class=&quot;wp-caption-text&quot;&gt;Fig.06 The Gnome System Monitor application&lt;/p&gt; &lt;/div&gt; &lt;h2&gt;Bonus: Additional Tools&lt;/h2&gt; &lt;p&gt;A few more tools: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/linux-scanning-network-for-open-ports.html&quot;&gt;nmap&lt;/a&gt; - scan your server for open ports.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/tag/lsof-command&quot;&gt;lsof&lt;/a&gt; - list open files, network connections and much more.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/faq/debian-ubuntu-install-ntop-network-traffic-monitoring-software/&quot; title=&quot;Debian / Ubuntu Linux Install ntop To See Network Usage / Network Status&quot;&gt;ntop&lt;/a&gt;  web based tool -  ntop is the best tool to see network usage in a way  similar to what top command does for processes i.e. it is network  traffic monitoring software. You can see network status, protocol wise  distribution of traffic for UDP, TCP, DNS, HTTP and other protocols.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://conky.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;Conky&lt;/a&gt; -  Another good monitoring tool for the X Window System. It is highly  configurable and is able to monitor many system variables including the  status of the CPU, memory, swap space, disk storage, temperatures,  processes, network interfaces, battery power, system messages, e-mail  inboxes etc. &lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://members.dslextreme.com/users/billw/gkrellm/gkrellm.html&quot; target=&quot;_blank&quot;&gt;GKrellM&lt;/a&gt;  - It can be used to monitor the status of CPUs, main memory, hard  disks, network interfaces, local and remote mailboxes, and many other  things.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/keeping-a-log-of-daily-network-traffic-for-adsl-or-dedicated-remote-linux-box.html&quot;&gt;vnstat&lt;/a&gt;  - vnStat is a console-based network traffic monitor. It keeps a log of  hourly, daily and monthly network traffic for the selected interface(s).&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://htop.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;htop&lt;/a&gt; - htop is an enhanced version of top, the interactive process viewer, which can display the list of processes in a tree form.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/finding-out-a-bad-or-simply-overloaded-network-link-with-linuxunix-oses.html&quot;&gt;mtr&lt;/a&gt; -  mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/6815698669139528343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/20-linux-system-monitoring-tools.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/6815698669139528343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/6815698669139528343'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/20-linux-system-monitoring-tools.html' title='20 Linux System Monitoring Tools'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-8741559128210725843</id><published>2010-10-16T08:27:00.000-07:00</published><updated>2010-10-16T08:31:15.995-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="configuration"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="linux server"/><category scheme="http://www.blogger.com/atom/ns#" term="proxy"/><category scheme="http://www.blogger.com/atom/ns#" term="proxy server"/><category scheme="http://www.blogger.com/atom/ns#" term="server"/><category scheme="http://www.blogger.com/atom/ns#" term="server configuration"/><category scheme="http://www.blogger.com/atom/ns#" term="squid"/><category scheme="http://www.blogger.com/atom/ns#" term="system administrator"/><category scheme="http://www.blogger.com/atom/ns#" term="transparent proxy"/><title type='text'>Linux: Setup a transparent proxy with Squid in three easy steps</title><content type='html'>&lt;div class=&quot;headline_area&quot;&gt;      &lt;h1 class=&quot;entry-title&quot;&gt;Linux: Setup a transparent proxy with Squid in three easy steps&lt;/h1&gt;      &lt;p class=&quot;headline_meta&quot;&gt;by &lt;span class=&quot;author vcard fn&quot;&gt;LinuxTitli&lt;/span&gt; · &lt;span&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html#comments&quot; rel=&quot;nofollow&quot;&gt;236 comments&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/div&gt;      &lt;div style=&quot;float: right; margin-top: 0px; margin-left: 5px;&quot;&gt;&lt;a href=&quot;http://www.cyberciti.biz/tips/category/squid-caching-server/&quot; title=&quot;See all Squid related tips&quot;&gt;&lt;img src=&quot;http://figs.cyberciti.biz/3rdparty/squid-logo.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt; &lt;p&gt;Y&#39;day I got a chance to play with Squid and iptables. My job was simple : Setup Squid proxy as a transparent server. &lt;/p&gt; &lt;p&gt;Main benefit of setting transparent proxy is you do not have to setup up individual browsers to work with proxies. &lt;/p&gt; &lt;h3&gt;My Setup:&lt;/h3&gt; &lt;p&gt;i) System: HP dual Xeon CPU system with 8 GB RAM (good for squid).&lt;br /&gt;ii) Eth0: IP:192.168.1.1&lt;br /&gt;iii) Eth1: IP: 192.168.2.1 (192.168.2.0/24 network (around 150 windows XP systems))&lt;br /&gt;iv) OS: Red Hat Enterprise Linux 4.0 (Following instruction should work with Debian and all other Linux distros)&lt;/p&gt; &lt;p&gt;Eth0 connected to internet and eth1 connected to local lan i.e. system act as router.&lt;br /&gt;&lt;span id=&quot;more-92&quot;&gt;&lt;/span&gt;&lt;/p&gt; &lt;h3&gt;Server Configuration&lt;/h3&gt; &lt;ul&gt;&lt;li&gt;Step #1 : Squid configuration so that it will act as a transparent proxy&lt;/li&gt;&lt;li&gt;Step #2 : Iptables configuration &lt;/li&gt;&lt;ul&gt;&lt;li&gt;a) Configure system as router &lt;/li&gt;&lt;li&gt;b) Forward all http requests to 3128 (DNAT)&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Step #3: Run scripts and start squid service&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;First, Squid server installed (use up2date squid) and configured by adding following directives to file:&lt;br /&gt;&lt;code&gt;# vi /etc/squid/squid.conf&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Modify or add following squid directives:&lt;br /&gt;&lt;code&gt;httpd_accel_host &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;virtual&lt;/span&gt;&lt;br /&gt;httpd_accel_port &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;80&lt;/span&gt;&lt;br /&gt;httpd_accel_with_proxy &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;on&lt;/span&gt;&lt;br /&gt;httpd_accel_uses_host_header &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;on&lt;/span&gt;&lt;br /&gt;acl lan src &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;192.168.1.1 192.168.2.0/24&lt;/span&gt;&lt;br /&gt;http_access allow &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;localhost&lt;/span&gt;&lt;br /&gt;http_access allow &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;lan&lt;/span&gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Where,&lt;/p&gt; &lt;ul&gt;&lt;li&gt;httpd_accel_host &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;virtual&lt;/span&gt;: Squid as an httpd accelerator &lt;/li&gt;&lt;li&gt;httpd_accel_port &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;80&lt;/span&gt;: 80 is port you want to act as a proxy&lt;/li&gt;&lt;li&gt;httpd_accel_with_proxy &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;on&lt;/span&gt;: Squid act as both a local httpd accelerator and as a proxy. &lt;/li&gt;&lt;li&gt;httpd_accel_uses_host_header &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;on&lt;/span&gt;: Header is turned on which is the hostname from the URL.&lt;/li&gt;&lt;li&gt;acl lan src &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;192.168.1.1 192.168.2.0/24&lt;/span&gt;: Access control list, only allow LAN computers to use squid&lt;/li&gt;&lt;li&gt;http_access allow &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;localhost&lt;/span&gt;: Squid access to LAN and localhost ACL only&lt;/li&gt;&lt;li&gt;http_access allow &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;lan&lt;/span&gt;: -- same as above --&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Here is the complete listing of squid.conf for your reference (grep  will remove all comments and sed will remove all empty lines, thanks to  David Klein for quick hint ):&lt;br /&gt;&lt;code&gt;# grep -v &quot;^#&quot; /etc/squid/squid.conf | sed -e &#39;/^$/d&#39;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;OR, try out sed (thanks to &lt;a href=&quot;http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html#comment-144&quot;&gt;kotnik&lt;/a&gt; for small sed trick)&lt;br /&gt;&lt;code&gt;# cat /etc/squid/squid.conf | sed &#39;/ *#/d; /^ *$/d&#39;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Output:&lt;br /&gt;&lt;code&gt;hierarchy_stoplist cgi-bin ?&lt;br /&gt;acl QUERY urlpath_regex cgi-bin \?&lt;br /&gt;no_cache deny QUERY&lt;br /&gt;hosts_file /etc/hosts&lt;br /&gt;refresh_pattern ^ftp:           1440    20%     10080&lt;br /&gt;refresh_pattern ^gopher:        1440    0%      1440&lt;br /&gt;refresh_pattern .               0       20%     4320&lt;br /&gt;acl all src 0.0.0.0/0.0.0.0&lt;br /&gt;acl manager proto cache_object&lt;br /&gt;acl localhost src 127.0.0.1/255.255.255.255&lt;br /&gt;acl to_localhost dst 127.0.0.0/8&lt;br /&gt;acl purge method PURGE&lt;br /&gt;acl CONNECT method CONNECT&lt;br /&gt;cache_mem 1024 MB&lt;br /&gt;http_access allow manager localhost&lt;br /&gt;http_access deny manager&lt;br /&gt;http_access allow purge localhost&lt;br /&gt;http_access deny purge&lt;br /&gt;http_access deny !Safe_ports&lt;br /&gt;http_access deny CONNECT !SSL_ports&lt;br /&gt;acl lan src 192.168.1.1  192.168.2.0/24&lt;br /&gt;http_access allow localhost&lt;br /&gt;http_access allow lan&lt;br /&gt;http_access deny all&lt;br /&gt;http_reply_access allow all&lt;br /&gt;icp_access allow all&lt;br /&gt;visible_hostname myclient.hostname.com&lt;br /&gt;httpd_accel_host virtual&lt;br /&gt;httpd_accel_port 80&lt;br /&gt;httpd_accel_with_proxy on&lt;br /&gt;httpd_accel_uses_host_header on&lt;br /&gt;coredump_dir /var/spool/squid&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Iptables configuration&lt;/h3&gt; &lt;p&gt;Next, I had added following rules to forward all http requests (coming to port 80) to the Squid server port 3128 :&lt;br /&gt;&lt;code&gt;iptables -t nat -A PREROUTING -i  &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;eth1&lt;/span&gt; -p tcp --dport &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;80&lt;/span&gt; -j DNAT --to 192.168.1.1:3128&lt;br /&gt;iptables -t nat -A PREROUTING -i  &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;eth0&lt;/span&gt; -p tcp --dport  &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;80 -j REDIRECT --to-port 3128&lt;/span&gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Here is complete shell script. Script first configure Linux system as  router and forwards all http request to port 3128 (Download the &lt;a href=&quot;http://www.cyberciti.biz/tips/wp-content/uploads/2006/06/fw.proxy.txt&quot;&gt;fw.proxy&lt;/a&gt; shell script):&lt;br /&gt;&lt;code&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;#!/bin/sh&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# squid server IP&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;SQUID_SERVER&lt;span style=&quot;color:#990000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;192.168.1.1&quot;&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Interface connected to Internet&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;INTERNET&lt;span style=&quot;color:#990000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;eth0&quot;&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Interface connected to LAN&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;LAN_IN&lt;span style=&quot;color:#990000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;eth1&quot;&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Squid port&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;SQUID_PORT&lt;span style=&quot;color:#990000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;3128&quot;&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# DO NOT MODIFY BELOW&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Clean old firewall&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;F&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;X&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;t nat &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;F&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;t nat &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;X&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;t mangle &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;F&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;t mangle &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;X&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Load IPTABLES modules for NAT and IP conntrack support&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;modprobe ip_conntrack&lt;br /&gt;modprobe ip_conntrack_ftp&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# For win xp ftp client&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;#modprobe ip_nat_ftp&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;echo &lt;span style=&quot;color:#993399;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;&gt;&lt;/span&gt; /proc/sys/net/ipv4/&lt;b&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ip_forward&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Setting default filter policy&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;P INPUT DROP&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;P OUTPUT ACCEPT&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Unlimited access to loop back&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A INPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;i lo &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j ACCEPT&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A OUTPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;o lo &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j ACCEPT&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# Allow UDP, DNS and Passive FTP&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A INPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;i &lt;span style=&quot;color:#009900;&quot;&gt;$INTERNET&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;m&lt;/span&gt;&lt;/b&gt; state &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;state ESTABLISHED&lt;span style=&quot;color:#990000;&quot;&gt;,&lt;/span&gt;RELATED &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j ACCEPT&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# set this system as a router for Rest of LAN&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;table nat &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;append POSTROUTING &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;out&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;interface &lt;span style=&quot;color:#009900;&quot;&gt;$INTERNET&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j MASQUERADE&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;append FORWARD &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;in&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;interface &lt;span style=&quot;color:#009900;&quot;&gt;$LAN_IN&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j ACCEPT&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# unlimited access to LAN&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A INPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;i &lt;span style=&quot;color:#009900;&quot;&gt;$LAN_IN&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j ACCEPT&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A OUTPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;o &lt;span style=&quot;color:#009900;&quot;&gt;$LAN_IN&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j ACCEPT&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;t nat &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A PREROUTING &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;i &lt;span style=&quot;color:#009900;&quot;&gt;$LAN_IN&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;p tcp &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;dport &lt;span style=&quot;color:#993399;&quot;&gt;80&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j DNAT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;to &lt;span style=&quot;color:#009900;&quot;&gt;$SQUID_SERVER&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#009900;&quot;&gt;$SQUID_PORT&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# if it is same system&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;t nat &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A PREROUTING &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;i &lt;span style=&quot;color:#009900;&quot;&gt;$INTERNET&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;p tcp &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;dport &lt;span style=&quot;color:#993399;&quot;&gt;80&lt;/span&gt; &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j REDIRECT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;to&lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;port &lt;span style=&quot;color:#009900;&quot;&gt;$SQUID_PORT&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;color:#9a1900;&quot;&gt;# DROP everything and Log it&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A INPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j LOG&lt;br /&gt;iptables &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;A INPUT &lt;span style=&quot;color:#990000;&quot;&gt;-&lt;/span&gt;j DROP&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Save shell script. Execute script so that system will act as a router and forward the ports:&lt;br /&gt;&lt;code&gt;# chmod +x /etc/fw.proxy&lt;br /&gt;# /etc/fw.proxy&lt;br /&gt;# service iptables save&lt;br /&gt;# chkconfig iptables on&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Start or Restart the squid:&lt;br /&gt;&lt;code&gt;# /etc/init.d/squid restart&lt;br /&gt;# chkconfig squid on&lt;/code&gt;&lt;/p&gt; &lt;h3&gt;Desktop / Client computer configuration&lt;/h3&gt; &lt;p&gt;Point all desktop clients to your eth1 IP address (192.168.2.1) as  Router/Gateway (use DHCP to distribute this information). You do not  have to setup up individual browsers to work with proxies.&lt;/p&gt; &lt;h3&gt;How do I test my squid proxy is working correctly?&lt;/h3&gt; &lt;p&gt;See access log file /var/log/squid/access.log:&lt;br /&gt;&lt;code&gt;# tail -f /var/log/squid/access.log&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Above command will monitor all incoming request and log them to  /var/log/squid/access_log file. Now if somebody accessing a website  through browser, squid will log information.&lt;/p&gt; &lt;h3&gt;Problems and solutions&lt;/h3&gt; &lt;h4&gt;(a) Windows XP FTP Client&lt;/h4&gt; &lt;p&gt;All Desktop client FTP session request ended with an error:&lt;br /&gt;Illegal PORT command.&lt;/p&gt; &lt;p&gt;I had loaded the ip_nat_ftp kernel module. Just type the following command press Enter and voila!&lt;br /&gt;&lt;code&gt;# modprobe ip_nat_ftp&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Please note that modprobe command is already added to a shell script (above).&lt;/p&gt; &lt;h4&gt;(b) Port 443 redirection&lt;/h4&gt; &lt;p&gt;I had block out all connection request from our router settings  except for our proxy (192.168.1.1) server. So all ports including 443  (https/ssl) request denied. You cannot redirect port 443, from &lt;a href=&quot;http://lists.debian.org/debian-user/2004/05/msg01434.html&quot;&gt;debian mailing list&lt;/a&gt;, &quot;&lt;em&gt;Long  answer: SSL is specifically designed to prevent &quot;man in the middle&quot;  attacks, and setting up squid in such a way would be the same as such a  &quot;man in the middle&quot; attack. You might be able to successfully achive  this, but not without breaking the encryption and certification that is  the point behind SSL&lt;/em&gt;&quot;.&lt;/p&gt; &lt;p&gt;Therefore, I had quickly reopen port 443 (router firewall) for all my LAN computers and problem was solved.&lt;/p&gt; &lt;h4&gt;(c) Squid Proxy authentication in a transparent mode&lt;/h4&gt; &lt;p&gt;You cannot use Squid authentication with a transparently intercepting proxy.&lt;/p&gt; &lt;h3&gt;Further reading:&lt;/h3&gt; &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/how-do-i-use-iptables-connection.html&quot;&gt;How do I use Iptables connection tracking feature? &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/how-do-i-build-simple-linux-firewall.html&quot;&gt;How do I build a Simple Linux Firewall for DSL/Dial-up connection? &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;a href=&quot;http://www.cyberciti.biz/nixcraft/forum/viewtopic.php?t=457&quot;&gt;Forum topic discussion: Setting up a transparent proxy with Squid peering to ISP squid server&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://squid-docs.sourceforge.net/latest/html/book1.html&quot;&gt;Squid, a user&#39;s guide&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.squid-cache.org/Doc/FAQ/&quot;&gt;Squid FAQ&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://tldp.org/HOWTO/TransparentProxy.html&quot;&gt;Transparent Proxy with Linux and Squid mini-HOWTO&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Updated for accuracy.&lt;/p&gt;   &lt;ins style=&quot;display: inline-table; border: medium none; height: 60px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 468px;&quot;&gt;&lt;ins id=&quot;google_ads_frame1_anchor&quot; style=&quot;display: block; border: medium none; height: 60px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 468px;&quot;&gt;&lt;/ins&gt;&lt;/ins&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/8741559128210725843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/linux-setup-transparent-proxy-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/8741559128210725843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/8741559128210725843'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/linux-setup-transparent-proxy-with.html' title='Linux: Setup a transparent proxy with Squid in three easy steps'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-3498103791809559283</id><published>2010-10-16T08:10:00.000-07:00</published><updated>2010-10-16T08:16:58.547-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="configuration"/><category scheme="http://www.blogger.com/atom/ns#" term="hat"/><category scheme="http://www.blogger.com/atom/ns#" term="howto paksnaps.com"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="red"/><category scheme="http://www.blogger.com/atom/ns#" term="samba"/><title type='text'>Samba-HOWTO-Collection on Red Hat Linux</title><content type='html'># This is the main Samba configuration file. You should read the&lt;br /&gt;# smb.conf(5) manual page in order to understand the options listed&lt;br /&gt;# here. Samba has a huge number of configurable options (perhaps too&lt;br /&gt;# many!) most of which are not shown in this example&lt;br /&gt;#&lt;br /&gt;# For a step to step guide on installing, configuring and using samba,&lt;br /&gt;# read the Samba-HOWTO-Collection. This may be obtained from:&lt;br /&gt;#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf&lt;br /&gt;#&lt;br /&gt;# Many working examples of smb.conf files can be found in the&lt;br /&gt;# Samba-Guide which is generated daily and can be downloaded from:&lt;br /&gt;#  http://www.samba.org/samba/docs/Samba-Guide.pdf&lt;br /&gt;#&lt;br /&gt;# Any line which starts with a ; (semi-colon) or a # (hash)&lt;br /&gt;# is a comment and is ignored. In this example we will use a #&lt;br /&gt;# for commentry and a ; for parts of the config file that you&lt;br /&gt;# may wish to enable&lt;br /&gt;#&lt;br /&gt;# NOTE: Whenever you modify this file you should run the command &quot;testparm&quot;&lt;br /&gt;# to check that you have not made any basic syntactic errors.&lt;br /&gt;#&lt;br /&gt;#---------------&lt;br /&gt;# SELINUX NOTES:&lt;br /&gt;#&lt;br /&gt;# If you want to use the useradd/groupadd family of binaries please run:&lt;br /&gt;# setsebool -P samba_domain_controller on&lt;br /&gt;#&lt;br /&gt;# If you want to share home directories via samba please run:&lt;br /&gt;# setsebool -P samba_enable_home_dirs on&lt;br /&gt;#&lt;br /&gt;# If you create a new directory you want to share you should mark it as&lt;br /&gt;# &quot;samba-share_t&quot; so that selinux will let you write into it.&lt;br /&gt;# Make sure not to do that on system directories as they may already have&lt;br /&gt;# been marked with othe SELinux labels.&lt;br /&gt;#&lt;br /&gt;# Use ls -ldZ /path to see which context a directory has&lt;br /&gt;#&lt;br /&gt;# Set labels only on directories you created!&lt;br /&gt;# To set a label use the following: chcon -t samba_share_t /path&lt;br /&gt;#&lt;br /&gt;# If you need to share a system created directory you can use one of the&lt;br /&gt;# following (read-only/read-write):&lt;br /&gt;# setsebool -P samba_export_all_ro on&lt;br /&gt;# or&lt;br /&gt;# setsebool -P samba_export_all_rw on&lt;br /&gt;#&lt;br /&gt;# If you want to run scripts (preexec/root prexec/print command/...) please&lt;br /&gt;# put them into the /var/lib/samba/scripts directory so that smbd will be&lt;br /&gt;# allowed to run them.&lt;br /&gt;# Make sure you COPY them and not MOVE them so that the right SELinux context&lt;br /&gt;# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts&lt;br /&gt;#&lt;br /&gt;#--------------&lt;br /&gt;#&lt;br /&gt;#======================= Global Settings =====================================&lt;br /&gt;&lt;br /&gt;[global]&lt;br /&gt;#--authconfig--start-line--&lt;br /&gt;&lt;br /&gt;# Generated by authconfig on 2010/09/02 18:04:52&lt;br /&gt;# DO NOT EDIT THIS SECTION (delimited by --start-line--/--end-line--)&lt;br /&gt;# Any modification may be deleted or altered by authconfig in future&lt;br /&gt;&lt;br /&gt;  workgroup = workgroup&lt;br /&gt; # password server = hamdardisb&lt;br /&gt;  #security = user&lt;br /&gt;  #idmap uid = 16777216-33554431&lt;br /&gt;  #idmap gid = 16777216-33554431&lt;br /&gt;  #template shell = /bin/false&lt;br /&gt;  #winbind use default domain = false&lt;br /&gt;  #winbind offline logon = false&lt;br /&gt;netbios name=installer&lt;br /&gt;security = share&lt;br /&gt;&lt;br /&gt;#--authconfig--end-line--&lt;br /&gt;&lt;br /&gt;# ----------------------- Network Related Options -------------------------&lt;br /&gt;#&lt;br /&gt;# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH&lt;br /&gt;#&lt;br /&gt;# server string is the equivalent of the NT Description field&lt;br /&gt;#&lt;br /&gt;# netbios name can be used to specify a server name not tied to the hostname&lt;br /&gt;#&lt;br /&gt;# Interfaces lets you configure Samba to use multiple interfaces&lt;br /&gt;# If you have multiple network interfaces then you can list the ones&lt;br /&gt;# you want to listen on (never omit localhost)&lt;br /&gt;#&lt;br /&gt;# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can&lt;br /&gt;# specifiy it as a per share option as well&lt;br /&gt;#&lt;br /&gt;;    workgroup = MYGROUP&lt;br /&gt;   server string = Samba Server Version %v&lt;br /&gt;&lt;br /&gt;;    netbios name = MYSERVER&lt;br /&gt;&lt;br /&gt;;    interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24&lt;br /&gt;;    hosts allow = 127. 192.168.12. 192.168.13.&lt;br /&gt;&lt;br /&gt;# --------------------------- Logging Options -----------------------------&lt;br /&gt;#&lt;br /&gt;# Log File let you specify where to put logs and how to split them up.&lt;br /&gt;#&lt;br /&gt;# Max Log Size let you specify the max size log files should reach&lt;br /&gt;&lt;br /&gt;   # logs split per machine&lt;br /&gt;;    log file = /var/log/samba/%m.log&lt;br /&gt;   # max 50KB per log file, then rotate&lt;br /&gt;;    max log size = 50&lt;br /&gt;&lt;br /&gt;# ----------------------- Standalone Server Options ------------------------&lt;br /&gt;#&lt;br /&gt;# Security can be set to user, share(deprecated) or server(deprecated)&lt;br /&gt;#&lt;br /&gt;# Backend to store user information in. New installations should&lt;br /&gt;# use either tdbsam or ldapsam. smbpasswd is available for backwards&lt;br /&gt;# compatibility. tdbsam requires no further configuration.&lt;br /&gt;&lt;br /&gt;;    security = share&lt;br /&gt;   passdb backend = tdbsam&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# ----------------------- Domain Members Options ------------------------&lt;br /&gt;#&lt;br /&gt;# Security must be set to domain or ads&lt;br /&gt;#&lt;br /&gt;# Use the realm option only with security = ads&lt;br /&gt;# Specifies the Active Directory realm the host is part of&lt;br /&gt;#&lt;br /&gt;# Backend to store user information in. New installations should&lt;br /&gt;# use either tdbsam or ldapsam. smbpasswd is available for backwards&lt;br /&gt;# compatibility. tdbsam requires no further configuration.&lt;br /&gt;#&lt;br /&gt;# Use password server option only with security = server or if you can&#39;t&lt;br /&gt;# use the DNS to locate Domain Controllers&lt;br /&gt;# The argument list may include:&lt;br /&gt;#   password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]&lt;br /&gt;# or to auto-locate the domain controller/s&lt;br /&gt;#   password server = *&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;;    security = domain&lt;br /&gt;;    passdb backend = tdbsam&lt;br /&gt;;    realm = MY_REALM&lt;br /&gt;&lt;br /&gt;;    password server = &lt;nt-server-name&gt;&lt;br /&gt;&lt;br /&gt;# ----------------------- Domain Controller Options ------------------------&lt;br /&gt;#&lt;br /&gt;# Security must be set to user for domain controllers&lt;br /&gt;#&lt;br /&gt;# Backend to store user information in. New installations should&lt;br /&gt;# use either tdbsam or ldapsam. smbpasswd is available for backwards&lt;br /&gt;# compatibility. tdbsam requires no further configuration.&lt;br /&gt;#&lt;br /&gt;# Domain Master specifies Samba to be the Domain Master Browser. This&lt;br /&gt;# allows Samba to collate browse lists between subnets. Don&#39;t use this&lt;br /&gt;# if you already have a Windows NT domain controller doing this job&lt;br /&gt;#&lt;br /&gt;# Domain Logons let Samba be a domain logon server for Windows workstations.&lt;br /&gt;#&lt;br /&gt;# Logon Scrpit let yuou specify a script to be run at login time on the client&lt;br /&gt;# You need to provide it in a share called NETLOGON&lt;br /&gt;#&lt;br /&gt;# Logon Path let you specify where user profiles are stored (UNC path)&lt;br /&gt;#&lt;br /&gt;# Various scripts can be used on a domain controller or stand-alone&lt;br /&gt;# machine to add or delete corresponding unix accounts&lt;br /&gt;#&lt;br /&gt;;    security = user&lt;br /&gt;;    passdb backend = tdbsam&lt;br /&gt;&lt;br /&gt;;    domain master = yes&lt;br /&gt;;    domain logons = yes&lt;br /&gt;&lt;br /&gt;   # the login script name depends on the machine name&lt;br /&gt;;    logon script = %m.bat&lt;br /&gt;   # the login script name depends on the unix user used&lt;br /&gt;;    logon script = %u.bat&lt;br /&gt;;    logon path = \\%L\Profiles\%u&lt;br /&gt;   # disables profiles support by specifing an empty path&lt;br /&gt;;    logon path =&lt;br /&gt;&lt;br /&gt;;    add user script = /usr/sbin/useradd &quot;%u&quot; -n -g users&lt;br /&gt;;    add group script = /usr/sbin/groupadd &quot;%g&quot;&lt;br /&gt;;    add machine script = /usr/sbin/useradd -n -c &quot;Workstation (%u)&quot; -M -d /nohome -s /bin/false &quot;%u&quot;&lt;br /&gt;;    delete user script = /usr/sbin/userdel &quot;%u&quot;&lt;br /&gt;;    delete user from group script = /usr/sbin/userdel &quot;%u&quot; &quot;%g&quot;&lt;br /&gt;;    delete group script = /usr/sbin/groupdel &quot;%g&quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# ----------------------- Browser Control Options ----------------------------&lt;br /&gt;#&lt;br /&gt;# set local master to no if you don&#39;t want Samba to become a master&lt;br /&gt;# browser on your network. Otherwise the normal election rules apply&lt;br /&gt;#&lt;br /&gt;# OS Level determines the precedence of this server in master browser&lt;br /&gt;# elections. The default value should be reasonable&lt;br /&gt;#&lt;br /&gt;# Preferred Master causes Samba to force a local browser election on startup&lt;br /&gt;# and gives it a slightly higher chance of winning the election&lt;br /&gt;;    local master = no&lt;br /&gt;;    os level = 33&lt;br /&gt;;    preferred master = yes&lt;br /&gt;&lt;br /&gt;#----------------------------- Name Resolution -------------------------------&lt;br /&gt;# Windows Internet Name Serving Support Section:&lt;br /&gt;# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both&lt;br /&gt;#&lt;br /&gt;# - WINS Support: Tells the NMBD component of Samba to enable it&#39;s WINS Server&lt;br /&gt;#&lt;br /&gt;# - WINS Server: Tells the NMBD components of Samba to be a WINS Client&lt;br /&gt;#&lt;br /&gt;# - WINS Proxy: Tells Samba to answer name resolution queries on&lt;br /&gt;#   behalf of a non WINS capable client, for this to work there must be&lt;br /&gt;#   at least one    WINS Server on the network. The default is NO.&lt;br /&gt;#&lt;br /&gt;# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names&lt;br /&gt;# via DNS nslookups.&lt;br /&gt;&lt;br /&gt;;    wins support = yes&lt;br /&gt;;    wins server = w.x.y.z&lt;br /&gt;;    wins proxy = no&lt;br /&gt;&lt;br /&gt;;    dns proxy = no&lt;br /&gt;&lt;br /&gt;# --------------------------- Printing Options -----------------------------&lt;br /&gt;#&lt;br /&gt;# Load Printers let you load automatically the list of printers rather&lt;br /&gt;# than setting them up individually&lt;br /&gt;#&lt;br /&gt;# Cups Options let you pass the cups libs custom options, setting it to raw&lt;br /&gt;# for example will let you use drivers on your Windows clients&lt;br /&gt;#&lt;br /&gt;# Printcap Name let you specify an alternative printcap file&lt;br /&gt;#&lt;br /&gt;# You can choose a non default printing system using the Printing option&lt;br /&gt;&lt;br /&gt;   load printers = yes&lt;br /&gt;   cups options = raw&lt;br /&gt;&lt;br /&gt;;    printcap name = /etc/printcap&lt;br /&gt;   #obtain list of printers automatically on SystemV&lt;br /&gt;;    printcap name = lpstat&lt;br /&gt;;    printing = cups&lt;br /&gt;&lt;br /&gt;# --------------------------- Filesystem Options ---------------------------&lt;br /&gt;#&lt;br /&gt;# The following options can be uncommented if the filesystem supports&lt;br /&gt;# Extended Attributes and they are enabled (usually by the mount option&lt;br /&gt;# user_xattr). Thess options will let the admin store the DOS attributes&lt;br /&gt;# in an EA and make samba not mess with the permission bits.&lt;br /&gt;#&lt;br /&gt;# Note: these options can also be set just per share, setting them in global&lt;br /&gt;# makes them the default for all shares&lt;br /&gt;&lt;br /&gt;;    map archive = no&lt;br /&gt;;    map hidden = no&lt;br /&gt;;    map read only = no&lt;br /&gt;;    map system = no&lt;br /&gt;;    store dos attributes = yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#============================ Share Definitions ==============================&lt;br /&gt;&lt;br /&gt;[homes]&lt;br /&gt;   comment = Home Directories&lt;br /&gt;   browseable = no&lt;br /&gt;   writable = yes&lt;br /&gt;;    valid users = %S&lt;br /&gt;;    valid users = MYDOMAIN\%S&lt;br /&gt;&lt;br /&gt;[printers]&lt;br /&gt;   comment = All Printers&lt;br /&gt;   path = /var/spool/samba&lt;br /&gt;   browseable = no&lt;br /&gt;vss ok = yes&lt;br /&gt;   writable = no&lt;br /&gt;   printable = yes&lt;br /&gt;&lt;br /&gt;# Un-comment the following and create the netlogon directory for Domain Logons&lt;br /&gt;;    [netlogon]&lt;br /&gt;;    comment = Network Logon Service&lt;br /&gt;;    path = /var/lib/samba/netlogon&lt;br /&gt;;    guest ok = yes&lt;br /&gt;;    writable = no&lt;br /&gt;;    share modes = no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Un-comment the following to provide a specific roving profile share&lt;br /&gt;# the default is to use the user&#39;s home directory&lt;br /&gt;;    [Profiles]&lt;br /&gt;;    path = /var/lib/samba/profiles&lt;br /&gt;;    browseable = no&lt;br /&gt;;    vss ok = yes&lt;br /&gt;&lt;br /&gt;[vss]&lt;br /&gt;comment = control your source&lt;br /&gt;path = /usr/local/vss&lt;br /&gt;available = yes&lt;br /&gt;valid users = vss&lt;br /&gt;read only = no&lt;br /&gt;browseable = yes&lt;br /&gt;writable = yes&lt;br /&gt;#force user = nobody&lt;br /&gt;#force group = nobody&lt;br /&gt;#read only = No&lt;br /&gt;#guest ok = Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# A publicly accessible directory, but read only, except for people in&lt;br /&gt;# the &quot;staff&quot; group&lt;br /&gt;;    [public]&lt;br /&gt;;    comment = Public Stuff&lt;br /&gt;;    path = /home/samba&lt;br /&gt;;    public = yes&lt;br /&gt;;    writable = yes&lt;br /&gt;;    printable = no&lt;br /&gt;;    write list = +staff&lt;/nt-server-name&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/3498103791809559283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/samba-howto-collection-on-red.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/3498103791809559283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/3498103791809559283'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/samba-howto-collection-on-red.html' title='Samba-HOWTO-Collection on Red Hat Linux'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4565261699505124804.post-5740917345488182544</id><published>2010-10-14T09:47:00.000-07:00</published><updated>2010-10-14T09:48:01.981-07:00</updated><title type='text'>Adding New Drives to Linux Machine</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; &quot;&gt;&lt;h4&gt;&lt;i&gt;Adding New Drives&lt;/i&gt;&lt;/h4&gt;There are many reasons why you would need to add a new drive to your Linux box. You might have out-grown your current space limitations, or you may want to add a separate drive for a specific project or service. In any case, if you follow this guide, you should have no problems. First, you must be familiar with the naming scheme Linux uses for your drives. For purposes if this article, everything highlighted in &lt;span &gt;blue&lt;/span&gt; is the command you must type at the terminal prompt. Anything hightlighted in &lt;span &gt;red&lt;/span&gt; indicates changes made by a previous command or something you should pay special attention to. Anything highlighted in &lt;span &gt;green&lt;/span&gt; is simply the standard output from a terminal or issued command. The machine used for this guide is running &lt;a href=&quot;http://www.redhat.com/software/rhel/&quot; target=&quot;_blank&quot; style=&quot;color: rgb(0, 0, 204); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; text-decoration: underline; &quot;&gt;Red Hat Entperise Linux&lt;/a&gt;.&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;i&gt;Conventional Naming&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;This article assumes you know the difference between primary, extended and logical partitions. In the following example, I added a SCSI hard drive with one primary partition. With that being said, I&#39;ll continue explaining the naming scheme. Linux gives each drive a 3 letter name followed by a partition number. If you are using IDE drives, these will all be named &lt;em&gt;hd**&lt;/em&gt;. Where &lt;em&gt;hd&lt;/em&gt; denotes the drive and the next two variables are aassociated with IDE order (primary master, primary slave, etc) and partition number. So, your primary master drive will always be named &lt;em&gt;hda&lt;/em&gt;. If you are using SCSI drives, everything remains the same except instead of using &lt;em&gt;hd&lt;/em&gt;, drives are named &lt;em&gt;sd**&lt;/em&gt;. Your SCSI primary master drive will always be named &lt;em&gt;sda&lt;/em&gt;. All of these devices reside under the &lt;em&gt;/dev&lt;/em&gt; portion of your Linux file system. For instance, as root, you can issue the following command to view the naming combinations possible for your system. Remember, in this example, I am using SCSI hardware. If you are using IDE, simply use &lt;em&gt;hd&lt;/em&gt; is place of &lt;em&gt;sd&lt;/em&gt; here.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell root]# &lt;span &gt;ls /dev/sda*&lt;/span&gt; /dev/sda     /dev/sdab10  /dev/sdad12  /dev/sdaf14  /dev/sdah2   /dev/sdaj4   /dev/sdal6 /dev/sda1    /dev/sdab11  /dev/sdad13  /dev/sdaf15  /dev/sdah3   /dev/sdaj5   /dev/sdal7 /dev/sda10   /dev/sdab12  /dev/sdad14  /dev/sdaf2   /dev/sdah4   /dev/sdaj6   /dev/sdal8 /dev/sda11   /dev/sdab13  /dev/sdad15  /dev/sdaf3   /dev/sdah5   /dev/sdaj7   /dev/sdal9 /dev/sda12   /dev/sdab14  /dev/sdad2   /dev/sdaf4   /dev/sdah6   /dev/sdaj8   /dev/sdam /dev/sda13   /dev/sdab15  /dev/sdad3   /dev/sdaf5   /dev/sdah7   /dev/sdaj9   /dev/sdam1 /dev/sda14   /dev/sdab2   /dev/sdad4   /dev/sdaf6   /dev/sdah8   /dev/sdak    /dev/sdam10 ---- &lt;strong&gt;&lt;em&gt;Some results omitted**&lt;/em&gt;&lt;/strong&gt; ---- [root@roswell root]#  &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;Note that I omitted a large portion of the results because they were huge! Remember that this list is not dependent on the current number of hard drives in the system, but the maximum naming possibilities for any number of drives and partitions. Do not be surprised if your results are rather lengthy as well.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;&lt;i&gt;Creating, Mounting, and Configuration New Partitions&lt;/i&gt;&lt;/h4&gt;Before adding an extra drive, this machine had 2 physical drives. Both of them were named accordingly (sda and sdb) before the new drive was added. The second drive containing the swap partitions was automatically renamed when the new drive was added. Notice the command and output below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell root]# &lt;span &gt;df -h&lt;/span&gt; Filesystem            Size  Used Avail Use% Mounted on /dev/sda1             8.3G  2.4G  5.5G  30% / /dev/sda2              99M   26M   69M  27% /boot &lt;span &gt;/dev/sdc1              16G   13G  2.3G  85% /export  &lt;strong&gt;&lt;span &gt;&lt;-- old sdb renamed to sdc by the Linux&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt; none                  250M     0  250M   0% /dev/shm [root@roswell root]#  &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;This command simply lists all currently mounted drives, their names, and space usage. Notice that &lt;em&gt;sdb&lt;/em&gt; is not presently mounted. However, we know that it exists otherwise, there would not be an &lt;em&gt;sdc&lt;/em&gt; present. I could not add my new drive as sdc because my SCSI hotswap drive cage reserves the first two slots for 1.5&quot; drives. So I was forced to make the new drive &lt;em&gt;sdb&lt;/em&gt; because it is a 1.5&quot; drive.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;&lt;i&gt;Setting Partitions&lt;/i&gt;&lt;/h4&gt;You should be fairly familiar with fdisk. The commands are somewhat different than it&#39;s DOS equivalent. See the following commands and output:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell root]# &lt;span &gt;fdisk /dev/sdb&lt;/span&gt;  Command (m for help): &lt;span &gt;m&lt;/span&gt; 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&#39;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):   &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;If there is a problem, and there is no drive associated with /dev/sdb, you will get an error message. Remember, that nothing will actually be executed until you issue a &lt;em&gt;w&lt;/em&gt; command. It&#39;s always a good idea to read through the variables of your commands. Doing so will ensure that you aren&#39;t forgetting anything. Let&#39;s get started!&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; Command (m for help): &lt;span &gt;p&lt;/span&gt;  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):  &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;If you issue a &lt;em&gt;p&lt;/em&gt; command, you will see any partitions that currently exist on the drive. You can see by the output above there are no existing partitions. This drive is un-partitionedd and unformatted. To create a new partition, is the &lt;em&gt;n&lt;/em&gt; command.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; Command (m for help): &lt;span &gt;n&lt;/span&gt; Command action    e   extended    p   primary partition (1-4) &lt;span &gt;p&lt;/span&gt; Partition number (1-4): &lt;span &gt;1&lt;/span&gt; First cylinder (1-6081, default 1): &lt;span &gt;1&lt;/span&gt; Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): &lt;span &gt;6081&lt;/span&gt;  Command (m for help):  &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;In the output above notice that interval I selected for the cylinders. Using the entire range allows you create one partition across the entire drive. So, in order to create a primary partition on &lt;em&gt;/dev/sdb/&lt;/em&gt; we issued the following commands:&lt;ul&gt;&lt;li&gt;n&lt;/li&gt;(creates a new partition)&lt;li&gt;p&lt;/li&gt;(creates a primary partition)&lt;li&gt;1&lt;/li&gt;(the number 1 denotes the partition will be /dev/sdb&lt;strong&gt;1&lt;/strong&gt;)&lt;/ul&gt;We can check the partition specifications we just entered by using the &lt;em&gt;p&lt;/em&gt; command again.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; Command (m for help): &lt;span &gt;p&lt;/span&gt;  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 &lt;span &gt;/dev/sdb1             1      6081  48845601   83  Linux&lt;/span&gt;  Command (m for help):   &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;Notice the new partition (highlighted in red). However, we must issue a &lt;em&gt;w&lt;/em&gt; command to finalize it. If you messed anything up, you can use the &lt;em&gt;d&lt;/em&gt; command and specify which partition you want to delete.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; Command (m for help): &lt;span &gt;w&lt;/span&gt; The partition table has been altered!  Calling ioctl() to re-read partition table. Syncing disks. [root@roswell root]#  &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;&lt;h4&gt;&lt;i&gt;Formatting&lt;/i&gt;&lt;/h4&gt;Now that the partition has been created, you need to format the drive. You can format it with almost any file system you wish. However, the most common Linux formats are ext2 and ext3. Ext3 is simply a candy coated version of ext2 that adds a logging feature. You must specify which partition to format by calling the device and partition number like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell root]# &lt;span &gt;mkfs -t ext3 /dev/sdb1&lt;/span&gt; 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. [root@roswell root]#   &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;What did we do there? Using the mkfs (make file system) command, we specified the type (using the -t) ext3 using the device and partition name (/dev/sdb1). You have successfull partitioned and formatted your new drive. Wait, you&#39;re not done yet. You will want to mount this partition to make it usable. You will also want this partition to mount automatically when you reboot the machine.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;&lt;i&gt;Mounting&lt;/i&gt;&lt;/h4&gt;In order to automatically mount a partition, you must edit the &lt;em&gt;/etc/fstab&lt;/em&gt; file. The fstab file tells Linux where to mount all partitions located within the system. The output below shows the current fstab file before including the newly added drive:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell root]# &lt;span &gt;vi /etc/fstab&lt;/span&gt; LABEL=/                 /                       ext3    defaults        1 1 LABEL=/boot             /boot                   ext3    defaults        1 2 none                    /dev/pts                devpts  gid=5,mode=620  0 0 LABEL=/export           /export                 ext3    defaults        1 2 none                    /proc                   proc    defaults        0 0 none                    /dev/shm                tmpfs   defaults        0 0 /dev/sdb2               swap                    swap    defaults        0 0 /dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0 /dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0 &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;You may notice I viewed this file using vi. Vi is a simple text editor that may or may not be loaded on your Linux system. It is somewhat similar to emacs. In any case, both programs can perform the same task. We will mount the new partition as &lt;em&gt;/media&lt;/em&gt;. Remember to create a directory named media, otherwise fstab won&#39;t be able to mount the partition. It is shown high-lighted red in the output below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; LABEL=/                 /                       ext3    defaults        1 1 LABEL=/boot             /boot                   ext3    defaults        1 2 none                    /dev/pts                devpts  gid=5,mode=620  0 0 LABEL=/export           /export                 ext3    defaults        1 2 none                    /proc                   proc    defaults        0 0 none                    /dev/shm                tmpfs   defaults        0 0 &lt;span &gt;/dev/sdb1               /media                  ext3    defaults        1 2&lt;/span&gt; /dev/sdb2               swap                    swap    defaults        0 0 /dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0 /dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0 &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;Next, issue a simple mount command providing the partition name:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell export]# &lt;span &gt;mount /dev/sdb1&lt;/span&gt; [root@roswell export]# &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;You&#39;re all done! You will be able to access the /media folder immediately &lt;em&gt;and&lt;/em&gt; after the machine reboots as fstab will automatically re-mount it for you. If you want to verify the partition is successfully present and mounted, use the following commands:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell media]# &lt;span &gt;mount&lt;/span&gt; /dev/sda1 on / type ext3 (rw) none on /proc type proc (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) usbdevfs on /proc/bus/usb type usbdevfs (rw) /dev/sda2 on /boot type ext3 (rw) /dev/sdc1 on /export type ext3 (rw) none on /dev/shm type tmpfs (rw) &lt;span &gt;/dev/sdb1 on /media type ext3 (rw)&lt;/span&gt; [root@roswell media]#  &lt;/span&gt;&lt;/pre&gt;&lt;span &gt;&lt;/span&gt;&lt;br /&gt;The red line shows our new drive freshly mounted. You can check the space usage if you issue the following command.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span &gt; [root@roswell media]# &lt;span &gt;df -h&lt;/span&gt; Filesystem            Size  Used Avail Use% Mounted on /dev/sda1             8.3G  2.4G  5.5G  30% / /dev/sda2              99M   26M   69M  27% /boot /dev/sdc1              16G   13G  2.3G  85% /export none                  250M     0  250M   0% /dev/shm &lt;span &gt;/dev/sdb1              46G   33M   44G   1% /media&lt;/span&gt; [root@roswell media]# &lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adding-a-hard-drive-in-linux.blogspot.com/feeds/5740917345488182544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/adding-new-drives-to-linux-machine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/5740917345488182544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4565261699505124804/posts/default/5740917345488182544'/><link rel='alternate' type='text/html' href='http://adding-a-hard-drive-in-linux.blogspot.com/2010/10/adding-new-drives-to-linux-machine.html' title='Adding New Drives to Linux Machine'/><author><name>paksnaps</name><uri>http://www.blogger.com/profile/10668120190512071338</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>