140

I want to create a symlink that should point to another directory.

Like inside directory /var/www/vhosts/ecash-staging.com/ should be a symlink named as ecash_root that should pointing to --> /var/www/vhosts/ecash_cfe.

How is this possible ?

I have googled but there some people said that there should be a dir ecash_root exist in /var/www/vhosts/ecash_cfe/... but I do not want that.

i just have to create symlink in /var/..../ecash-staging.com/ name as ecash_root that should point to /var/www/vhosts/ecash_cfe but should not be a ecash_root dir inside /var/www/vhosts/ecash_cfe.

thanks to all

2
  • 2
    open a terminal, enter ln --help or/and man ln and read it for additional information... Oct 31, 2016 at 6:22
  • 1
    You needed to be in Target folder ln -s <source-file> name Apr 16, 2019 at 7:55

1 Answer 1

193

Use ln:

ln -s /var/www/vhosts/ecash_cfe /var/www/vhosts/ecash-staging.com/ecash_root
  • -s stands for symbolic link

  • /var/www/vhosts/ecash_cfe is the source file

  • /var/www/vhosts/ecash-staging.com/ecash_root is the link name

8
  • 1
    2 commands worked for me . one of them that is @heemayl mentioned above . and other one in current directory just ran the command ls -s /var/www/vhosts/ecash_cfe ecash_root . same worked both . good .
    – Waqas Rana
    Oct 31, 2016 at 6:31
  • 1
    @heemayl isn't it the other way around? Feb 21, 2017 at 15:45
  • 23
    For me, this creates a file... Dec 17, 2018 at 21:31
  • 2
    ln -s target_directory short_cut_file_path_and_name Example : ln -s /media/ ./media_shortcut Explanation : Creating shortcut file in the same directory with name media_shortcut which references to /media/ directory Aug 6, 2019 at 6:11
  • 2
    @YanickRochon et al — make sure you are in the target directory, not the source directory when you create the symlink.
    – Karoh
    Jan 14, 2021 at 20:32

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