MoonPoint Support Logo

 




Advanced Search
August
Sun Mon Tue Wed Thu Fri Sat
           
13
         
2026
Months
AugSep
Oct Nov Dec


Thu, Aug 13, 2026 7:20 pm

Symlinks on Linux

To create a symbolic link (symlink), aka soft link, on a Linux system, you can use the ln command with the -s option, i.e., ln -s, followed by the target file path and the name you wish to use for the symbolic link. The -s option specifies that the link should be "soft" or symbolic (omitting this creates a hard link). You can view existing symlinks with the ls command with the -l option and then piping the output through the grep command with the -l or --long option to obtain more detailed information. Since the permission string for files or directories will begin with the letter "l", you can limit the output with ls -l | grep "^l". E.g.:

alice@Wonderland@Serenity:~/Documents$ ln -s ~/Pictures/Phone/PXL_20260715_202210365.jpg erin.jpg
alice@Wonderland@Serenity:~/Documents$ ls -l | grep "^l"
lrwxrwxrwx  1 alice@Wonderland domain users@ad.moonwillowwoods.com        75 Aug 14 15:03 erin.jpg -> /home/alice@Wonderland/Pictures/Phone/PXL_20260715_202210365.jpg
alice@Wonderland:~/Documents$

You can link an entire directory with a symlink. E.g., you could point a local logs folder to a folder elsewhere on the system, even one on another drive. E.g., ln -s /var/log/app_logs ./logs.

If you wish to find all of the symlinks in the current directory and all its subdirectories, you can use the command find . -type l. The -type l flag instructs the find command to look just for links. To see the full, absolute path of where a specific link points you can use the readlink command, e.g., readlink -f filename where filename is the name of the symlink. E.g.:

alice@Wonderland:~/Documents$ readlink -f erin.jpg
/home/alice@Wonderland/Pictures/Phone/PXL_20260715_202210365.jpg
alice@Wonderland:~/Documents$ 

You can remove a symlink with the unlink command followed by the symlink name.

alice@Wonderland@Serenity:~/Documents$ unlink erin.jpg
alice@Wonderland:~/Documents$ 

You could also use the rm command. E.g., if you created a symlink named shortcut.txt, you could remove that shortcut with rm shortcut.txt. Never add a trailing slash (/) when removing a directory symlink, or you risk deleting the contents inside the actual target directory.

[/os/unix/linux] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo