Find Out What Process is Listening on a Specific TCP Port

There are two commands which are popular to get the result: netstat and lsof. We probably already have been familiar with

netstat -nlp

to list all the listening ports. We actually could do

lsof -Pnl +M -i4

to list all IPv4 ports or

lsof -Pnl +M -i6

to list all IPv6 ports as well.

Static IP Configuration in CentOS

For example, to configure the IP of eth0, edit the file /etc/sysconfig/network-scripts/ifcfg-eth0

## Configure eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="System eth0"
IPADDR= # Replace with your ip address
## Configure Default Gateway
# vi /etc/sysconfig/network

And then restart the network interfaces by

/etc/init.d/network restart

Optionally, configure the DNS servers by editing the file /etc/resolv.conf

## Configure DNS Server
# vi /etc/resolv.conf
nameserver # Replace with your nameserver ip
nameserver # Replace with your nameserver ip

Reset iptables / Clear / Remove all iptables rules

iptables has many different tables. In order to reset it or remove all rules of it, you need to run a series of commands like below:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -t raw -F
iptables -t raw -X
iptables -P INPUT ACCEPT

Don’t forget to save your iptables configuration. However, you have another option to do it easily and permanently by running the following command:

> /etc/sysconfig/iptables

And then restart the iptables service. All the rules will go away.

How to delete user password in Linux?

How do I delete user Password under Linux? I’d like to disable a password for an account.

After Google, I’ve found the solution.

All user encrypted passwords are stored in /etc/shadow file. The quick way to remove/delete a user password is pass –delete option to passwd command. First, login in as a root user.

Command to delete user password under Linux

Type the following command to delete a user password:

# passwd --delete username


# passwd -d username

Above command delete a user’s password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless. User will not able to login. It is also a good idea to setup user shell to nologin to avoid security related problems:

# usrmod -s /sbin/nologin username

For example to delete password for user vivo, Type:

# passwd -d vivo
# usrmod -s /sbin/nologin vivo