5

This is a double question.

The first one is: can I put a terminal shortcut on an Ubuntu desktop and how (the double-click is supposed to launch the terminal window)

The second is: is it possible to launch the terminal directly with a command? That is, any time it starts it must directly call sudo apt-get...

Any help is appreciated.

  • 4
    Welcome to askubuntu ! Typically it is advised to split posts into one question per post. In your case , it can be condensed into one, because to make shortcut you actually need to know the command. – Sergiy Kolodyazhnyy Jan 13 '16 at 17:09
  • 1
    It is best if you address one issue per question :) – Ron Jan 13 '16 at 17:09
  • @Serg: Oh, thanks for your comment! Ron: is the answer too complex? –  Jan 13 '16 at 17:10
  • @kos: maybe half duplicate at this point ;-) –  Jan 13 '16 at 17:11
  • Answer isn't complex, but has bunch of tiny bits that need explaining – Sergiy Kolodyazhnyy Jan 13 '16 at 17:15
  • Wrong question, sorry: http://askubuntu.com/q/64222/380067. Maybe the second answer is more suitable if you don't want to install additional packages. – kos Jan 13 '16 at 17:15
  • I love Ubuntu but this should be more simple... :-( –  Jan 13 '16 at 17:16
  • I'm writing an answer, will post soon – Sergiy Kolodyazhnyy Jan 13 '16 at 17:17
  • Answer posted, slightly edited , let me know if you have any further questions – Sergiy Kolodyazhnyy Jan 13 '16 at 17:31
  • Upon re-reading it's not clear what you're trying to do, do you want to know how to launch the terminal by double-clicking on a shortcut and run sudo apt-get [...] automatically in that specific terminal or do you want to know how to launch the terminal by double-clicking on a shortcut and run sudo apt-get [...] automatically in whatever terminal? If the first one please clarify, If the second one please split the post into two different questions. – kos Jan 13 '16 at 17:33
  • @kos: the ideal it would be the possibility to have on the same computer two different terminal icons, one opening a regular terminal window and another one (custom) launching the terminal from desktop directly with a certain command –  Jan 13 '16 at 17:41

1 Answers1

7

The actual command that launches Terminal is . . .gnome-terminal. There are actually many different Terminal Emulators. For instance, I am using sakura right now, a lot of people like Terminator , the classic one is xterm (which by the way also comes with Ubuntu and pretty much any Linux distro that has graphical environment).

What you call "shortcut" in Windows world is an .lnk file. In Ubuntu world there is something similar, .desktop files. They are used for a lot more than just running some app - you can also use them to launch stuff on GUI login if you put those files into .config/autostart folder (notice the leading dot). The structure of those files is as follows :

[Desktop Entry]
Type=Application
Exec=**actual command goes here**
Hidden=false
NoDisplay=false
Terminal=false

So knowing that you could create a file like this:

[Desktop Entry]
Name=MY-CUSTOM-APP
Type=Application
Exec=gnome-terminal
Hidden=false
NoDisplay=false
Terminal=false
Icon=/usr/share/icons/gnome/48x48/apps/terminal.png

The Icon field can be ignored sometimes, but if you want the shortcut to look pretty, give it a full path to the image.

Also, there exists a folder with all the .desktop files, the /usr/share/applications, and there is /usr/share/applications/gnome-terminal.desktop. One could copy over such file to /home/user/Desktop/. Problem is, those files are owned by root user, so you have to do something along these lines:

cp /usr/share/applications/gnome-terminal.desktop /home/$USER/Desktop/Terminal.desktop

chown $USER:USER /home/$USER/Desktop/Terminal.desktop

chmod +x /home/$USER/Desktop/Terminal.desktop
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • a little question: I must tell a 10 years old boy he can change the icon. He doesn't know anything about permissions but he can put the icon in the Pictures folder. I can tell him not to delete it, but isn't there any way to protect that icon from accidental removal? –  Jan 17 '16 at 13:40
  • (it should be something he can do without using the terminal, of course) –  Jan 17 '16 at 13:47
  • @IanBell In file manager, you can right click on an image, select properties option, and it should display small properties window. There will be the Permissions tab, where you can set the permissions form drop down menus. That should prevent deletion by others, but not the owner. I'll think if there's any other way, but probably this is the best I can offer – Sergiy Kolodyazhnyy Jan 17 '16 at 19:14