Question: How can I get my Linux server rebooted/restarted automatically if it caught a kernel panic?
Answer: As you might know, kernel panic is an action taken by an operating system upon detecting an internal fatal error from which it cannot safely recover; the term is largely specific to Unix and Unix-like systems (it’s a wiki’s description).
By default Linux wouldn’t not reboot after panic occurs, but the following option of sysctl will cause a kernel to reboot after N seconds you specify. In our example server will be rebooted in 15 seconds if kernel panic stopped its operation:
1. Open sysctl’s configuration file:
sudo nano /etc/sysctl.conf
2. Add there the following line:
kernel.panic = 15
or
1. Execute the following command:
/sbin/sysctl -w kernel.panic=15
Hope it helps!
Question: How can I disable building of directory index in apache/httpd? In other words, how to prevent users from seeing the contents of published directories?

Answer: Actually you are totally right that you wish to disable this feature. One of the “must do’s” on setting a secure apache web server is to disable directory browsing. Usually apache comes with this feature enabled but its always a good idea to get it disabled unless you really need it.
First of all find where is the main apache’s config file httpd.conf is located. If you use Debian, it should be here: /etc/apache/httpd.conf. Using some file editor like Vim or Nano open this file and find the line that looks as follows:
Options Includes Indexes FollowSymLinks MultiViews
then remove word Indexes and save the file. The line should look like this one:
Options Includes FollowSymLinks MultiViews
After it is done, restart apache (e.g. /etc/init.d/apache restart in Debian). That’s it!
Question: I want to select APT repository server/mirror that is fastest for my location. How can I do it in Debian?
Answer: You can use application named as “netselect-apt” to get new sources.list file with fastest APT mirror. Install this application by command "sudo aptitude install netselect-apt" and run it in accordance with Debian distribution you use (Debian Etch in our example):
sudo netselect-apt -n etch -o /etc/apt/sources.list
sudo apt-get update
P.S. By the way, in Ubuntu you can do the same in a few clicks.
Question: I want to reset counters in /proc/net/dev (also shown in ifconfig output as RX and TX bytes) and thus I have to unload network interface driver. How to do it?
Answer: There are two commands in Linux CLI coming by default which would help to unload drivers: rmmod and modprobe. First of all it is necessary to find what kernel module controls certain NIC and then unload that module. For example, you have VIA VT6102 (RHINE-II) network card that is recognized by Linux as eth0 and want to disable its driver temporarily. Just execute the following:
“sudo rmmod via-rhine” or “sudo modprobe -r eth0” (or “sudo modprobe -r via-rhine“). You can use command dmesg to determine the name of kernel module you wish to unload.
Question: How can I restrict/allow access to certain service on timely basis with iptables? For example restrict access to SSH between 7:00 pm – 8:00 am on weekdays?
Answer: You are welcome to use iptables patch-o-matic extension (pom or p-o-m) that allows you to match a packet based on its arrival or departure (for locally generated packets) timestamp. The syntax is the following:
iptables RULE -m time --timestart TIME --timestop TIME --days DAYS -j ACTION
Where:
--timestart TIME: Time start value (format is 00:00-23:59)
--timestop TIME: Time stop value (the same format)
--days DAYS: a list of days to apply, from (format: Mon, Tue, Wed, Thu, Fri, Sat, Sun).
To add the rule stated in the question use the following command:
iptables -A INPUT -p tcp -d 192.168.0.1 --dport 22 -m time --timestart 19:00 --timestop 8:00 -days Mon,Tue,Wed,Thu,Fri -j DROP
Hope it helps!
Recent Ideas