How to create shortcut in linux

How to make a desktop shortcut on Ubuntu 20.04?

What is the most elegant way to create desktop shortcuts (e.g. to folders, applications, or documents) in Ubuntu 20.04?

@GeorgeUdosen From the top answers it doesn’t look much different from the way it used to work in older releases though (for example: askubuntu.com/a/457377/480481).

NONE of the suggested solutions worked for me. It is absolutely crazy that in 2021 you cant add a link to a launch bar. I ended up creating a link using ln command, but that still wouldn’t allow me to add my app to the launch bar

16 Answers 16

For Application Shortcuts:

I think TheBuntuNewb’s answer is pretty good. Do that using file manager:

  1. Open /usr/share/applications
  2. Copy the application shortcut to desktop
  3. Right click on the shortcut on the desktop and select Allow Launching

For Folder/File shortcuts:

Either directly use the terminal to create a symbolic link

  1. Open the folder in the file manager (nautilus), navigate to the directory to which you want to create a shortcut to.
  2. Right click and select Open in Terminal.
  3. For shortcut to current directory, type and execute

I will suggest to use «$PWD» , as if you have spaces in folder paths, this will not create correctly. Thanks for this.

This should be the accepted answer because it actually allows to create a desktop shortcut, rather than suggesting you to reuse a shortcut which can only exist for only certain installed applications.

You can copy a file from /usr/share/applications to your desktop folder ( ~/Desktop ) using the cp command. Then right click the .desktop file and select ‘allow launching‘.

cp /usr/share/applications/nautilus.desktop ~/Desktop 

Make sure to include the .desktop ending.

You might also have to allow launching for an existing .desktop file after upgrading to Ubuntu 20.04.

Yes I was able to launch the file but the icon looks like a cog, but you can change that by right clicking the fille, choosing properties, click the icon and select the proper one

1.1. enable symbolic links in nautilus: Settings → Behavior → [x] Show action to create symbolic links

  1. open two windows of nautilus. one for the desktop, second for the shortcut you want to produce.
  2. click the item the shortcut has to produced for with the left mouse button and drag it to the desktop folder in your home directory with the ALT-key pressed.
  3. when you leave the item on the desktop folder a context meune appears, that give you three options. One of them is «create symbolic link» or so.

Its awful, that this simple feature has to be done the complex way.

On default DE (Gnome 3) symlinking does not work, but .desktop files copying works as TheBuntuNewb said: enter image description here enter image description here enter image description here

For Lubuntu 20.04 desktop the next works:

Displaying items on the desktop could be done using .desktop file copying, .desktop file or folder symlinking or .desktop file creating.

