A file to create a symbolic link is not required. The following example demonstrates creating a symbolic link to a nonexistent file:
First check if there is a file named foobar in /home/wieslander/tmp :
[ wieslander@rizzo tmp]$ ls -l /home/wieslander/tmp/foobar ls: cannot access /home/wieslander/tmp/foobar: No such file or directory
Create a symlink named brokensymlink pointing to /home/wieslander/tmp/foobar :
[ wieslander@rizzo tmp]$ python Python 2.5.2 (r252:60911, Sep 30 2008, 15:42:03) [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.symlink('/home/wieslander/tmp/foobar', 'brokensymlink')
Ensure that the symbolic link is created and that the destination still does not exist:
[ wieslander@rizzo tmp]$ ls -l brokensymlink lrwxrwxrwx 1 wieslander wieslander 27 19 nov 13.13 brokensymlink -> /home/wieslander/tmp/foobar [ wieslander@rizzo tmp]$ ls -l /home/wieslander/tmp/foobar ls: cannot access /home/wieslander/tmp/foobar: No such file or directory
source share