Administration

How to start or stop or restart a service in Fedora/RHEL/Ubuntu/Debian Linux

The following examples show how to start or stop or restart a service in different flavours of Linux. In all these examples, the service name “httpd” is used. You can replace it with name of the service you want to start or stop or restart.

Starting a service

In RHEL or Fedora:

[root@techpulp ~]# service httpd start

or

[root@techpulp ~]# /etc/init.d/httpd start

In Debian Linux:

[root@techpulp ~]# /etc/init.d/httpd start

In Ubuntu Linux:

[root@techpulp ~]# sudo /etc/init.d/httpd start
Stopping a service

In RHEL or Fedora:

[root@techpulp ~]# service httpd stop

or

[root@techpulp ~]# /etc/init.d/httpd stop

In Debian Linux:

[root@techpulp ~]# /etc/init.d/httpd stop

In Ubuntu Linux:

[root@techpulp ~]# sudo /etc/init.d/httpd stop
Restarting a service

In RHEL or Fedora:

[root@techpulp ~]# service httpd restart

or

[root@techpulp More >

How to scan a host for open ports in Linux

It is better to scan the server once to detect any unwanted services. It helps in harden the security of the server and minimizes security threats. Linux provides a command nc command to scan the open ports on a host. Typically it comes with default installation. If not, you can use following command to install it.

yum -y install nc

To scan a host with IP address “172.16.5.20″ for ports ranging from 1 to 1023, use the following command.

[neo@techpulp ~]# nc -z 172.16.5.20 1-1023
Connection to 172.16.5.20 80 port [tcp/http] succeeded!
Connection to 172.16.5.20 443 port [tcp/ssh] succeeded!
Connection to 172.16.5.20 904 More >

How to recover a corrupted RPM database

If the previous installation attempt is terminated abruptly or failed due to unexpected error, the rpm tool fails to remove database locks. Then on, attempt of a new rpm installation fails due to the stale database locks.

In the worst case scenario, rpm command misbehaves like hangs, segmentation faults. In all these cases, you should first manually remove any stale locks present in “/var/lib/rpm” directory.

[root@techpulp ~]# rm -f /var/lib/rpm/__db*

If you still face the same problem, your rpm database is corrupted and it is time to rebuild or repair your database. However beforeyou attempts to rebuild the database, you must first take More >

How to mount file system using SSH in Linux

Here is a cool way of mounting file system from the remote SSH server in the local system. The user space file system implementation “Fuse” makes it possible.

You need to install package “sshfs” in your system as shown below.

[root@techpulp ~]# yum -y install sshfs
fedora                                                                         | 2.8 kB     00:00
updates                                                                        | 3.4 kB     00:01
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package fuse-sshfs.i386 0:2.2-5.fc10 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================
Package                   Arch                Version                   Repository              Size
======================================================================================================
Installing:
fuse-sshfs                i386                2.2-5.fc10                updates                 49 k

Transaction Summary
======================================================================================================
Install      More >

How to disable HTTPS or SSL in Apache server

If your web server is not hosted using a dedicated IP address and doesn’t have a security certificate, it is implicit that you can’t host HTTPS service. In such cases, it is always better to disable HTTPS service so that there won’t be any unwanted service running in the server.

Use the following command to find if Apache is listening on HTTPS port.

[root@techpulp ~]# netstat -ntl | grep 43
tcp        0      0 :::443                      :::*                        LISTEN
[root@techpulp ~]#

To disable Apache from enabling HTTPS service, you need to comment the following line in /etc/httpd/conf.d/ssl.conf file.

#Listen 443

You need to restart the service to make the More >