Pages

Saturday, February 8, 2025

How to check the ftp service running on Linux?

 To check if the FTP service is running on a Linux system, you can use various commands to verify the service's status, associated ports, and process. Here's how you can do it:

 

1. Check the Status of the FTP Service

The FTP service on Linux is typically provided by servers like vsftpd, ProFTPD, or pure-ftpd.

Using systemctl:

sudo systemctl status vsftpd

Replace vsftpd with the name of the FTP server you use (e.g., proftpd or pure-ftpd).

If the service is running, you’ll see active (running) in the output.

If not, it might show inactive or failed.

 

2. Check for Listening Ports

FTP typically uses port 21 for control and port 20 for data transfer in active mode.

Using netstat:

sudo netstat -tuln | grep 21

Using ss:

sudo ss -tuln | grep 21

Expected Output:

You should see an entry like:

tcp    LISTEN  0      50     0.0.0.0:21       0.0.0.0:*  

This indicates the FTP service is listening on port 21.

 

3. Check for Running Processes

You can verify if the FTP server process is running using ps or pgrep.

Using ps:

ps aux | grep ftp

Using pgrep:

pgrep -l ftp

If the service is running, you will see the process name (e.g., vsftpd, proftpd, or pure-ftpd).

 

4. Check the FTP Server Logs

The log files can indicate if the service is running and handling connections.

Log File Locations:

vsftpd: 

sudo tail -f /var/log/vsftpd.log

ProFTPD: 

sudo tail -f /var/log/proftpd/proftpd.log

pure-ftpd: 

sudo tail -f /var/log/messages | grep pure-ftpd

 

5. Test the FTP Service

You can test the FTP service by attempting to connect to it.

Using ftp Command:

ftp localhost

Using telnet or nc:

telnet localhost 21

# or

nc -vz localhost 21

If the service is running, you’ll see a response similar to: 

220 (vsFTPd 3.0.3)

If not, you’ll get a connection refused or timeout message.

 

6. Ensure FTP is Installed

If the service is not running or not found, ensure an FTP server is installed on your system.

Check Installed FTP Server:

dpkg -l | grep ftp       # On Debian/Ubuntu

rpm -qa | grep ftp       # On RHEL/CentOS

Install an FTP Server (e.g., vsftpd):

sudo apt install vsftpd      # On Debian/Ubuntu

sudo yum install vsftpd      # On RHEL/CentOS

 

By following these steps, you can determine whether the FTP service is running and troubleshoot any issues if it is not. 


No comments:

Post a Comment