- How can I open a new terminal window from a cli command and print «Hello World»
- 2 Answers 2
- What is a terminal and how do I open and use it?
- 5 Answers 5
- What is it:
- Why use it:
- How do I open a terminal:
- Alternative names for the terminal:
- Common commands & Further information
- 5 Ways to Open a Terminal Console Window Using Ubuntu
- Use these shortcuts to quickly perform common tasks
- Open a Linux Terminal Using Ctrl+Alt+T
- Search Using the Ubuntu Dash
- Navigate the GNOME App Launcher
- Use the Run Command
- Use Ctrl+Alt+A Function Key
- Запуск терминала в Ubuntu
- Как открыть терминал в Ubuntu
- 1. Горячие клавиши Ctrl+Alt+T
- 2. Всплывающее окно «выполнить»
- 3. Главное меню системы
- 4. Системные терминалы
- 5. Открыть терминал в папке
- Выводы
How can I open a new terminal window from a cli command and print «Hello World»
I’ve been playing with the gnome-terminal command for some minor automations, and I keep running into the same issue. The goal is to open a new window in the same directory as the current window, and execute a simple command (i.e. echo, cd, or similar). This command seems to work fine to open the new window in the same directory:
However, when I add an execution to it, it fails:
I receive a message saying that -e is deprecated and I should use — so I swapped to
However I now receive this error:
Failed to execute child process “echo «test»” (No such file or directory)
Does anyone know why this is happening?
Exact System Specs: Ubuntu 18.04, GNOME Terminal 3.32.1 using VTE 0.56.2 +GNUTLS
The exact deprecation message is:
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
2 Answers 2
Ah. I see. The two messages are actually distinct.
I think this means that you should use -x , instead — everything on the command line after -x is considered to be part of the command to be executed.
This is a convention used in command line programs. The two dashes indicate that anything that comes afterward, regardless of whether or not it has a dash, is not a command line option. It’s useful in conjunction with -x , because you may have stuff that you don’t want parsed as one of the options to gnome-terminal — rather they’re command line arguments to be run inside the terminal.
I think an example would probably make this clearer.
This opens a gnome terminal. Inside the terminal we’re running grep, and excluding any line that contains the string «42». If we had not used — , gnome-terminal would see -v as a command line argument of gnome-terminal , and probably thrown a warning saying that -v is not a valid argument to gnome-terminal.
Ok, so both -x and -c are deprecated. You can execute commands without any flags. It does require using — to terminate all other options. so I was pretty much wrong about everything that I said. The rationale was solid, just wrong.
will open a new terminal, and launch nano inside the terminal.
Things get tricky when you try
It runs, but it exits so fast that you don’t see anything other than a flash on the screen.
Note that there is also an open bug about the deprecation of -c :
To clarify the issues in the OP, 2 Points:
the (unexplained) error indicates that the «command» is
i.e. it is trying to run the program stored in the file named echo «test» (being the single argument after the —). The correct syntax would be
but (as stated by Barton Chittenden) that then results in the terminal window appearing and disappearing (after executing the echo) almost instantly (probably faster than the screen refresh rate, giving the appearance that nothing happened). It needs some delay. So try
(I know this is wrong, wait for the analysis)
but this just seems to do nothing for longer. Reason:- ; is a reserved symbol (control operator) and terminates the argument list for gnome-terminal . The sleep 5 is a separate command executed after the (do nothing) gnome-terminal . Trying to quote the ; is ineffective:
This is syntactically valid if what you want is to display test ; sleep 5 in a nanosecond window. No, the problem here is that we are trying to execute a command LIST not a command (single executable). So the answer is:
Execute a general command line in a new window using «sh -c»:
P.S. For the pedants, I know that spaces around ; and the » around (the single word) test are unnecessary. Also, I have used the generic sh to represent whichever version is in use on the target system (and assumed that -c works as in Bourne shell). Further, the shell variable ( DIR in the example) is redundant, just use —working-directory=$(pwd) , unless you want to use the value again within the subsequent command (line). In fact, in my testing, gnome-terminal starts in the current directory of the invoking process, so —working-directory is almost certainly redundant here. Finally, the question wanted to print «Hello World», so the (fully and minimally) correct answer (with added delay) is:
P.P.S. While testing the (deprecated) -e and -x options, the following was noted (V3.28.2):
-x has the same effect as — , further argument processing is still inhibited. This possibly explains the «odd» error
as it is trying to execute the command — . (Didn’t get this exact error in my testing, just the standard «—» No such file or directory .)
Источник
What is a terminal and how do I open and use it?
5 Answers 5
What is it:
The terminal is an interface in which you can type and execute text based commands.
Why use it:
It can be much faster to complete some tasks using a Terminal than with graphical applications and menus. Another benefit is allowing access to many more commands and scripts.
A common terminal task of installing an application can be achieved within a single command, compared to navigating through the Software Centre or Synaptic Manager.
For example the following would install Deluge bittorrent client:
To save a detailed list of files in the current directory tree to a file called listing.txt :
Sometimes you will also see the following notation:
This means that the command whoami is executed which gives calum as output. Following that command, ls is executed which outputs Downloads Documents .
A similar notation is:
This means that the command should be run as root, that is, using sudo :
Note that the # character is also used for comments.
How do I open a terminal:
Open the Dash (Super Key) or Applications and type terminal
Use the keyboard shortcut by pressing Ctrl + Alt + T .
For older or Ubuntu versions: (More Info)
Applications → Accessories → Terminal
Alternative names for the terminal:
- Console
- Shell
- Command line
- Command prompt
Common commands & Further information
A Terminal is your interface to the underlying operating system via a shell, usually bash. It is a command line.
Back in the day, a Terminal was a screen+keyboard that was connected to a server. Today, it is usally just a progam.
You can open it via the utilities part of the apllications menu, or press Alt + F2 and type gnome-terminal .
The terminal (also known as console) is an application in which you can execute commands directly. It looks like:
You can start the terminal from Applications -> Accessories -> Terminal.
If you’re not using Gnome, but KDE (Kubuntu), you would find it under: Kickoff menu -> Applications -> System -> Konsole.
The Ubuntu wiki has an article about the terminal which includes information on starting the terminal in Xubuntu and Lubuntu, and a basic overview of commonly used commands. It’s recommended for reading as it includes much examples as well.
A Terminal is a command interpreter. A Terminal is an entity that takes input from the user and deals with the computer rather than the user deal directly with the computer. If the user had to deal directly with the computer he would not get much done as the computer only understands strings of 1’s and 0’s
Example
When a person drives a car, that person doesn’t have to actually adjust every detail that goes along with making the engine run, or the electronic system controlling all of the engine timing and so on. The dashboard would also be considered part of the the Terminal since pertinent (Having logical precise relevance to the matter at hand) information relating to the user’s involvement in operating the car is displayed there. In fact any part of the car that the user has control of during operation of the car would be considered part of the Terminal.
Terminal is a program that allows the user to use the computer without him having to deal directly with it. It is in a sense a protective shell that prevents the user and computer from coming into contact with one another.
Источник
5 Ways to Open a Terminal Console Window Using Ubuntu
Use these shortcuts to quickly perform common tasks
It’s possible to do most of the things you want to do in Linux without using the Linux terminal. However, there are many good reasons to learn how to use it. The Linux terminal provides access to the Linux commands as well as command-line applications that often provide more features than desktop applications. Another reason to use the terminal is that online help guides that solve problems with a Linux environment contain Linux terminal commands.
People use an array of desktop environments as well as Linux distributions. Hence, the terminal commands are usually the same or are easier to narrow down than writing full graphical instructions for each combination.
When using Ubuntu, it is easier to install software using the command line than it is to use the graphical software tools available. The apt-get command provides access to every package in the Ubuntu repositories, whereas the graphical tool is often lacking.
Open a Linux Terminal Using Ctrl+Alt+T
The easiest way to open a terminal is to use the Ctrl+Alt+T key combination. When you hold these three keys at the same time, a terminal window opens.
Search Using the Ubuntu Dash
If you prefer a graphical approach, select either the Activities launcher in the upper-left corner of the desktop or the Show Applications icon in the lower-left corner.
In the search box, enter term. As you type, the terminal icon appears. You will likely see an option for the default GNOME terminal at the top. Below, other terminal emulators that are available to install are listed.
To use the default one for your system, select the GNOME one at the top. It’s called Terminal.
Navigate the GNOME App Launcher
Another way to open a terminal window is to navigate the GNOME applications menu. Select Show Applications in the lower-left corner of the desktop. Then, select All at the bottom of the screen, if it isn’t highlighted, scroll down, and select Utilities.
There are several system tools under Utilities. The Terminal is one of those utilities. Select it to open it.
Use the Run Command
Another relatively quick way to open a terminal is to use the run command option. To open the run command window, press Alt+F2. To open the terminal, type gnome-terminal into the command window, then press Enter on the keyboard.
You must enter gnome-terminal because that is the full name of the terminal application.
You can also type xterm for the xterm application or uxterm for the uxterm application if those are installed on your system.
Use Ctrl+Alt+A Function Key
The methods illustrated so far open a terminal emulator in the graphical environment. To switch to a terminal that isn’t linked to the current graphical session, usually when installing certain graphics drivers or doing anything that messes with your graphical setup, press Ctrl+Alt+F3.
You will need to log in because you are starting a new session.
You can use F4 through F10 to create more sessions.
To get back to the graphical desktop, press Ctrl+Alt+F2.
Источник
Запуск терминала в Ubuntu
Терминал — это один из самых важных инструментов Linux. Когда графический интерфейс не был ещё так популярен, все действия выполнялись через командную строку или, другими словами, терминал. В наше время терминал потерял своё значение в Windows, но всё ещё остаётся очень мощным инструментом в Linux. В командной строке можно сделать всё, что только возможно, и более тонко настроить систему.
В сегодняшней статье мы поговорим о том, как открыть терминал в Ubuntu Linux с помощью различных способов, начиная горячими клавишами и заканчивая графическим интерфейсом. Хотя статья ориентирована на Ubuntu, большинство способов будут работать и в других дистрибутивах.
Как открыть терминал в Ubuntu
1. Горячие клавиши Ctrl+Alt+T
Это особенность дистрибутива Ubuntu, вы можете открыть терминал Linux в любом графическом окружении, просто нажав сочетание клавиш Ctrl+Alt+T одновременно:
Если вам не нравиться это сочетание клавиш, то его можно очень просто настроить. Для этого откройте утилиту Настройки -> Устройства -> Клавиатура и найдите там пункт Открыть терминал:
Далее вы можете задать комбинацию из трёх клавиш.
2. Всплывающее окно «выполнить»
Почти во всех окружениях при нажатии сочетания клавиш Alt+F2 открывается строка ввода, из которой уже можно выполнять команды и запускать программы:
Но вывод команды здесь вы не сможете увидеть, поэтому надо запустить полноценный терминал. В Gnome это gnome-terminal:
А в KDE эмулятор терминала называется — konsole:
В других окружениях рабочего стола команда может отличаться. Если вы не знаете, какая команда используется в вашей системе, смотрите следующий способ.
3. Главное меню системы
В главном меню дистрибутива собраны все установленные программы. Сначала нажмите клавишу Windows (Super), чтобы открыть главное меню. В том числе там есть и терминал. В окружении Gnome вы можете набрать начало имени программы, например «терм» или «term», и система отобразит доступные для запуска программы.
Просто выберите в списке нужную программу, чтобы запустить терминал Linux. Если же поиска в вашем меню нет, то терминал следует искать в категории Системные или Утилиты:
4. Системные терминалы
По умолчанию в любом дистрибутиве Linux открыто 12 системных терминалов. Вы можете использовать один из них. Вернее, вам доступно только 11, потому что в одном уже открыто ваше графическое окружение, в котором вы работаете. Обычно, это первый или седьмой терминал. Это не совсем запуск терминала Ubuntu, так как эти терминалы уже запущены.
Для переключения между этими терминалами используется комбинация клавиш Ctrl+Alt+F и номер терминала. Например, Ctrl+Alt+F2 или Ctrl+Alt+F3. После нажатия этого сочетания графическое окружение исчезнет, а вместо него появится черный экран с предложением ввода логина и пароля:
Если вы введёте правильные данные для аутентификации, откроется терминал Linux.
Эти терминалы можно использовать для настройки системы или для восстановления её работоспособности, если графическое окружение зависло. Чтобы вернуться обратно в графическое окружение, откройте первый терминал — Ctrl+Alt+F1.
5. Открыть терминал в папке
Если у вас запущен файловый менеджер Nautilus, и вы хотите открыть терминал Linux в текущей папке, то сделать это очень просто. Откройте контекстное меню и выберите открыть в терминале:
Выводы
В этой небольшой статье мы рассмотрели, как запустить терминал в Ubuntu. Терминал — это очень мощный инструмент, который позволяет настроить систему так, как вы захотите. Только надо во всём разобраться. А начать можно со статьи «44 команды терминала которые вы должны знать».
Источник