user@ubuntu:~$ ls -ailh ~/Desktop/ total 32K 8126477 drwxrwxr-x 2 user user 4,0K тра 1 12:58 . 8126465 drwxr-xr-x 21 user user 4,0K тра 1 11:49 .. 8130587 -rwxr-xr-x 1 user user 239 кві 20 17:38 anydesk.desktop 8126512 -rw-rw-r-- 1 user user 90 тра 1 12:48 computer.desktop 8130987 lrwxrwxrwx 1 user user 22 тра 1 12:58 Documents -> /home/user/Documents 8130976 -rw-rw-r-- 1 user user 97 тра 1 12:51 Downloads.desktop 8129570 lrwxrwxrwx 1 user user 45 тра 1 12:30 google-chrome.desktop -> /usr/share/applications/google-chrome.desktop 8126514 -rw-rw-r-- 1 user user 94 тра 1 12:48 network.desktop 8129813 -rw-rw-r-- 1 user user 102 тра 1 12:58 trash-can.desktop 8126513 -rw-rw-r-- 1 user user 89 тра 1 12:48 user-home.desktop 
  • anydesk.desktop file is copied: `cp /usr/share/applications/anydesk.desktop ~/Desktop/
  • google-chrome.desktop is symlinked using ln -s /usr/share/applications/google-chrome.desktop /home/user/Desktop/
  • Documents link is created by: ln -st /home/user/Desktop /home/user/Documents
  • Downloads.desktop file which opens the Downloads directory by nautilus is created the next way:
[Desktop Entry] Type=Application Exec=nautilus /home/user/Downloads Icon=folder Name=Downloads 

In my case file properties changing is not required for .desktop file — it asks to execute it anyway:

Источник

How to Create Shortcut on Linux ( GUI & CLI)

Shortcuts on your desktop screen are useful for easy and fast navigating to folders you need quick access to. Also, if you have an application you use often, you can launch it using the desktop shortcut.

When Windows users switch to Linux for the first time, one of the common struggles for them is to create shortcuts on Linux. The thing is, creating desktop shortcuts isn’t as straightforward in Linux as it is in Windows.

But that doesn’t mean it’s impossible to do so. This tutorial will show you the different methods of creating desktop shortcuts of folders and software on your Linux machine.

For demonstration purposes, we will be using Ubuntu 22.04. So if you are using a different distribution, you may need to do some modifications in some cases. But the base idea is the same.

Linux Create Shortcut Using Command Line Interface (Terminal)

First, we will see how to create shortcuts using terminal commands. No matter which Linux distro you are using (Ubuntu, Linux Mint, CentOS, OpenSUSE) you can always use the CLI for creating shortcuts.

So launch your terminal using “Alt+Ctrl+T” and follow along with this tutorial.

Method #1: Copying folder/application to the desktop

We will first navigate to the folder (or directory) where our application is at. This folder will vary depending on the application and your Linux distro.

For Ubuntu, it’s /usr/share/applications. So go to this directory with the following command:

cd command

Now look at the list of applications in this folder with the ls command:

ls command

You can scroll down to see the full list. So in this example, we will create a desktop shortcut of ‘CodeBlocks’. You need to copy the file of your desired application and move it to the desktop. You can do that with this command:

You have to replace with the original file name and with the desktop directory. Here’s what it looks like in our case:

$ cp codeblocks.desktop /home/ali23/Desktop/

cp command

create shortcuts on linux

Nice. We’ve successfully copied the app to our desktop. But we’re not finished yet. If you try to launch the app, you will run into an error. That’s because the copied version of the app doesn’t have the required permission to run. But we can change that.

Left-click on the icon. Press “Allow Launching”. The icon will change.

create shortcuts on linux

Run the app. It should launch successfully. If not, try changing its permission.

Navigate to the desktop directory using these commands.

cd command

Now you need to change the file permission using chmod like this:

$ chmod u+x codeblocks.desktop

chmod command

Another way to create shortcuts on Linux is using Symlinks. For this, we use the ln command. The only catch is that ln creates hard links. But we need short links. We can do that by using a flag.

Here is what the basic command looks like.

The first argument will be the directory of your desired file or app. The second argument, in this case, is the Desktop directory.

So, for example, we want to create a shortcut for ‘Vim’. This will be the command we need to use:

$ ln -s /usr/share/applications/vim.desktop ~/Desktop/

create symlinks on linux

create shortcuts on linux

You don’t have permission to launch it. So, change the permission mode as shown previously:

$ cd Desktop/$ sudo chmod u+x vim.desktop

chmod command

Finally, right-click on the icon and press “Allow Launching.”

create shortcuts on linux

Method #3: Creating a “.desktop” file

In this method, we will just create a “.desktop” file from scratch. We’re creating a shortcut for Evince document viewer. So we’ll need the path of where the application is located. You can know that with this command:

which command

We will need this information later.

Now we need to open a text editor. We’ll be using nano. Feel free to use your favorite one. Open the file in the text editor with this command:

$ nano ~/Desktop/Evince.desktop

linux nano

Replace the directory path and file name with one suitable for your device.

Now copy and paste this template into the file:

[Desktop Entry] Version= Type= Terminal= Exec= Name= Comment= Icon=

You will need to fill in the right side with the correct values. Here is what it looks like in our case:

linux desktop file create

The most important part is the “Exec” line. Remember the path we got from the which command? Paste that in this line.

Once done, save by pressing “Ctrl+O”. Then quit by pressing “Ctrl+X”.

Right-click on the icon and click “Allow Launching”.

create shortcuts on linux

Creating Desktop Shortcuts Using GUI

linux files

linux navigation

  1. Go to usr > share > applications. You will find a list of all the applications you saw earlier.

linux navigation

  1. Right-click on the file you want to create a shortcut of. Then press “Copy”. Alternatively, you can left-click the icon and press “Ctrl+C”.

copy file linux

  1. Finally, return to the Desktop. Right-click on any empty space to open the options. Click on “Paste”. Alternatively, press “Ctrl+V”.
  2. Lastly, right-click on the icon and press “Allow Launching”.

create shortcuts on linux

Final Thoughts

This tutorial shows you the different methods of creating shortcuts on a Linux desktop. We’ve covered both the GUI and CLI method so you can do it whichever way you prefer.

You can create shortcuts without writing commands if your Linux distro is GUI-friendly. But if you feel more comfortable on the terminal or your distro isn’t so GUI-centric, then any of the 3 methods should work for you.

If you have any questions regarding this tutorial, feel free to let us know in the comments below.

If any of the above solutions did not fix the Windows PC issues, we recommend downloading the below PC repair tool to identify and solve any PC Issues.

Dinesh

Dinesh is the founder of Sysprobs and written more than 400 articles. Enthusiast in Microsoft and cloud technologies with more than 15 years of IT experience.

Источник

Читайте также:  Linux низкоуровневое форматирование hdd
Оцените статью
Adblock
detector