- Command to open new terminal window from the current terminal?
- 3 Answers 3
- What is a terminal and how do I open and use it?
- Why use it:
- How do I open a terminal:
- Alternative names for the terminal:
- Common commands & Further information
- How to open a Linux terminal window
- The shell
- The terminal emulator
- Opening the Linux terminal window
- Option 1
- Option 2
- Wrapping up
Command to open new terminal window from the current terminal?
I installed xdotool by running sudo apt-get install xdotool and throw xdotool key ctrl+alt+t command to open a new terminal window from the current one.But it was not working. What was the command to open a new terminal window from the current gnome-terminal?
3 Answers 3
Just this command will do:
Normally if you want a command to open from the terminal and separate (so it returns to the prompt without having to close the opened program), you have to use something like this:
However the parent terminal seems to detect that the same command is being used so you don’t need to do that and gnome-terminal will suffice. This also seems to happen when running xfce4-terminal from Xfce’s terminal, konsole from KDE’s as well (doesn’t seem to work when running xterm from xterm (see also xterm xterm ) — Running konsole from Gnome/Unity & Xfce’s terminal works as well, but for Xfce’s terminal in gnome terminal you need xfce4-terminal & disown ).
gnome-terminal [-e, --command=STRING] [-x, --execute ] [--window-with-profile=PROFILENAME] [--tab-with-profile=PRO‐ FILENAME] [--window-with-profile-internal-id=PROFILEID] [--tab-with-profile-internal-id=PROFILEID] [--role=ROLE] [--show-menubar] [--hide-menubar] [--geometry=GEOMETRY] [--disable-factory] [-t, --title=TITLE] [--working-direc‐ tory=DIRNAME] [--usage] [-?, --help]
You probably want to run it in the background, like that: gnome-terminal & . Otherwise the current terminal will be unusable, as it will be busy running that other one — so you end up with just one usable terminal, which may be missing the point.
Interesting. You are apparently right, however, I am not wrong neither 🙂 I’ve just checked that in details. If I run gnome-terminal while another instance of it is already running (it may be the one I’m using to launch this command) — it indeed finishes immediately, because instead of running a new instance gnome-terminal , it tells that currently running one to open a new window. Tricky. But if I run gnome-terminal from anything else, and there are no other instances of gnome-terminal running, it does as I explained in the previous comment, blocking the terminal used to launch it.
@RafałCieślak — anyway, konsole doesn’t seem to need at all. weird. I have no idea why this question/answer is so popular 🙂
Thanks very much, if you want to open a terminal with the same directory you could do this, gnome-terminal .
Command to open new terminal window from the current terminal,
sudo apt-get install xdotool
I don’t see any reason to use xdotool key ctrl+shift+n while using gnome-terminal you have many other options; see man gnome-terminal in this sense.
Still think this neat 🙂 is there any equivalent for Mir or Wayland (for implementations not compatible with X server stuff)
The following script will open a new tab in the current gnome-terminal window and optionally give that tab a title. This works from any window, you don’t have to be in a gnome-terminal window to run it. And, if there is no gnome-terminal running, it will start one. The only caveat is that if you changed the hotkey for opening a new tab you might have to change the line xdotool key ctrl+T to use your hotkey instead.
#!/bin/bash DELAY=1 # get title we are going to set tab too, default to Terminal title="Terminal" if [ $# -eq 1 ]; then title="$1" fi # get pid of running terminal server TPID=$(ps -C gnome-terminal-server -o pid | tail -1 | sed -e's/\s//g') if [ $ == "PID" ]; then # no terminal process running yet, so just start one gnome-terminal -t "$title" --tab exit 0 fi # there is a terminal, get window id of the running terminal server WID=$(wmctrl -lp | awk -v pid=$TPID '$3==pid') # get title of currently active tab TTITLE=`xwininfo -id 0x5000006 | grep xwininfo | awk ''` if [ "$TTITLE" == "\"Terminal\"" ]; then # so we don't go into an infinite loop later TTITLE="we had a terminal named terminal $$" fi # get focus on active terminal tab xdotool windowfocus $WID # use keyboard shortcut to open new tab xdotool key ctrl+T # see if we have created tab and are in terminal NTITLE=`xwininfo -id 0x5000006 | grep xwininfo | awk ''` waited=0 while [ "$TTITLE" == "$NTITLE" ]; do # sleep for 1 second before we try again xdotool sleep 1 NTITLE=`xwininfo -id 0x5000006 | grep xwininfo | awk ''` if [ $waited == 0 ]; then echo "Waiting " waited=1 fi echo -n "." done if [ $waited == 1 ]; then echo "" fi # active tab is the new one we created, wait DELAY seconds just to be sure we can type into it to set tab name xdotool sleep $DELAY xdotool type --clearmodifiers "termtitle $title" xdotool key Return # make tab the active window and raise it to top wmctrl -i -a $WID exit 0
What is a terminal and how do I open and use 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:
sudo apt-get install deluge
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:
$ whoami calum $ ls Downloads Documents
This means that the command whoami is executed which gives calum as output. Following that command, ls is executed which outputs Downloads Documents .
This means that the command should be run as root, that is, using sudo :
Note that the # character is also used for comments.
# this command will give your username whoami # the next command will show the contents of the current directory ls
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:
Common commands & Further information
Another reason that people helping you will prefer to give you terminal-based commands over directing you through a GUI is simply because you type everything in directly. There’s no searching for applications and/or menu items. Don’t be put off by the sole text-interface. To this day, whenever I open a command-prompt in Windows, people instantly ask me if I’m hacking their computer or some other such nonsense. The terminal is your friend.
Lazy tip: You can use drag and drop to drop files and folders from the filemanager into the terminal, which will give you the complete path to apply a command to the file. It’s the best of both worlds.
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.
«Shell» and «terminal» don’t really mean the same thing. For example, in the screenshot above, the terminal is probably gnome-terminal . The shell is probably bash .
Strictly speaking, those are indeed not the same. However, I mentioned it because the word «shell» is often used to refer to the place where you can enter commands. It happens to be that the terminal opens that shell, but a novice user may not directly relate it.
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
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.
How to open a Linux terminal window
Say you are new to Linux world and just installed Linux desktop and now you would like to fire up terminal window and start issuing commands, but wait you don’t know how to access a terminal window in Linux, in this article I will walk you through how to open a Linux terminal window and set up a keyboard shortcut for easier access.
Before I begin, allow me to explain the basic differences between a shell and a terminal emulator.
The shell
The shell is a command-line interface program that takes commands from the user as an input, processes the command, and prints out the output to the display. In most Linux systems, you will find bash (Bourne Again SHell) installed and is the default, Bash is an enhanced version of Unix shell program sh (shell). Apart from bash, there are other shell programs that can be installed on Linux machines such as ksh, zsh, and csh.
The terminal emulator
Simply put, a Terminal Emulator is a program that allows users to interact with shell in the graphical user interface (GUI) environment.
Some familiar terminal emulators you might find in Linux distros are:
Opening the Linux terminal window
I am using a Centos 8 Machine with the Gnome Desktop Environment. I’m going to show you two different ways to open a Linux terminal window.
Option 1
Gnome desktop environment makes easy access of application, in order to access the terminal window, press the super key (aka Windows key) and you should see Terminal application listed on the left-hand side application pane if you don’t see it listed on here simple start searching for “Terminal” in the search area.
You should see a Terminal Emulator application
Option 2
The other way (my favorite) is to open the terminal window is with a keyboard shortcut. Who doesn’t like to have a keyboard shortcut? Keyboard shortcuts make it easier to launch apps.
You can create a keyboard shortcut to open a terminal window, create a new shortcut, press the super key and search for “keyboard” or “shortcut” and launch it.
Click on “+” option at the end of the list to create a new keyboard shortcut.
Provide the required information, Like Name of the shortcut, command. You can name this anything you would like to, I named it “Open Terminal Window”, the command, in this case, is “gnome-terminal” since gnome-terminal is installed on centos and RHEL machines. If you have other terminal emulators such as “konsole” provide that command in this field. In the next article, I will show you how to install other Linux terminal emulators.
Click on set shortcut button to set a new keyboard short cut, this is where you register key combination to launch the terminal window.
I used CTRL + ALT + T, you can use any combination, but remember this key combination should be unique and not being used by other keyboard shortcuts.
Finally, click on Add to register this keyboard shortcut and you’re all set to use the new terminal window shortcut you created.
Wrapping up
Whether you choose to create a keyboard shortcut to launch a terminal window or to simply launch it from Applications, it’s simple to open the Linux terminal window in Linux. The process is similar to other desktop environments. For myself, I like the luxury of using keyboard shortcuts. In a future article, I will show you how to install additional terminal emulators onto your Linux system. Until then, enjoy practicing at your new-found graphical command line.
Want to try out Red Hat Enterprise Linux? Download it now for free.