How do I create a shortcut to a command?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Imagus
Level 3
Level 3
Posts: 129
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

How do I create a shortcut to a command?

Post by Imagus »

Hello,

I have succesfully downloaded and installed an online chess program called "jin". After unpacking the file in a separate directory, I tried to start the program by clicking on "jin", but that didn't work - even though the included readme file told me to do it this way. The only way I can get the program to work is by opening a terminal in the jin directory, and then type: java -jar jin.jar

How do I create a shortcut on my desktop that will automatically run this command when I click on it?

Thanks for helping an absolute beginner.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
nick
Level 5
Level 5
Posts: 684
Joined: Sat Dec 02, 2006 8:04 am

Post by nick »

Hi

Right Click on desktop/create launcher, under command put
java -jar jin.jar, check the box marked "run in terminal"

Name-"whatever you want"

Click on icon box to choose icon.

Nick
User avatar
Imagus
Level 3
Level 3
Posts: 129
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Post by Imagus »

Thanks for your reply. Unfortunately it doesn't work, I keep getting an error message when I click the launcher. If I try the command as Application, I get this error:

There was an error launching the application
Details: Failed to execute child process "/media/
sdb1/Linux/jin" (No such file or directory)

And when I try it as Application in Terminal, I get this:

There was an error creating the child process for this terminal

I also tried to change the command from just "jin" to "jin.jar" and even "java -jar jin.jar", but that didn't help either. :cry:
User avatar
Boo
Level 7
Level 7
Posts: 1633
Joined: Mon Mar 26, 2007 7:48 am

Post by Boo »

sounds like you do not have write permission to /media/sdb1/Linux/jin.

did you cd into the jin directory and run the command?
it worked that way before.

could you post the output of

ls -l /media/sdb1/Linux/jin

did you unpack the program as yourself or with a sudo ?

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
Imagus
Level 3
Level 3
Posts: 129
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Post by Imagus »

Boo wrote:sounds like you do not have write permission to /media/sdb1/Linux/jin.

did you cd into the jin directory and run the command?
it worked that way before.

could you post the output of

ls -l /media/sdb1/Linux/jin

did you unpack the program as yourself or with a sudo ?

:D

I have entered the command you suggested and I got this:

luc@luc-desktop:~$ ls -l /media/sdb1/Linux/jin chess/jin-2.14.1/jin
ls: /media/sdb1/Linux/jin: No such file or directory
ls: chess/jin-2.14.1/jin: No such file or directory

This looked like it was caused by the space in the directory name, so I renamed it to jinchess without the space, and then tried again. This time I got:

luc@luc-desktop:~$ ls -l /media/sdb1/Linux/jinchess/jin-2.14.1/jin
-rwxrwxrwx 1 root luc 668 2007-08-01 23:03 /media/sdb1/Linux/jinchess/jin-2.14.1/jin

I have no idea what the ls-command does, but at least it seemed to do something. So I also removed the space from the command in the launcher and... it works!

I never would have thought it would be this simple... Gosh, I feel such a newbie...

Anyway, thank you for your help!
scorp123
Level 8
Level 8
Posts: 2272
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 »

Imagus wrote: I have no idea what the ls-command does
The manual is your friend.

Code: Select all

man ls
LS(1) User Commands LS(1)

NAME
ls - list directory contents

SYNOPSIS
ls [OPTION]... [FILE]...

DESCRIPTION
List information about the FILEs (the current directory by default).
...
...
User avatar
Boo
Level 7
Level 7
Posts: 1633
Joined: Mon Mar 26, 2007 7:48 am

Post by Boo »

FYI
spaces in Linux/Unix have meaning.
I avoid putting spaces in file and directory names.

if there is a space in a file/dir name you have 2 options:
put the whole path in quotes
or
dereference the space with a backslash.

eg for you origional ls you could have done:
ls -l "/media/sdb1/Linux/jin chess/jin-2.14.1/jin"
or
ls -l /media/sdb1/Linux/jin\ chess/jin-2.14.1/jin

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
Imagus
Level 3
Level 3
Posts: 129
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Post by Imagus »

Thank you all for the replies. Unfortunately this has turned into a very annoying problem: the launcher only works until I restart my computer! I have tried it several times now, but every time I restart my computer, I need to create a whole new launcher! Even the chess icon has disappeared when Mint starts, all I get is this small white rectangle instead. And when I click that I get the same message as before: "There was an error creating the child process for this terminal".

Why is this? The program is still at its original location and when I create a new launcher everything works great again? I really don't get this...
scorp123
Level 8
Level 8
Posts: 2272
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 »

Boo wrote: I avoid putting spaces in file and directory names.
A wise choice. 8)
Boo wrote: if there is a space in a file/dir name you have 2 options:
put the whole path in quotes
or
dereference the space with a backslash.

eg for you origional ls you could have done:
ls -l "/media/sdb1/Linux/jin chess/jin-2.14.1/jin"
or
ls -l /media/sdb1/Linux/jin\ chess/jin-2.14.1/jin
Absolutely correct. Just a minor addition which I put here in the hope that it will benefit others who maybe don't know it: The thing with the backslashes is sometimes called "to escape ..." in some texts. So if someone writes "you have to escape the spaces in the file name" ==> he means that you should convert the empty space in a file name from " " into "\ " (as in Boo's second example above). The backslash here serves as "escape" signal and tells UNIX-like shells "OK, whatever weird character follows after the backslash -- just ignore it please and take it 'as is' ..."

Sometimes it can happen that you come across a file that has 'illegal' characters in its name from a UNIX shell point of view. e.g. files that start with dashes or question marks can be difficult to get rid of again (because both signs have their special meanings in shell programming and thus get interpreted in special ways). So putting the entire thing into quotation marks (Boo's first example above) or by placing backslashes in the right places (Boo's second example) you can avoid troubles and e.g. access and manipulate the file although the shell doesn't really like the filename.
User avatar
Boo
Level 7
Level 7
Posts: 1633
Joined: Mon Mar 26, 2007 7:48 am

Post by Boo »

delete the launcher and create a new one with the correct path to the application.

I suspect that when you changed the path in the launcher it does not really save it. some funny bug.

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
Imagus
Level 3
Level 3
Posts: 129
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Post by Imagus »

Hi,

I did create a new launcher, but the problem doesn't go away. Here is what I get after creating a new icon:

Image

... and here is what I get immediately after rebooting:

Image

As you can see, the path in the launcher properties has changed after reboot: sdb1 suddenly became sda1. When I change it back to sdb1 everything's fine again - although I have to manually put back the icon.

What is causing this change? Is this a bug in Mint? Does it have something to do with my hard disks?

Thank you,
Husse

Post by Husse »

both sda1 and sdb1 are large FAT32 volumes if I read your screenshot correctly. This may cause problems, but you should not have a change from sda to sdb. However sometimes programs (including an OS) are too smart for their own good.
Do you have a folder called Linux on sda1 as well? Could explain it
User avatar
Imagus
Level 3
Level 3
Posts: 129
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Post by Imagus »

I have two internal (40 and 320 Gb) and two external hard disks (320 and 250 Gb). The external hard disks are always connected to the computer, so every partition is always available to both Windows and Linux. I only have one folder named Linux, and it's always on the same partition (external hd 2, partition 1), so I assume the path in the launcher should always point to sdb1. I will try to move my Linux folder to another partition on hda or hdb to see if that helps.
Locked

Return to “Beginner Questions”