Linux Bash中能否创建类Windows快捷方式替代符号链接?
Absolutely feasible! While Linux doesn't have an exact 1:1 equivalent of Windows shortcuts at the filesystem level, you can create desktop shortcut files (.desktop) that behave almost identically—complete with custom names, icons, and the ability to open your target location with a double-click, just like Windows shortcuts.
How to create a Windows-like shortcut in /home/user1/
Create a .desktop file
Open a text editor (likenanoorgedit) and create a file namedhere.desktopin/home/user1/with this content:[Desktop Entry] Type=Link Name=Here Shortcut # This is the visible name of your shortcut URL=file:///tmp/subdir1/subdir2/here Icon=folder # Optional: Replace with an icon name (e.g., "document" for a file icon)Type=Linktells the desktop environment this is a shortcut to a file/folderURLspecifies the full path to your target location (note thefile://prefix)Iconlets you set a custom icon to match the target type (use any system icon name)
Make the shortcut executable
Run this command in your terminal to give the file executable permissions (required for desktop environments to recognize it as a valid shortcut):chmod +x /home/user1/here.desktopUse the shortcut
- In a graphical file manager (like Nautilus, Dolphin), double-clicking
here.desktopwill directly open/tmp/subdir1/subdir2/here - If you need to launch it from the terminal, use the
xdg-opencommand:xdg-open /home/user1/here.desktop
- In a graphical file manager (like Nautilus, Dolphin), double-clicking
Key difference from symbolic links
- A symbolic link (
ln -s) is a filesystem-level pointer—any program that accesses it will treat it exactly like the target file/folder. - A
.desktopshortcut is a desktop environment-specific file: it’s more like a "launcher" with metadata (name, icon), and only graphical environments or tools likexdg-openwill interpret it correctly. For terminal-only use, symbolic links are still more efficient, but.desktopfiles give you that familiar Windows-style shortcut experience in a GUI.
内容的提问来源于stack exchange,提问作者code_fodder
相关产品推荐
相关产品推荐

