lsmod: list a modules that are currently loaded
rmmod: remove a module from the Linux kernel
Configure network interface:
ifconfig eth_name ip_address netmask network_mask broadcast broadcast address
ifconfig eth0 192.168.0.23 netmask 255.255.255.0 broadcast 192.168.0.255
check the ip address and mask of an interface:
Fedora add the info to
Ubuntu in the
To get the ipaddress from the DHCP: use the line “iface eth0 inet dhcp”
Use static : iface eth0 inet static , then add another line use format like:
ifdown eth0 , then
ifup eth0 to load the configuration file.
how to disable IPv6 on Red Hat- and Debian-based distributions.
Here’s how to disable the protocol on a Red Hat-based system:
Open a terminal window.
Change to the root user.
Issue the command
sysctl -w net.ipv6.conf.all.disable_ipv6=1
Issue the command
sysctl -w net.ipv6.conf.default.disable_ipv6=1
To re-enable IPv6, issue the following commands:
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0
Host file (cache): /etc/hosts
add DNS server into your system:
/etc/resolv.conf file. older Linux, the
/etc/host.conf file used.
This file can contain up to 3 DNS servers.
If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file
/etc/resolv.conf. In general, editing
/etc/resolv.conf directly is not recommended, but this is a temporary and non-persistent configuration. The example below shows how to enter two DNS servers to
/etc/resolv.conf, which should be changed to servers appropriate for your network.
The format is like:
search example.com local.lan nameserver 127.0.0.1 nameserver 172.16.1.254 nameserver 172.16.2.254
A more proper persistent way to do DNS client configuration is in a following section.
Stands for Domain Information groper, Dis is an excellent tool to do an DNS query .
basic command is like:
For more complex use, check here:
To see the
route table, use route command, or
netstat -r command.
Enable routing ( IP forwarding ):
change the value in the file
/proc/sys/net/ipv4/ip_forward into 1:
echo 1 > /proc/sys/net/ipv4/ip_forward
IPv4 routing at every boot,ensure that the line
net.ipv4.ip_forward = 1 exists in the
Add a route:
route add -net network_address netmask network_mask gw gateway_address
route add -net 10.0.1.0 netmask 255.255.255.0 gw 10.0.1.1
ip route add network_address/mask_length via gateway_addgess
ip route add 10.0.1.0/24 via 10.0.1.1
delete a route:
route del network_address
Ports and their associated protocols are defined in the
To see which port the telnet daemon listens, use
grep telnet /etc/services
Ports range in number from 0 to 65534. The ports 0–1023 are called well-known ports.
Two kinds of network daemons:
- Stand-alone daemons: Daemons that provide the network services directly.
- Smaller network daemons: connections are started and managed by the inetd or xinetd daemons, which starts the appropriate daemon inorder to provide the network service as needed.
- inetd ( Internet Super Daemon)
- xinetd ( Extended Internet Super Daemon.
we can check the network state with netstat command：
The most common switches include:
（1） show network interface info:
（2） show the active internet connections and socket of the server:
Include the Program name, PID, I-node.
（3） show routing table info
（4） show tcp or udp connection info:
Telnet : By default Root user is prevented from logging in and obtaining a shell, to enable this. Removing or renaming the file
encrypt the information that passes between computers.
ssh -l username IP_address(or url)
First time to use SSH: Accept the RSA encryption fingerprint, which is stored in
If the target computer’s encryption keys are regenerated, you will need to remove the old key from the ~/.ssh/known_hosts file before you connect again.
The –X option to the ssh command can be used to tunnel X Windows information through the SSH connection.
sshd is usually configured to allow root logins and a wide range of encryption algorithms by default. However,you can configure the functionality of sshd by editing the
Under command line, the most popular download tools are wget and curl.
The result is a singlefile. On its own this file is fairly useless as the content is still pulled from Google and the images and stylesheets are still all held on Google.
To download the full site and all the pages you can use the following command:
This downloads the pages recursively up to a maximum of 5 levels deep.
5 levels deep might not be enough to get everything from the site. You can use the -l switch to set the number of levels you wish to go to as follows:
wget -r -l5
If you want infinite recursion you can use the following:
wget -r -l inf
You can also replace the inf with 0 which means the same thing.
Send Mail from command
First of all, check if the /bin/mailx or /usr/bin/mailx file exist or not. Or else, you need to install it:
# ubuntu/debian $ sudo apt-get install heirloom-mailx # fedora/centos $ sudo yum install mailx
Run the following command, and then mailx would wait for you to enter the message of the email. You can hit enter for new lines. When done typing the message, press Ctrl+D and mailx would display EOT.
After than mailx automatically delivers the email to the destination.
$ /bin/mail -s "Subject" email@example.com Hi! How are you I am fine Bye [ctrl+D to send] EOT
echo ” The mail body” | mailx -v -r “firstname.lastname@example.org” -s “Test Message” -S smtp=”smtp.smtp_server_domain.com:port” -S smtp-auth=plain -S smtp-auth-user=”sender” -S smtp-auth-password=”xxxxx” recepient@target_domain.com
- -v : show the process verbosely
- -r: sender email
- -s: title
- -S: parameters
Specify “Reply-To” address
The reply to address is set with the internal option variable “replyto” using the “-S” option.
# replyto email $ echo "This is message" | mail -s "Testing replyto" -S replyto="email@example.com" firstname.lastname@example.org # replyto email with a name $ echo "This is message" | mail -s "Testing replyto" -S replyto="Mark<email@example.com>" firstname.lastname@example.org
Attachments can be added with the “-a” option.
$ echo "This is message body" | mail -s "This is Subject" -r "Harry<email@example.com>" -a /path/to/file firstname.lastname@example.org
For more use, check here: