Как создавать и удалять симлинки
Обновлено:
Опубликовано:
Используемые термины: Симлинк, Windows, Linux.
Windows
Linux
Проблемы и решения
Работы с символьными ссылками в Windows ведутся из командной строки.
Синтаксис
mklink <имя создаваемого симлинка> <на что ведет симлинк>
Симлинк на файл
mklink C:\Users\dmosk\Desktop\cmd.exe C:\Windows\system32\cmd.exe
* в данном примере на рабочем столе пользователя dmosk будет создан симлинк на файл cmd.exe.
Симлинк на директорию
mklink /D «C:\Users\dmosk\Desktop\Сетевая папка» \\dmosk.local\share
* в примере создается симлинк на сетевую папку \\dmosk.local\share
** так как в названии папки есть пробел, путь заключен в кавычки.
Для создания ссылки на папку доступен также ключ /J. Созданная таким образом ссылка будет по некоторым особенностям напоминать жесткую ссылку.
Удалить симлинк
В Windows его можно удалить в проводнике, как обычный файл или папку.
Или использовать командную строку.
Для папки:
rmdir «C:\Users\dmosk\Desktop\Сетевая папка»
Для файла:
del C:\Users\dmosk\Desktop\cmd.exe
Разрешить симлинки в Windows
Если при попытке перейти по символьной ссылке мы получим ошибку «Символическая ссылка не может быть загружена, так как ее тип отключен», открываем командную строку от администратора и вводим команду:
fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1
Если это не помогло, пробуем создать симлинк с ключом /J.
Linux и FreeBSD
Создание
Общий синтаксис
ln -s <на какой существующий объект будет вести> <создаваемый симлинк>
В системах на базе Linux (например, Ubuntu или CentOS) и FreeBSD симлинк для каталога и файла создаются одинаково:
ln -s /usr/share/nginx/html/index.php /home/dmosk/
ln -s /usr/share/nginx/html /home/dmosk/
* в первом примере создана символьная ссылка в домашней директории пользователя dmosk на файл index.php; во втором — на каталог /usr/share/nginx/html.
Удаление
Также используется одна команда:
rm /home/dmosk/index.php
Решение возможных проблем
При работе с симлинками мы можем сталкиваться с различными проблемами. Я рассмотрю те, с которыми приходилось сталкиваться мне.
ln: failed to create symbolic link … Function not implemented
При попытке создать симлинк мы можем получить ошибку Function not implemented, например:
ln: failed to create symbolic link ‘/etc/pve/nodes/pve/fullchain.pem’: Function not implemented
Причина: файловая система, на которой мы хотим создать файл не поддерживает симлинки. Посмотреть файловую систему подмонтированных разделов можно командой:
df -T
Решение: как правило, решения зависит от используемой файловой системы и ее драйвера. Но, обычно, решения у проблемы нет и нужно искать методы работы без использования символьных ссылок.
Symbolic Link Deletion: Understanding the Concepts, Processes, and Best Practices
In the realm of computer file systems, symbolic links, often referred to as symlinks, play a significant role in enhancing file management and accessibility. However, managing these links effectively—especially when it comes to deletion—can be a nuanced task that significantly impacts system functionality and user experience. This article delves into the intricacies of symbolic link deletion, covering definitions, types of symbolic links, deletion methods, implications, troubleshooting common issues, and best practices to consider.
Understanding Symbolic Links
Symbolic links are special types of files that serve as references to another file or directory in the file system. Unlike hard links that point directly to the data on disk, symbolic links contain a path that locates the target file. As a result, if you delete the original file, the symbolic link becomes broken, leading users to an inaccessible path. In Unix-like systems, symlinks are created using the ln -s
command, while Windows environments use the mklink
command.
Types of Symbolic Links:
-
Soft Links: These are standard symbolic links that can point to any file or directory. They can traverse file systems and point to files located on network shares.
-
Hard Links: Though not a symbolic link in the traditional sense, hard links reference the same inode as the target file. This means that multiple directory entries can refer to the same file without creating separate copies.
The creation and management of symbolic links optimize disk space and enhance the accessibility of frequently-used files or directories.
Deleting Symbolic Links
When it comes to deleting symbolic links, understanding the different methods available to perform this task is crucial. The process of deletion depends on the operating system being used, as commands and syntax vary across platforms.
1. Deleting Symbolic Links in Unix/Linux Systems:
In Unix/Linux, you can delete symbolic links using the rm
command. Here’s how it’s typically done:
-
Using
rm
: To remove a symbolic link, you would enter:rm symlink_name
This command removes the symlink but does not affect the original file it points to.
-
Using
unlink
: Another command used to delete symbolic links isunlink
:unlink symlink_name
The
unlink
command is specifically designed for deleting singular files, including symlinks.
2. Deleting Symbolic Links in Windows Systems:
In Windows, symbolic links can be deleted via the Command Prompt:
-
Using
del
: To remove a symbolic link, use:del symlink_name
This command will delete the symlink, similar to its Unix/Linux counterpart.
- Using File Explorer: Users can also delete symbolic links just like regular files using the graphical user interface. Right-clicking the symlink and selecting “Delete” will remove it without affecting the target file.
3. Deleting Symbolic Links in macOS:
Since macOS is built on a Unix-like foundation, symlink deletion follows similar commands:
-
Using
rm
: The command in the macOS terminal is the same as Linux:rm symlink_name
-
Using Finder: Deletion can also occur through Finder by moving the link to the Trash or using the delete key.
Implications of Deleting Symbolic Links
While deleting symbolic links might seem straightforward, it’s vital to understand that their deletion does not recursively affect the original files. However, losing access to references may lead to issues in scripts or programs relying on those paths.
1. Impact on Application Behavior:
Applications that reference symbolic links may experience errors upon the deletion of the link. For example, a development environment using symlinks for file management could break if the links are removed unexpectedly.
2. Broken Links:
Deleting the original target of a symlink does not delete the symlink itself. Any attempt to access the symlink afterward will result in an error, leading to broken links. This may cause confusion for users or scripts that expect the files to be present.
3. Data Loss Concerns:
Although deleting a symlink is typically safe, users must ensure that they do not confuse links with actual data files. Accidental deletion of linked files rather than just the links could lead to data loss.
Troubleshooting Common Issues
Despite the simplicity of deleting symbolic links, users may encounter issues. Here are some common problems and their solutions:
1. Permission Denied:
If you attempt to delete a symlink without the required permissions, you will receive an error. To fix this:
- Check the permissions using
ls -l
in Unix/Linux or by checking properties in Windows. - Use
sudo
for Unix/Linux or run the Command Prompt as an administrator on Windows.
2. File Not Found:
If a symlink points to a deleted or moved file, you may receive a “file not found” error during deletion attempts. In this instance, simply ignore the error or remove the symlink using rm
or del
.
3. System Lock:
Certain running processes may lock a symlink, preventing deletion. Ensure that no process is using the symlink. You can use tools like lsof
in Unix/Linux to identify which processes are using a specific file.
Best Practices for Managing Symbolic Links
Proper management and deletion of symbolic links involve certain best practices to ensure system integrity and data safety:
1. Verification Before Deletion:
Always verify the target of a symbolic link before deleting it. Use ls -l symlink_name
to check where the link points, ensuring you’re not mistakenly removing important files.
2. Avoid Circular References:
Circular symbolic links occur when a symlink points to itself or to another symlink in a loop. This can cause issues, especially with scripts that could lead to endless loops. Always be cautious when creating symlinks.
3. Regular Maintenance:
Periodically audit your symbolic links for broken paths. Remove any that are no longer necessary to help maintain a clean file structure, minimizing confusion and potential errors.
4. Utilize Absolute Paths:
For better stability, consider using absolute paths rather than relative paths when creating symlinks. This minimizes the risk of broken links due to changes in the directory structure.
5. Document Link Purpose:
If you have a complex file system with many symbolic links, consider maintaining documentation on their purpose and target locations. This practice could help to streamline future management and avoid unwanted deletions.
6. Utilize Scripts for Complex Deletions:
In cases of bulk deletion of symbolic links, consider using scripts that can efficiently identify and delete symlinks based on user-defined criteria. For example, a simple bash script can be created to remove all symlinks in a directory.
Conclusion
The deletion of symbolic links is an integral part of file system management, spanning across various operating systems. While the processes are generally straightforward, they require consideration of the implications, potential issues, and best management practices to avoid complications. Understanding how symlinks function and the consequences of their deletion can significantly enhance system organization and prevent disruptions in workflow. By following the outlined practices and solutions, users can navigate the complexities of symbolic link deletion with confidence and efficiency, ensuring a smoother overall experience when managing files and directories.
A symbolic link can be created at the command-line using the mklink command of the command prompt.
To delete a symbolic link to a file use the del command:
del Foo.txt
To delete a symbolic link to a directory use the rmdir command:
rmdir Foo
Unlike creation of symbolic links, deletion of a symbolic link does not require Administrator privilege. It can be performed from a normal command prompt without elevated privileges.
Tried with: Windows 8 Pro
- Tagged
- del
- deletion
- mklink
- rmdir
- symbolic link
- windows
Beyond Shortcuts: Understanding Windows 11 Symbols & Links
Ever clicked on a shortcut that just… doesn’t work? Yeah, me too. It’s frustrating, right? You’re trying to get somewhere quick, and instead you’re met with an error message. Well, Windows 11 has something a little more powerful than your average shortcut: symbolic links (or symlinks, as some people call them). They’re like super-charged shortcuts that can seriously level up your file management game. But, what exactly are symbolic links and how do you use them in Windows 11? Let’s, uh, check it out.
Symbolic links are basically pointers. Instead of copying a file or folder to a new location, you create a link that points back to the original. This is super useful for a bunch of reasons, like keeping your files organized without actually moving them, or making it easier for programs to find the files they need. They can be a little confusing at first, but trust me, once you get the hang of it, you’ll wonder how you ever lived without them.
Think of it like this: imagine you have a bunch of important documents stored in a filing cabinet in your office. Now, imagine you want to access those same documents from your home office. You could copy all those documents and lug them back and forth, but that’s a lot of work, and you have to make sure you have the latest version in both places. A symbolic link is like creating a magic portal in your home office that instantly takes you to the filing cabinet in your main office. No copying, no lugging, just instant access to the real deal. Pretty neat, huh?
In this article, I’m gonna walk you through everything you need to know about symbolic links in Windows 11. We’ll cover what they are, why you’d wanna use them, how to create them using both the command line and a graphical tool, and even how to get rid of them when you’re done. Trust me, it’s not as scary as it sounds! Plus, I’ll share some tips and tricks I’ve picked up along the way, so you can become a symlink pro in no time.
One thing I’m not sure about is, is it worth it? Like, really worth it? I mean, it’s a bit technical, and some people might find it easier to just stick with regular shortcuts. But honestly, the power and flexibility that symbolic links offer are hard to beat. So, if you’re willing to put in a little effort, I think you’ll find that they’re a valuable tool to have in your Windows 11 arsenal. And hey, even if you don’t use them all the time, it’s always good to know how they work, right?
Anyway, let’s get started! You’ll learn how to create and manage symbolic links, making your file system more efficient and manageable. So, grab your favorite beverage, settle in, and let’s get linking!
Creating Order from Chaos: Symbolic Links Explained
Okay, so what are symbolic links, really? Well, as I mentioned earlier, they’re like advanced shortcuts. But they’re more than just shortcuts, they’re more like a portal. They let you create a reference to a file or folder that acts just like the original, even though it’s located somewhere else. What’s the big deal, you ask? Well, here’s why they’re so useful:
- Organization: Keep your files organized without actually moving them. You can have a folder with all your project files, and then create symlinks in different locations to access those files from multiple places.
- Program Compatibility: Some programs are picky about where they expect to find their files. With symlinks, you can trick them into looking in the right place, even if the files are actually stored somewhere else.
- Cloud Syncing: Sync any folder with programs like Dropbox, Google Drive, and OneDrive, even if they don’t officially support it.
- Saving Space: Instead of duplicating large files, you can create a symlink that points to the original, saving valuable disk space.
As we can see from How-To Geek, symbolic links are supported by Windows 11 and 10, which means you can start using them right away!
Soft Links vs. Hard Links: What’s the Difference?
Now, before we dive into creating symlinks, it’s important to understand the two different types: soft links and hard links. They’re similar, but they have some key differences that can affect how you use them.
- Soft Links (Symbolic Links): These are like regular shortcuts. They point to the path of the original file or folder. If you delete the original, the soft link will break.
- Hard Links: These are more like mirrors. They point to the actual data of the original file or folder. If you delete the original, the hard link will still work, because it’s pointing to the same data on your hard drive.
So, which one should you use? Well, it depends on your needs. Soft links are more flexible, because they can point to files or folders on different drives or even network locations. However, they’re also more fragile, because they’ll break if the original is deleted. Hard links are more robust, but they can only point to files or folders on the same drive, and they can’t point to folders at all.
Why Bother with Symbols and Links? Real-World Scenarios
Okay, so you know what symlinks are, but why should you care? Here are a few real-world scenarios where they can be incredibly useful:
- Moving Your Steam Games: Steam lets you install games to different drives, but sometimes you might want to move them without re-downloading. You can move the game files to a new location, and then create a symlink in the original location pointing to the new one. Steam will think the game is still in the same place, and you won’t have to re-download anything.
- Customizing Your Windows Theme: Windows themes are stored in a specific folder, but you might want to use custom images or sounds from other locations. You can create symlinks in the theme folder pointing to your custom files, and Windows will use them just like they were part of the theme.
- Sharing Files Between Users: If you have multiple user accounts on your computer, you might want to share files between them without duplicating them. You can store the files in a shared location, and then create symlinks in each user’s profile pointing to the shared files.
I’ve used symlinks to keep my music library organized across multiple computers, and it’s saved me a ton of time and disk space. Plus, it’s kinda fun to feel like you’re hacking the system a little bit, y’know?
Command Line Kung Fu: Creating Symlinks with MKLINK
Alright, let’s get down to business. The most common way to create symbolic links in Windows 11 is using the mklink
command in the Command Prompt. It might sound a little intimidating, but it’s actually pretty straightforward. First, you’ll need to open the Command Prompt as an administrator. Here’s how:
- Click the Start button.
- Type «cmd» or «Command Prompt».
- Right-click on «Command Prompt» in the search results.
- Select «Run as administrator».
This is important, because you need administrator privileges to create symlinks in certain locations, especially system folders. Now that you have the Command Prompt open, you’re ready to start linking!
The basic syntax for the mklink
command is:
mklink <Link> <Target>
Where <Link>
is the path to the new symbolic link you want to create, and <Target>
is the path to the original file or folder you want to link to.
But wait, there’s more! The mklink
command has a few different options that let you specify the type of link you want to create:
/D
: Creates a soft link to a directory./H
: Creates a hard link to a file./J
: Creates a hard link to a directory (also known as a directory junction).
So, if you wanted to create a soft link to a folder, you’d use the /D
option. For example:
mklink /D "C:\MyLink" "D:\MyFolder"
This would create a soft link named C:\MyLink
that points to the folder D:\MyFolder
.
If you wanted to create a hard link to a file, you’d use the /H
option. For example:
mklink /H "C:\MyLink.txt" "D:\MyFile.txt"
This would create a hard link named C:\MyLink.txt
that points to the file D:\MyFile.txt
.
And if you wanted to create a directory junction, you’d use the /J
option. For example:
mklink /J "C:\MyLink" "D:\MyFolder"
This would create a directory junction named C:\MyLink
that points to the folder D:\MyFolder
. Remember: You only use directory junctions for folders, not files.
A Graphical Approach: Using Link Shell Extension
If the command line isn’t your thing, don’t worry! There’s also a graphical tool called Link Shell Extension that makes creating symbolic links a breeze. It’s a free, open-source program that adds a bunch of extra options to the Windows Explorer context menu (that’s the menu that pops up when you right-click on a file or folder).
Once you’ve installed Link Shell Extension, here’s how to use it:
- Right-click on the file or folder you want to create a link to.
- Select «Pick Link Source» from the context menu.
- Navigate to the location where you want to create the link.
- Right-click in the destination folder.
- Select «Drop As» from the context menu.
- Choose the type of link you want to create (Hardlink, Junction, Symbolic Link).
That’s it! No complicated commands, no memorizing syntax. Just a few clicks and you’re done. I find this method especially useful for creating symlinks to folders, because it’s much easier to navigate the file system using the graphical interface than it is to type out long paths in the command line. Plus, it gives you a clear idea of where the link is pointing to, which can be helpful for avoiding mistakes.
Symlink Troubleshooting: Common Problems and Solutions
Okay, so you’ve tried creating a symlink, but something went wrong. Don’t panic! Here are a few common problems and how to fix them:
- «You do not have sufficient privilege to perform this operation»: This means you didn’t open the Command Prompt as an administrator. Close the Command Prompt, and then follow the steps above to open it with administrator privileges.
- «The system cannot find the path specified»: This means you typed the path to the link or the target incorrectly. Double-check your spelling and make sure the paths are correct. Remember to use quotation marks around paths with spaces.
- The symlink doesn’t work: This could be caused by a few different things. First, make sure the original file or folder still exists. If it’s been deleted or moved, the symlink will break. Also, make sure the symlink is pointing to the correct location. If you’re using a soft link, it’s possible that the path has changed.
If you’re still having trouble, try searching online for the specific error message you’re seeing. There’s a good chance someone else has run into the same problem, and there might be a solution posted on a forum or blog.
Cleaning Up: Deleting Symbolic Links
When you’re done with a symbolic link, you can simply delete it like you would any other file or folder. Just be careful to delete the link itself, rather than the original file or folder it’s linking to. This is a major advantage of symbolic links – you can freely delete them without worrying about affecting the original files. If you delete the original file, then the symbolic link will just be broken.
Wrapping Up: Symlinks for the Win!
So, there you have it! Everything you need to know about symbolic links in Windows 11. They might seem a little complicated at first, but they’re actually a pretty powerful tool that can help you organize your files, customize your system, and save valuable disk space. Whether you’re a command-line ninja or a graphical interface guru, there’s a method for creating and managing symlinks that’s right for you.
So, go ahead and give them a try! See how they can improve your workflow and make your life a little easier. And don’t be afraid to experiment – the worst that can happen is you’ll break a link, which is easily fixed. Just remember to be careful when deleting files and folders, and always double-check that you’re deleting the right thing. As I mentioned earlier, this can be a big advantage. I hope you found this article helpful, and that you’re now ready to unleash the power of symbolic links in Windows 11! Have fun linking!
FAQ
- What happens if I delete the original file or folder that a symbolic link points to?
- If you delete the original file or folder, the symbolic link will become broken. When you try to access the symbolic link, you’ll get an error message saying that the target cannot be found. This is because a symbolic link is simply a pointer to the original location, not a copy of the data itself. If you want to ensure that you can still access the data even if the original is deleted, you should use a hard link instead.
- Can I create symbolic links to files or folders on a network drive?
- Yes, you can create symbolic links to files or folders on a network drive, but there are some limitations. Soft links (symbolic links) can point to network locations, but hard links (directory junctions) cannot. Also, the user account you’re using to create the symbolic link must have the necessary permissions to access the network location. If you don’t have the correct permissions, the symbolic link might not work correctly, or you might not be able to create it at all. Remember that if the network drive is not connected or the network location is no longer available, the symlink will fail.
- Are symbolic links the same as shortcuts? What are the differences?
- While both symbolic links and shortcuts provide a way to access files or folders from another location, they function differently and offer different capabilities. Shortcuts are essentially pointers to the original file path. If the target file is moved or renamed, the shortcut will break. Symbolic links, on the other hand, are more robust. Soft symbolic links also point to the path, but they are treated more like the actual file or directory by the operating system. Hard links point directly to the data on the disk, so they remain valid even if the original file is moved or renamed as long as it is on the same disk. Symbolic links can also point to network locations, unlike hard links. Symbolic links require administrative privileges to create in some locations, whereas shortcuts do not. The choice between symbolic links and shortcuts depends on the specific requirements for file access and management.
Символическая ссылка (симлинк, символьная ссылка, Symbolic link) это специальный файл на файловой системе, которые сам не содержит данных, а является по сути ярлыком, указывающим на какой-то другой объект (файл или папку). При обращении к симлику операционная система считает, что это оригинальный файл (папка) и работает с ними совершенно прозрачно.
Символические ссылки используются в Windows довольно часто для системных файлов и каталогов. Пользователь может их применять, когда нужно перенести часть “тяжелых” файлов на другой диск, но чтобы Windows считала, что файлы все еще находятся в исходном каталоге (например в ситуациях, когда нужно экономить место на SSD, перенеся некоторые каталоги на более медленный и емкий SSD, не нарушая работоспособности программ). Можно использовать симлинки на SMB файловом сервере, когда каталоги с разных LUN должны быть доступны через одну точку входа.
В Windows есть три типа файловых ссылок для NTFS томов: жесткие, мягкие (симлинки), точки соединения (Junction point).
- Hard Links (жесткие ссылки) – могут указывать только на локальный файл, но не на папку. Такой файл – это ссылка на другой файла на этом же диске без фактического дублирования самого файла. У него отображается такой же размер и свойства, как у целевого файла (но реальное место на диске он не занимает);
- Junction Points (Directory Hard Link, точка соединения) – могут указывать только на папку (на этом же или на другом разделе);
- Symbolic Links (мягкая ссылка, симлинк) – могут указывать на локальный файл, папку и сетевой каталог на удаленном компьютере (UNC), поддерживаются относительные пути.
В подавляющем большинстве случаев вам будет достаточно функционала symbolic link, как наиболее универсального средства создания ссылки на любой объект.
Как создать символическую ссылку в Windows?
Для создания символических и жестких ссылок в Windows можно использовать встроенную утилиты mklink или PowerShell.
Синтаксис у утилиты
mklink
простой. Чтобы создать символическую ссылку на файл, нужно указать имя ссылки и целевой объект, на который она должна указывать. Можно указать тип ссылки:
/D
— символьная (мягкая) ссылка на каталог,
/H
— жесткая ссылка,
/J
– точка соединения (Junction point).
Чтобы использовать mklinkдля создания символических ссылок нужно запустить командную строку с правами администратора. Иначе при запуске команды появится ошибка “
You do not have sufficient privilege to perform this operation
”.
Если вам нужно разрешить создавать символические ссылки обычным пользователям, нужно добавить группу пользователей в параметр групповой политики Create Symbolic Links (Computer configuration -> Window Settings -> Security settings -> User Rights Assignment в редакторе GPO). По умолчанию в этой политике добавлена только локальная группа «Administrators». Обновите локальные политики после изменения параметра: gpupdate /force
Создадим в каталоге C:\PS символическую ссылку на файл notepad.exe:
mklink C:\PS\note.exe c:\Windows\System32\notepad.exe
Должно появится сообщение:
symbolic link created for C:\PS\note.exe <<===>> c:\Windows\System32\notepad.exe
Теперь для запуска процесса notepad.exe можно использовать символическую ссылку note.exe.
Теперь создадим в этом каталоге симлинк на другой каталог на этом же диcке:
mklink /D “C:\PS\Downloads” “C:\Users\user\Downloads”
Теперь при переходе в каталог C:\PS\Downloads вы будете видеть содержимое каталога, на который он ссылается.
Выведем содержимое каталога C:\PS:
Dir c:\ps
Как вы видите, в атрибутах некоторых файлов указано, что это symlink/simlinkd. Также указан объект, на который они ссылаются. В Windows File Explorer симлинки отображаются с иконками ярлыков, а в их свойствах можно посмотреть целевой объект на который они ссылаются.
Также можно создать символически ссылки в Windows 10 с помощью PowerShell (в этом примере я использую относительные пути, чтобы создать символическую ссылку):
New-Item -ItemType SymbolicLink -Path ".\test\tmpfiles" -Target "..\tmp\files"
Можно создать символическую ссылку на сетевую папку на удаленном компьютере/сервере. Адрес сетевой папки нужно указывать в формате UNC. Следующий пример создаст симлинк на сетевой каталог на сервере:
mklink /D c:\ps\share \\mskfs01\Share
Например, подключим административную шару C$ с удаленного компьютера по IP адресу:
mklink /D c:\remotePC\server1 \\192.168.31.15\С$
Если при доступе к сетевой папке через симлинк, вы получили ошибку
The symbolic link cannot be followed because its type is disabled
проверьте разрешенные способы использования символических ссылок на вашем компьютере:
fsutil behavior query SymlinkEvaluation
Local to local symbolic links are enabled. Local to remote symbolic links are enabled. Remote to local symbolic links are disabled. Remote to remote symbolic links are disabled.
Чтобы включить использование символических ссылок на удаленные ресурсы, выполните команды:
fsutil behavior set SymlinkEvaluation R2R:1
fsutil behavior set SymlinkEvaluation R2L:1
Вы можете работать с символическими ссылками, как с обычными объектами файловой системы, можно переименовать, переносить или удалить их. Система автоматически изменит настройки таких симлинков, чтобы они указывали на верные целевые объекты.
Для удаления симлинков используются обычные команды, как и для удаления файлов:
Del c:\ps\note.exe
RD c:\ps\downloads
Как найти и вывести все символические ссылки на диске?
В Windows нет простых инструментов для просмотра и управления всеми симлинками на диске.
Вы можете вывести список всех символических ссылок на диске с помощью команды:
dir /AL /S C:\ | find "SYMLINK"
-
/A
– вывести файлы с атрибутом L (симлинк); -
/S
–выполнить команду рекурсивно для всех вложенных каталогов; -
C:\
— укажите имя диска, на котором нужно найти все символические ссылки (если вы не хотите сканировать весь диск, укажите путь к нужному каталогу)
Также можно вывести список всех символических ссылок на диске с помощью PowerShell. Для этого нужно просканировать все каталоги и найти NTFS объекты с атрибутом ReparsePoint:
Get-ChildItem -Path C:\ -Force -Recurse -ErrorAction 'silentlycontinue' | Where { $_.Attributes -match "ReparsePoint"}