version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; OpenBSD amd64; rv:82.0) Gecko/20100101 Firefox/82.0 author=jrmu charset=UTF-8 csum= ctime=1614255433 host=198.251.81.119 name=Ln.Intro rev=2 targets= text=(:title Symbolic Links:)%0a%0aA symbolic link allows you to create what appears to be a new file but which points to an existing file. The command is:%0a%0a[@%0a$ ln -s /path/to/file /path/to/link%0a@]%0a%0aThis creates a symbolic link @@/path/to/link@@ which points to @@/path/to/file@@.%0a%0aIt can be very handy to have multiple copies of a file in different places. For example, you might have a binary with a long name, such as python3.8, but it would be easier to call it python. You can use a symbolic link so that /usr/local/bin/python3.8 points /usr/local/bin/python:%0a%0a[@%0a$ doas ln -s /usr/local/bin/python3.8 /usr/local/bin/python%0a@]%0a%0aThis creates a symbolic link @@/usr/local/bin/python@@ which points to @@/usr/local/bin/python3.8@@.%0a%0aIf you long list it without following symbolic links:%0a%0a[@%0a$ ls -ld /usr/local/bin/python%0alrwxr-xr-x 1 root wheel 24 Feb 25 07:13 /usr/local/bin/python -> /usr/local/bin/python3.8%0a@]%0a%0aThe -> indicates that @@/usr/local/bin/python@@ is a symbolic link.%0a%0aSymbolic links can be used on folders, too! This can be very handy:%0a%0a[@%0a$ doas ln -s /var/www/htdocs /home/username/htdocs%0a@]%0a%0aNow, any files you put in your home folder's htdocs will automatically show up in /var/www/htdocs (the folder for your web server). time=1614255649 title=Symbolic Links author:1614255649=jrmu diff:1614255649:1614255433:=28,34c28,44%0a%3c Symbolic links can be used on folders, too! This can be very handy:%0a%3c %0a%3c [@%0a%3c $ doas ln -s /var/www/htdocs /home/username/htdocs%0a%3c @]%0a%3c %0a%3c Now, any files you put in your home folder's htdocs will automatically show up in /var/www/htdocs (the folder for your web server).%0a\ No newline at end of file%0a---%0a> Symbolic links can be used on folders, too! This can be very handy%0a> %0a> Create a symbolic link named /home/www and point it to /var/www:%0a> %0a> # ln -s /var/www /home/www%0a> %0a> Hard link /usr/local/bin/fooprog to file /usr/local/bin/fooprog-1.0:%0a> %0a> # ln /usr/local/bin/fooprog-1.0 /usr/local/bin/fooprog%0a> $ mkdir bar baz%0a> $ ln -s bar foo%0a> $ ln -shf baz foo%0a> %0a> Without the -h option, this would instead leave foo pointing to bar and%0a> inside foo create a new symlink baz pointing to itself. This results%0a> from directory-walking.%0a> %0a host:1614255649=198.251.81.119 author:1614255433=jrmu diff:1614255433:1614255433:=1,44d0%0a%3c (:title Symbolic Links:)%0a%3c %0a%3c A symbolic link allows you to create what appears to be a new file but which points to an existing file. The command is:%0a%3c %0a%3c [@%0a%3c $ ln -s /path/to/file /path/to/link%0a%3c @]%0a%3c %0a%3c This creates a symbolic link @@/path/to/link@@ which points to @@/path/to/file@@.%0a%3c %0a%3c It can be very handy to have multiple copies of a file in different places. For example, you might have a binary with a long name, such as python3.8, but it would be easier to call it python. You can use a symbolic link so that /usr/local/bin/python3.8 points /usr/local/bin/python:%0a%3c %0a%3c [@%0a%3c $ doas ln -s /usr/local/bin/python3.8 /usr/local/bin/python%0a%3c @]%0a%3c %0a%3c This creates a symbolic link @@/usr/local/bin/python@@ which points to @@/usr/local/bin/python3.8@@.%0a%3c %0a%3c If you long list it without following symbolic links:%0a%3c %0a%3c [@%0a%3c $ ls -ld /usr/local/bin/python%0a%3c lrwxr-xr-x 1 root wheel 24 Feb 25 07:13 /usr/local/bin/python -> /usr/local/bin/python3.8%0a%3c @]%0a%3c %0a%3c The -> indicates that @@/usr/local/bin/python@@ is a symbolic link.%0a%3c %0a%3c Symbolic links can be used on folders, too! This can be very handy%0a%3c %0a%3c Create a symbolic link named /home/www and point it to /var/www:%0a%3c %0a%3c # ln -s /var/www /home/www%0a%3c %0a%3c Hard link /usr/local/bin/fooprog to file /usr/local/bin/fooprog-1.0:%0a%3c %0a%3c # ln /usr/local/bin/fooprog-1.0 /usr/local/bin/fooprog%0a%3c $ mkdir bar baz%0a%3c $ ln -s bar foo%0a%3c $ ln -shf baz foo%0a%3c %0a%3c Without the -h option, this would instead leave foo pointing to bar and%0a%3c inside foo create a new symlink baz pointing to itself. This results%0a%3c from directory-walking.%0a%3c %0a host:1614255433=198.251.81.119