Interesting facts about Linux...
How do I restart Linux netword service ?
RedHat Linux command to reload or restart network (login as root user):
# service network restart
OR
# /etc/init.d/network restart
To start Linux network service:
# service network start
To stop Linux network service:
# service network stop
How to restart inetd and xinetd service under Linux ?
inetd is a daemon on Linux (BSD/Unix) systems that manages Internet services. inetd listens on all ports used by internet services such as FTP, POP3, and telnet. When a TCP packet or UDP packet comes in with a particular port number, inetd launches the appropriate server program to handle the connection. This uses memory more efficiently, as the other daemons do not run constantly.
Under old version of RedHat Linux you can restart inetd (login as root user):
# killall -HUP inetd
Note above command should work with almost any Linux distrobution.
New version of RedHat Linux (Fedora) comes with xinetd daemon, which can be restarted as follows:
# service xinetd restart
How to reset the transmitted and received bytes counters for network interface card under FreeBSD and Linux w/o rebooting system.
You need to remove driver related to Ethernet card. Under Linux use following commands:
1) Find out driver attached to eth0 using following command
lsmod | less
2) Remove the driver using rmmod command:
rmmod driver-name
3) Again insert driver into kernel using
modprobe driver-name
An example, let us assume your driver name is 8139too , then your command should be (log in as root user):
# rmmod 8139too
# modprobe 8139too
Verify that RX and TX couters reset:
ifconfig
Under FreeBSD use following commands:
Get list of loaded drivers, and find out ID of device driver related to Ethernet
# kldstat
Remove driver
# kldunload driver-ID
Load driver into kernel:
# kldload -v driver-name
Don't try this command on remote server via telnet or ssh, at it will take down your connection.
How to install JRE (java run time) under Linux Firefox browser?
First visit Sun java site and http://www.java.com latest JRE for Linux.You can download RPM or self-extracting file. All the information to install JRE is on same page, just follow it.Once you downloaded and installed the JRE, you need to restart FireFox.
Exploring Linux Kernel
Here are some interesting facts about running Linux kernel. Following information is quite useful if you are planning to compile your own custom kernel
But where is my kernel stored?
Your compiled kernel is always installed in /boot directory:
Here is listing of all installed kernel in my system (filename -> description)
$ ls -l /boot/
config-2.6.12-1-386 –> Kernel configuration file generated by make menuconfig/make xconfig/make gconfig
System.map-2.6.12-1-386 –> This file has a map of positions of symbols in the kernel. Device driver such as USB pen uses hot plug, which depend upon symbols generated by depmod utility
vmlinuz-2.6.12-1-386 — > Actual Kernel file
initrd.img-2.6.12-1-386 –> Contains device drivers which are required to boot and load rest of operating system from disk. Usually SCSI and IDE drivers are stored in this file
grub –> It is a directory, which stores grub Boot loader configuration file
config –> Soft link to current kernel configuration file
vmlinuz -> Soft link to current running kernel file
System.map –> Soft link to current running kernel system map file
But what is 2.6.12 … yup you are right it is kernel version
How do I find out version of running Linux kernel?
Use any one of the following command:
uname -r
OR
cat /proc/version
How do I find out where running kernel modules (device drivers) are stored?
Use any one of the following command:
ls /lib/modules/$(uname -r)
ls -d /lib/modules/$(uname -r)
How do I load kernel modules at boot time?
/etc/modules file should contain the names of kernel modules that are
to be loaded at boot time, one per line.
$ cat /etc/modules
How do I install latest binary kernel?
Find out if latest version available or not via following command
apt-cache search kernel-image| grep VERSION
An example to see if 2.6.xx.xx series new kernel available or not (Debian Linux):
apt-cache search kernel-image| grep 2.6
Compare version with existing running kernel if it is greater than running kernel, run following command to install new kernel (run it as a root user and assuming that 2.6.12.1 is latest the kernel available):
apt-get install linux-image-2.6.12-1-386
Difference between monolithic and Modular kernel:
Monolithic kernel
Single binary file [ directory ls -d /lib/modules/$(uname -r) does NOT exists ]
All drivers included in kernel itself
Modular kernel
Multiple files for kernel
Drivers can be loaded or unloaded into kernel using modprob command, see man page of
lsmod, modprob etc [directory ls -d /lib/modules/$(uname -r) exists to store drivers]
Almost all drivers are build and linked against kernel
How Do I build modular kernel?
You can built modular kernel by setting option in kernel configuration option:
Enable loadable module support (CONFIG_MODULES) [Y/n/?]
If you set above option to Y then kernel becomes modular and three possibilities occurs for each and every feature/driver:
m - you can compile driver as module
y - built into kernel itself
n - Don't include feature/driver
Type command make menuconfig
make menuconfig
How do I restart MySQL server ?
Each distribution of Linux comes with shell script to restart mysql server. First login as root user and open shell prompt (command prompt).
A) If you are using mysql on RedHat Linux (Fedora) then use following command:
* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
etc/init.d/mysqld stop
To restart mysql server
/etc/init.d/mysqld restart
Redhat Linux also supports service command, which can be use to start, restart, stop any service:
service mysqld start
service mysqld stop
service mysqld restart
How do I remote reboot linux system ?
If you are using any Linux distro or even FreeBSD or other UNIX like Os then remote reboot of linux or UNIX system can be done as follows:
A) Login to remote server using ssh as root user and use any one of the following syntax:
shh root@remote-server-ip
OR
shh root@remote-server-name
When prompted for password please supply remote server root password.
B) Type reboot command as follows:
reboot
An example of Remote reboot of linux system called webserver.nixcraft.net (IP 202.54.10.20)
1) Type ssh command
shh root@webserver.nixcraft.net
When prompted for password please supply remote server root password.
2) Type reboot command:
reboot
Hot tip you can also save time using following reboot hack linux command:
ssh root@202.54.10.20 reboot
ssh root@webserver.nixcraft.net reboot
Halt Linux Firewall
You would like to Halt linux firewall or stop linux firewall (i.e. flush iptables rules). First login as root user:
Option A - If you are redhat Linux user type command:
/etc/init.d/iptables stop
OR
service iptables stop
Option B - If you are Debian Linux user type following commands one by one:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
Divya Dutta
Level 5th, Cyber Green, Tower c,
Sector 25, DLF City III, Gurgaon
Email:duttadivya2002@yahoo.co.in
(Life is Short and Sweet, so make others happy and never let anyone down)
