Actions

Difference between revisions of "Create a Symlink"

From InfoTechPedia

(additional text)
(update)
Line 1: Line 1:
 +
In computing, a symbolic link (also symlink or soft link) is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.<ref>[http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11 Pathname resolution].</ref>
 +
 
The standard format is: <code>ln -s absolute_path_source_file absolute_path_target_file</code>
 
The standard format is: <code>ln -s absolute_path_source_file absolute_path_target_file</code>
  
To create a new symlink (will fail if symlink exists already):
+
== Create a New Symlink ==
 +
To create a new symlink (will fail if symlink exists already):<ref name="stack">[https://stackoverflow.com/questions/1951742/how-to-symlink-a-file-in-linux Stackoverflow, How to Symlink a File]</ref>
  
 
<pre>
 
<pre>
Line 7: Line 10:
 
</pre>
 
</pre>
  
To create or update a symlink:
+
== Create or Update a Symlink ==
 +
 
 +
To create or update a symlink:<ref name="stack"></ref>
  
 
<pre>
 
<pre>
Line 29: Line 34:
 
admin@server:~/public_html/Upload$
 
admin@server:~/public_html/Upload$
 
</pre>
 
</pre>
 +
 +
== References ==
 +
<references/>
  
 
[[Category:Linux]]
 
[[Category:Linux]]

Revision as of 23:51, 25 February 2018

In computing, a symbolic link (also symlink or soft link) is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.[1]

The standard format is: ln -s absolute_path_source_file absolute_path_target_file

Create a New Symlink

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

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

Create or Update a Symlink

To create or update a symlink:[2]

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$

References