133

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

muru
  • 193,181
  • 53
  • 473
  • 722
Waqas Rana
  • 1,441
  • 2
  • 9
  • 7

1 Answers1

183

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

heemayl
  • 90,425
  • 20
  • 200
  • 267
  • 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 '16 at 06:31
  • 1
    @heemayl isn't it the other way around? – still_dreaming_1 Feb 21 '17 at 15:45
  • nope, target goes first, see [docs](https://linux.die.net/man/1/ln), also @WaqasRana's comment mentions the wrong command "ls" – Efren Feb 04 '18 at 23:47
  • 23
    For me, this creates a file... – Yanick Rochon Dec 17 '18 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 – Mr. Suryaa Jha Aug 06 '19 at 06: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 '21 at 20:32
  • @YanickRochon et al - I would say you should make sure to give the absolute path to the directory the link should be pointing to – chsymann Jun 10 '21 at 15:46