Actions

Create a Symlink

From InfoTechPedia

Revision as of 23:44, 25 February 2018 by TomHutchison (talk | contribs) (additional text)

The standard format is: ln -s absolute_path_source_file absolute_path_target_file

To create a new symlink (will fail if symlink exists already):

admin@server:~$ ln -s /home/server/a_directory/file.ext /home/server/public_html/file.ext

To create or update a symlink:

admin@server:~$ ln -sf /path/to/file /path/to/symlink

Output

This is an example of a directory listing using ls -la. Files and directories that are symlinked will show an arrow like this -> to indicate it is symlinked. See the output below.

admin@server:~/public_html/Upload$ ls -la
total 24
drwxr-xr-x  5 admin admin 4096 Feb 25 10:47 .
drwxr-x--- 24 admin admin 4096 Feb 25 04:02 ..
lrwxrwxrwx  1 admin admin   60 Feb 25 10:47 .bulk_file_upload.sh -> /home/admin/GitRepo/Upload/.bulk_file_upload.sh
lrwxrwxrwx  1 admin admin   49 Feb 25 10:46 .htaccess -> /home/admin/GitRepo/Upload/.htaccess
drwxr-xr-x  3 admin admin 4096 Feb  7 16:29 Images
lrwxrwxrwx  1 admin admin   50 Feb 25 10:46 .index.php -> /home/admin/GitRepo/Upload/.index.php
drwxr-xr-x  3 admin admin 4096 Feb  7 16:56 Saved_Images-> ../GitRepo/Upload/Saved_Images
lrwxrwxrwx  1 admin admin   51 Feb 25 10:46 .script.php -> /home/admin/GitRepo/Upload/.script.php
admin@server:~/public_html/Upload$