Open shell linux command

How to open a command terminal in Linux?

I need the same thing in Linux. Thanks for your answers. I would like to run a sh script also. Whether the following code works.

String command= "usr/bin/xterm myshell.sh"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); 

Can you clarify? Do you want to open a terminal, or do you want to run a script? Users have a variety of different terminals, and you’d be hard pressed to guarantee that you can open one. But running a script, almost every linux box has /bin/sh (just not necessarily at that absolute path)

8 Answers 8

In Linux, there are a number of terminal emulators which allow you to interact with various shells. Each shell is basically a command interpreter that understands Linux commands (GNU & Unix commands is more correct I suppose. ). A terminal emulator provides an interface (window) for the shell and some other facilities for using the command prompt. To open a terminal window, you just have to modify your command string like this:-

import java.io.*; class TerminalLauncher < public static void main(String args[]) throws IOException < String command= "/usr/bin/xterm"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); >> 

The basic assumption I have made is that you want to open xterm, which is available on almost any system (with X installed of course). You might want to open another terminal emulator like rxvt, eterm, aterm, gnome-terminal or konsole. The command string can also be modified to use different shells like zsh. I suggest you catch an exception in case the terminal you chose isn’t present and handle it by asking the user to install it. A better solution is to accept command line arguments for the users preferred shell or to use a configuration file which the user can change to make your script open the shell of his/her choice.

Читайте также:  Linux user sudoers file

Note
1. As others have already pointed out, xterm (or any other terminal of your choice) may not be in the path specified (/usr/bin/. ) and may not even be installed, so you might have to use some fancy command string (Ex: pipelining find through grep to get the path to xterm before launching), which isn’t such a great idea. I think the best way is to let the user configure the whole thing.

2.I got a comment on this answer (by ypnos), suggesting that I avoid using absolute paths and rather rely on the command being in the PATH environment variable. I have to say I agree. In that case, the command string should be —

Do look at the comment, because it also points out the problem with using find.

Источник

How do you open the UNIX shell?

There is a keyboard shortcut that starts a Terminal session.

Alternatively, press the windows button and type Terminal

In the Desktop Environment start the program «Terminal» or press ctrl-alt-F2 (F1 to F6 is normally possible).

  1. Click the launcher enter image description here
  2. Type terminal
  3. Click the terminal app that is shown enter image description here
  4. Start using the terminal window shown enter image description here

You are likely looking to open a terminal which can be accomplished by opening your dashboard/start menu and typing terminal in the search bar.

As a point of context: The shell is less the window you enter commands into, and more the environment in which the commands are interpreted. There are a few different options as far as shells are concerned, the default and most widely used for Linux being bash . There is also however tcsh and just plain sh

Each has their own particular usage style as well as strengths and weaknesses.

You can open the graphical terminal in any of the ways others have mentioned:

  1. Click on the «start» button thing and type «terminal»
  2. Hit the Windows key (aka Meta key) to open the command launcher, and type «terminal» or «gnome-terminal»
  3. Open the start button thingy and browse through to find the terminal.
Читайте также:  Cryptopro csp linux gui

In addition to opening the graphical terminal, if you want to look really cool, type Ctrl+Alt+F1 to go to a TTY terminal. You’re sure to get all the ladies if you know this cool trick

Ctrl+Alt+F7 will go back to graphics (or sometimes you need Ctrl+Alt+F8).

Источник

How to open a Linux terminal window

terminal window Linux

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.

Читайте также:  Linux mint настройка разрешения экрана

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.

creating keyboard shortcuts

Click on “+” option at the end of the list to create a new keyboard shortcut.

GNOME keyboard shortcut creation

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.

Источник

Оцените статью
Adblock
detector