Search code examples
bashcentosdatediff

Unable to execute datediff command on centos as root user?


I am unable to run the datediff command as root user on centos. But as the other user, I can run the command. Could you guys, please help me to fix the issue?

FYI, I'm using this version centos-release-7-0.1406.el7.centos.2.5.x86_64


Solution

  • Check your $PATH variable, the command's directory is probably not in there for your root user.

    echo $PATH
    

    Will show the current value, the directory of the datediff command must appear in there. To modify, do:

    export PATH=$PATH:<THE DIRECTORY>
    

    To find where datediff resides on your system, while you are connected with another user than root, do:

    which datediff