I can use command sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist to start TFTP Server on mac. But what is the process name of the running TFTP server?

I tried ps aux | grep tftp and pgrep tftp, neither give me anything...

My goal is to use script to track if tftp server has been turned on OR not...

  • What di you mean by " if tftp server has been turned on OR not" ? It is turned on if the plist does not include the Disables key - but that does not mean it has run just that if another process tried to use it would run if there was such a process – user151019 Jul 25 '16 at 18:49
  • Please don't add answers directly to the question text, it confuses both users and search engines. You can post it as an answer to your own question though. – nohillside Jul 25 '16 at 20:00

I wrote a script for that purpose if you care to use it. The usage for TFTP would be as follows.

sudo what-listens.sh -p 69

You might be surprised to find that it shows launchd instead of the actual TFTP process. The service needs to be running to see the actual TFTP process, and launchd is probably managing that service.

if [[ "$EUID" -ne 0 ]]; then
    echo 'This script must be run as root.' 1>&2
    exit 1


function port() {
    if [[ "$?" -eq 1 ]]; then
        echo "There is no program listening on port $PORT."

function usage() {
    echo "Usage: $0 [-p,--port <port> ]"

case "$1" in
        echo "Error: unknown parameter: '$1'."

if [[ $B_NEED_ARG -eq 1 ]] ; then
    if [[ -z "$2" ]] ; then
        echo "Error: option '$1' requires an argument."
        exit 1
        if ! [[ "$2" =~ ^[0-9]+$ ]]; then
            echo "Error: argument to '$1' option must be an integer."
            exit 1

${FUNCTION} "$2"

unset CMD_SUDO
unset CMD_LSOF
unset CMD_GREP
unset B_NEED_ARG
unset PORT

I see the question was modified with...

My goal is to use script to track if tftp server has been turned on OR not...

This solution below was working up to Mavericks, 10.9, and probably works up to El Capitan, 10.11.6; but, I have not actually tried it on a Mac with a version higher than 10.9. To disable a service:

sudo defaults write /private/var/db/launchd.db/com.apple.launchd/overrides.plist 'com.apple.tftpd' -dict Disabled -bool true

It can then be checked:

sudo /usr/libexec/PlistBuddy -c 'print com.apple.tftpd:Disabled' /private/var/db/launchd.db/com.apple.launchd/overrides.plist

If the return value is not 'true', then the service is not disabled.

  • Thanks thats what am I looking for and I also added a simple and dirty script I wrote for my needs :) – m1xed0s Jul 25 '16 at 19:52

The short answer is that there is no running process

You need to look ay the plist in more detail (and probably read Apple's documentation on Launch Agents and Daemons.

What the plist for tftp does is provides a list of sockets the agent listens on.

When someone talks to the socket listed in the plist launchd will realise that the program listed in the plist, /usr/libexec/tftpd, is needed and start it.

So until something talks to the socket the agent is not running and I think as the agent is intend compatible it will shout down when the socket is closed. When the socket is open there will be a process /usr/libexec/tftpd running

  • This makes sense...but even there is no socket opened for TFTPD, there is still a file named tftpd under /usr/libexec/ folder...Any other method I could use to track if the TFTP is turned on or not? – m1xed0s Jul 25 '16 at 18:11
  • @m1xed0s you can use lsof, as shown in the script posted by Christopher – nohillside Jul 25 '16 at 18:16
  • It is turned on if the Disabled key in the pList is removed or you start a press that talks to tftpd and see if it can talk to the service – user151019 Jul 25 '16 at 18:26


As inspired by @Christopher, Here is the simple and dirty script I wrote to meet my needs :)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys,os

my_pid = os.system("sudo lsof -n -i4UDP:69 > /dev/null 2>&1")

if len(sys.argv) == 1:
    if my_pid == 0:
        print 'TFTP Server is already turned on.'
        print "Parameter (start/stop) is required to turn on/off TFTP Server!"
elif len(sys.argv) > 2:
    print "Only One Parameter (start/stop) is acceptable!"
    cmdarg = str(sys.argv[1])

    if cmdarg == 'start':
        if my_pid == 0:
            print 'TFTP Server is already turned on, No Action!'
            os.system("sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist")
            os.system("sudo chmod 777 /private/tftpboot")
            print 'TFTP Server been Started.'
    elif cmdarg == 'stop':
        if my_pid == 0:
            os.system("sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plist")
            os.system("sudo chmod 755 /private/tftpboot")
            print "TFTP Server has been Stopped."
            print "TFTP Server was not Turned on! No Action!"
        print "Correct Parameter (start/stop) is required!"

To check if tftpd is correcly activated the command is:

/usr/bin/sudo launchctl list com.apple.tftpd

and the output should look like:

        "Wait" = true;
        "Sockets" = {
                "Listeners" = (
        "LimitLoadToSessionType" = "System";
        "Label" = "com.apple.tftpd";
        "inetdCompatibility" = true;
        "TimeOut" = 30;
        "OnDemand" = true;
        "LastExitStatus" = 0;
        "Program" = "/usr/libexec/tftpd";
        "ProgramArguments" = (

A test on $? is sufficient to espablish that from the system standpoint the service is activated and will be restarted as needed upont external connection. For example:

if /usr/bin/sudo launchctl list com.apple.tftpd ; then
    echo "tftpd is on"
    echo "tftpd is off"

The TFTPD is a service which means that the executable is started on demand when an incoming connection is made. To see whether your Mac will respond i.e. whether the TFTPD service is active you can use the following command in Terminal or shell script. Note that admin privileges are not needed for this type of query:

launchctl print system/com.apple.tftpd

This will produce a configuration output if the service is active like this:

com.apple.tftpd = {
   active count = 0
   path = /System/Library/LaunchDaemons/tftp.plist
   state = waiting
   [...cut for brevity...]
   system service = 1

or an error like this:

"Could not find service "com.apple.tftpd" in domain for system"

Which would mean that the service has not been or cannot be started. If all that you are interested in is running/not running state then it's easiest to check for error message or the non-zero errorlevel returned. Errorlevel 0 means TFTPD service active, non-zero means not active. For example, if the launchd is not loaded at all errorlevel number 113 is returned which means: "Could not find specified service"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .