I'm trying to type 'realpath' in CentOS 6.5. But it seems not installed. I checked it is contained in coreutils (archlinux). I double check the coreutils package which provide by CentOS, it lack the /usr/bin/realpath. I don't want to install 3rd party rpm like 'http://pkgs.org/centos-6/repoforge-x86_64/realpath-1.17-1.el6.rf.x86_64.rpm.html'.

I've did yum search realpath, can not found it. Is the utility contains in other package? Or just be removed for security reason?

  • Try sudo yum provides -C realpath to see which package it is in; then install it (or try re-installing if it is already installed).
    – BenjiWiebe
    Jun 20, 2014 at 3:38
  • yum provides -C /usr/bin/realpath Loaded plugins: fastestmirror, refresh-packagekit, security No Matches found Jun 20, 2014 at 4:41
  • @DanielYCLin Can't you simply use readlink -e? It is exactly the same thing. Jun 20, 2014 at 6:05
  • @MariusMatutiae please write as answer, I'm writing my script, so, it is possible to use readlink if centos 6.5 support it. Jun 20, 2014 at 16:56
  • @DanielYCLin I have done so, as per your request. Jun 20, 2014 at 17:11

4 Answers 4


realpath is a very useful tool, however most of its functionalities were already present with readlink. The realpath man page states:

Please note that mostly the same functionality is provided by the '-e' option of the readlink(1) command.

And the readlink man page states:

-e, --canonicalize-existing: canonicalize by following every symlink in every component of the given name recursively, all components must exist.

The readlink command was added to coreutils, AFAIK, in 2008: it is surely available in Ubuntu Hardy 8.04. So if you do not have realpath, it is possible that you have readlink immediately available.


The realpath tool was added to GNU coreutils in version 8.15 (commit 77ea441f79aa), released in 2012. Your CentOS release likely has coreutils v8.4. The tool wasn't removed; it was not yet added in the first place.

  • So, 'realpath' is not contained in centos official repository. Install 3rd party rpm is the only way? Jun 20, 2014 at 5:50
  • 1
    @DanielYCLin You could just download it from ftp.gnu.org, run tar -xJf coreutils-8.22.tar.xz; ./configure; make; sudo make install. It will put it in /usr/local/bin which is likely in your PATH (if not, you can add it).
    – BenjiWiebe
    Jun 23, 2014 at 12:35
  • 3
    or just echo '/usr/bin/readlink -e "$@"' > /usr/local/bin/realpath ; chmod +x /usr/local/bin/realpath
    – djsadinoff
    Dec 30, 2014 at 15:22
  • @djsadinoff It's best practice not to call an alias after another command. realpath -s $0, for instance, is a very common idiom not covered there. Nov 12, 2019 at 10:24

Normally realpath is provided by coreutils package, so you should install it via:

yum install coreutils

Alternatively try: readlink or define your own function, such as:

realpath () { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" }

or see some more examples here.

I've tested the command in CentOS 7 VM via Vagrant:

vagrant init bento/centos-7.1 && vagrant up --provider virtualbox && vagrant ssh

it seems realpath is installed by default.


had the similar issue. On MacOS:

brew install coreutils
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    May 23 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.