30 January 2022

In the previous post I describe the use of pwd to know the physical directory of a symbolic link.
Another command that could be used to print value of a symbolic link or canonical file name is readlink

Note: all example below could be execute in a container:

docker run -it  ubuntu /bin/bash

Example:

  1. Create a symbolic link:

    ln -s /etc/init.d/ /init.d
    
  2. List all directories:

    ls
    
    bin  boot  dev  etc  home  init.d  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
    
  3. Print value of symbolic link:

    readlink /init.d
    /etc/init.d
    

References