You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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/

  1. Create a .desktop file
    Open a text editor (like nano or gedit) and create a file named here.desktop in /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=Link tells the desktop environment this is a shortcut to a file/folder
    • URL specifies the full path to your target location (note the file:// prefix)
    • Icon lets you set a custom icon to match the target type (use any system icon name)
  2. 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.desktop
    
  3. Use the shortcut

    • In a graphical file manager (like Nautilus, Dolphin), double-clicking here.desktop will directly open /tmp/subdir1/subdir2/here
    • If you need to launch it from the terminal, use the xdg-open command:
      xdg-open /home/user1/here.desktop
      
  • 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 .desktop shortcut is a desktop environment-specific file: it’s more like a "launcher" with metadata (name, icon), and only graphical environments or tools like xdg-open will interpret it correctly. For terminal-only use, symbolic links are still more efficient, but .desktop files give you that familiar Windows-style shortcut experience in a GUI.

内容的提问来源于stack exchange,提问作者code_fodder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:26:37