How to extract a Single File From a Large Tar file.

I’ve a large tar files such as images.tar.gz. Is it possible to extract a single file or a list of files from a large tarball such as justgeek.img instead of extracting the entire tarball? How do I extract specific files under Linux / UNIX operating systems?

Extracting Specific Files

Extract a file called etc/default/sysstat from config.tar.gz tarball

If you don’t know the exact location in tar file then you can first use the -tvf option to see the contents of tar file without extracting it.

[root@justgeek~]# tar -tvf config.tar.gz

Then you can use the following command to extract file.

[root@justgeek~]# tar -xvf {tarball.tar} {path/to/file}


[root@justgeek~]# tar -xvf config.tar.gz etc/default/sysstat

How to extract a Single Folder from tar file.

[root@justgeek~]# tar -zxvf config.tar.gz -C /tmp filename


[root@justgeek~]# tar -zxvf config.tar.gz -C /tmp folder-name

Read tar man page for more information:

man tar

Read More

How to extract one table from MySQL dump file.

Restoring a MySQL backup is not much tedious when the database size is small, but it’s a frustrating job when it comes to restoring a very large database.

I had a scenario, where I wanted to restore a single table from a very large database and it’s I was getting all sorts of time-out errors. After playing a lot I found a script which extracted the databases to separate SQL files of each table. Which made my life easy.

You can download script here.

Script Usage.

To Extract all tables as a separate file from dump.

[root@justgeek~]# sh DUMP-FILE-NAME

To Extract single table from dump.

[root@justgeek~]# sh DUMP-FILE-NAME TABLE-NAME

To Extract tables from dump for specified regular express

[root@justgeek~]# sh DUMP-FILE-NAME -S TABLE-NAME-REGEXP

Read More

How to optimize Apache.

The default Apache settings that cPanel sets upon install are definitely something that needs to modified. With little changes in that you can achieve great performance.

Note: The settings provided below are based on Linux cPanel server.

To start, open the Apache configuration file. On a cPanel server, it will be located in /usr/local/apache/conf/.

[root@host /] vim /etc/httpd/conf/httpd.conf

This list is a composite of the settings we will be reviewing from fresh install on a cPanel server:

Timeout 300
KeepAlive On
MaxKeepAliveRequests 150
KeepAliveTimeout 5
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0


Timeout 300

Usually this value doesn’t require editing and a default of 300 is sufficient. Lowering the ‘Timeout’ value will cause a long running script to terminate earlier than expected.


KeepAlive On

This setting should be “On” unless the server is getting requests from hundreds of IPs at once. High volume and/or load balanced servers should have this setting disabled (Off) to increase connection throughput.


MaxKeepAliveRequests 100

This setting limits the number of requests allowed per persistent connection when KeepAlive is on. If it is set to 0, unlimited requests will be allowed. It is recommended to keep this value at 100 for virtualized accounts like VPS accounts. On dedicated servers it is recommended that this value be modified to 150.


KeepAliveTimeout 15

The number of seconds Apache will wait for another request before closing the connection. Setting this to a high value may cause performance problems in heavily loaded servers. The higher the timeout, the more server processes will be kept occupied waiting on connections with idle clients. It is recommended that this value be lowered to 5 on all servers.


MinSpareServers 5

This directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer spareservers idle then specified by this value, then the parent process creates new children at a maximum rate of 1 per second. Setting this parameter to a large number is almost always a bad idea.


MaxSpareServers 10

The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes.

The MaxSpareServers value should be set as double the value that is set in



StartServers 5

This directivesets the number of child server processes created on startup. This value should mirror what is set in MinSpareServers.


MaxClients 150

This directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the specified limit will be queued. Once a process is freed at the end of a different request, the queued connection will then be served.

For virtualized servers such as VPS accounts, it is recommended to keep this value at 150. For all dedicated servers the recommended value for this setting is 250.


MaxRequestsPerChild 0

This directive sets the limit on the number of requests that an individual child server process will handle. After the number of requests reaches the value specified, the child process will die. When this value is set at 0, then the process will never expire.

Read More