Command line in ubuntu how to call. How to open a terminal in Ubuntu

Despite the ubiquity of graphical interfaces and all sorts of convenient manipulators like the Magic Mouse and Magic Trackpad, the Terminal.app application is still quite a useful and slightly “geeky” tool for performing some operations that most of us are familiar with rather superficially. In fact, there is nothing difficult in "taming" it, so for all MacRadar readers, I have prepared commands for the Terminal that may be useful.

To begin with, it is worth saying that the Terminal.app application itself, like all useful utility utilities, is located in the Programs > Utilities directory. Immediately after running it, you will see a line that says the name of the computer and the current directory, and after the dollar sign ($) - a friendly blinking cursor that invites you to enter your first command ...

List files and folders - ls

By default, after starting the utility, the user's home folder is selected as the working directory. In order to get a list of files and folders in it, just run the two-letter ls command.

There are several variations of this command, which are called by different keys (in fact, there are many more):

  • ls -l will display detailed information about each item, including permissions, file sizes, and so on. In addition, the first character of each line will allow you to determine the data type: if it is the Latin letter “d”, then we have a directory, and if it is a hyphen (-), then a regular file.
  • ls -a will list all files and directories in the current folder, including hidden elements(whose names begin with a dot on Mac OS X).

Note to the hostess: the keys can be easily combined with each other, so if you want to view detailed information about all elements of the catalog, including hidden files, then your command should look like this: ls -la

Move between directories - cd

The name of this team does not come from the old CDs that Apple successfully killed with its digital iTunes Store, but from two English words “change directory” - this is exactly what she does:

  • Type cd Music and the Terminal will go to the Music folder, if it exists in your current directory, of course.
  • The command cd .. (with two dots) is used to exit to a folder one level higher.
  • And by executing the cd command, you will instantly be transferred to the user's home directory.

Full path to the working directory - pwd

The name of this command also comes from the first letters of the phrase "print working directory". Whatever directory you are in, the result of executing this command will be full path to the current directory.

Create directory - mkdir

This command creates a directory with the specified name. For example, mkdir Temp will create the Temp directory in the current folder. If you forget which directory you are currently in, use pwd:

Removing files and directories - rm, rmdir

During this action on files and directories through the Terminal, you need to take into account a small but important nuance: there is no Recycle Bin here, so the data is permanently deleted.

But in general, the rm test1.txt command will remove the file test1.txt from the current directory. And if you add, say, the "i" key (rm -i test2.txt), the user will need to confirm the deletion.

Unfortunately, deleting directories is more difficult, because there are several types of commands for this action:

  • rmdir Test will only remove the Test directory if it is empty and contains no subfolders or files within it.
  • rm -r Test2 deletes all files and folders inside Test2 recursively, and deletes it at the very end.

Moving and copying files - mv and cp

Two commands perform practically similar actions, so they have the same parameter list. If I want to move a file from one directory to another, then I need to use the following command:

mv ~/test1.txt ~/Documents/test1.txt

The first parameter (~/test1.txt) is the file we want to move, and the second is the destination directory and the resulting filename.

Again, note to the owner. First, as you may have guessed, you don't have to change to the right directory to perform actions on files. It is enough to know its name, full path and use them as command parameters.

Secondly, in order not to write the path to the home directory each time, it is enough to use the tilde (~). For example, the entry ~/Documents is equivalent to /Users/username/Documents .

To copy files, just replace mv with cp:

Other teams

Naturally, it is not possible to describe all the available commands (as well as their keys), so I will focus on a few more interesting and useful "instances":

  • You can launch any application in the system using the open command, specifying the path to the application and its name separated by a space. For example, open /Applications/Airfoil.app
  • Using the who command, you can see a list of users who are logged into the system. Naturally, this is relevant only if the work on this computer implies multiple user login or active SSH.
  • The cat test.txt command will allow you to display the contents of a file named test.txt in the Terminal window, but you will not be able to edit it (you will need to use text editor like nano, vim, or emacs), view only.
  • You can always cancel the execution of any command (be it ping or a shell script) using the universal key combination Control+C .
  • Clearing a large amount of text from the Terminal window is easy enough by running the clear command.
  • You may need administrator privileges to run some commands. The fastest way to do this is to add sudo to the beginning of the command line. In this case, the Terminal will ask you to enter the password for your account.
  • View list running processes you can use the top command, however, in this case, the data will look less visual than in System Monitor.
  • To display detailed help for any command, you can use man , specifying the name of the command of interest separated by a space.
  • I almost forgot to mention the fantastic search utility grep , which can be used to find a text string in a file or, say, a specific process in the process list (for example, ps ax|grep smbd).

Perhaps we’ll stop there, and if I missed something or indicated incorrectly, you are welcome in the comments.

All Linux beginners have probably heard about the terminal, or as it is also called the command line. After all, the presence and complexity of the terminal is one of the main arguments of opponents of Linux. Perhaps you have already come across the command line in Windows in practice and already know what it is.

Indeed, in the operating room Linux system there is a terminal where you can execute the commands you need to manage your system very effectively. But this is not at all necessary, for many it is quite enough. GUI. Now the use of the terminal has faded into the background, but it remains the main tool for accessing remote servers and a tool for professionals.

The Linux terminal is much more interesting than the command line Windows string and this article will discuss in detail the work in the Linux terminal for beginners, as well as what is the Linux terminal and what it actually is.

The use of the terminal began a very long time ago. Even before DOS was created and there was no graphical interface. In the distant eighties, the operating room Unix system was just starting to develop. Users need to interact with the system in some way, and the easiest way is to use commands. You enter a command, the system returns a response to you.

Since then, this input method has been used in many systems, including DOS and Apple's OS / 2, until a graphical interface was invented. Then text mode The terminal was successfully pushed out, but it is still being used where it is needed.

Above, under the terminal, we understood the place where you can enter commands and receive a response from the computer. This can be Linux text mode or a terminal window open in graphical mode. Common words in Linux are: console, terminal, command line, command shell, tty, terminal emulator. They all refer to the terminal, but they mean slightly different things. Before moving on, let's look at the terms in order to call everything by its proper name.

Under terminal It is customary to understand the environment where you can enter commands and receive a response to them, it can be a physical terminal or a terminal on a computer.

Console is the physical hardware for managing the server. When the server is not accessible from the network, only the console can be used to manage it.

TTY is a device file that is created by the kernel and provides access to the terminal for programs. These files can be /dev/tty for permanent text terminals and /dev/pts/* for terminal emulators. You can execute a command or send a message by simply writing data to this file, and also get the result by reading data from this file.

terminal emulator- it graphics program, which gives you access to a tty or pts terminal. For example, Gnome Terminal, Konsole, Terminix, Xterm and many others.

command shell- the tty device is only engaged in the transmission and reception of data, but all this data must be processed by someone else, executing commands, interpreting their syntax. There are a lot of command shells, these are bash, sh, zsh, ksh and others, but Bash is most often used.

Well command line- this is the place where you will enter your commands, the terminal prompt for input.

Now that we have figured out what a Linux terminal is and know all the basic principles, let's move on to the practice of working with it.

How to open a Linux terminal?

There are several ways to access the terminal. Your default init system creates 12 virtual terminals. In one of them - usually the seventh - your graphical shell is running, but all the others are free to use. You can use Ctrl+Alt+F1-F12 to switch between terminals. For authorization, you will need to enter a username and password.

These are text terminals without a graphical interface, it may not be very convenient to work in them, but such terminals will be useful if the graphical interface does not work.

The second method allows you to open a virtual terminal directly in the graphical interface using a terminal emulator. The linux terminal emulator works with files in the /dev/pts/* directory and is also called a pseudo-terminal because it does not use a tty.

In Ubuntu, you can start the linux terminal by pressing the keyboard shortcut Ctrl+Alt+T:

It can also be found in the Dash application menu:

As you can see, opening a command line in linux is very easy.

Executing commands in the terminal

Let's take a closer look at the Linux terminal for beginners. As I said, the terminal and tty device files are only responsible for data transfer. The command shell is responsible for processing commands, to which the data received from the user is transmitted.

You can type something and see if it works:

To execute a command, just write it and press Enter.

Moreover, the Bash shell supports autocompletion, so you can write half of the command, press TAB and if only one command starts with such characters, then it will be automatically completed, if not, then you can press TAB twice to see the options .

Exactly the same scheme works for file paths and command parameters:

In Windows, you could not even dream of such a thing. To execute a command, you can specify its name executable file or , relative to the root or any other folder. It is important to note that the Linux shell, unlike Windows, is case sensitive, so be careful when entering commands and their options.

By default, work on the linux command line can be performed using a large number of commands, many of them, for example, to navigate directories, view content, install software, come with the system.

An instance of a running command is called a process. When one command is executed in the Linux terminal, we need to wait for it to complete in order to execute the next one.

Commands can be executed without parameters, which we saw above, or with parameters that allow you to specify the data that the program will work with, there are also options with which you can customize the behavior. Most standard utilities follow this syntax:

$ command options parameter1 parameter2...

Options are often optional and specify one or another aspect of the program's operation. They are written in the form of dash and symbol or double dash and word. For example -o or --output. Here is an example for the ls command. Without options and parameters:

With a parameter indicating which folder to look at:

With the -l option, output as a list:

In with option and parameter:

You can combine two options:

Basically, this is all you need to know about commands in order to use them productively. You could also talk about combining commands and redirecting the output of one command to another, but this is a separate topic.

conclusions

This article covered the work in the linux terminal for beginners. The Linux command line may seem very complicated at first, but it is not at all, it is much easier to use than in Windows and allows you to manage the system more efficiently. I hope this article has shed some light on this very large topic.

Operating system tasks can be performed in the console or terminal by entering certain commands. On the this moment There are many computer operating systems. The most popular of them are Windows, Ubuntu, Mac os. All of them launch the terminal differently. Learn how to run the terminal on different operating systems.

Windows

First you need to click on the "Start" button, after which you should select the "Run" item in the menu that appears. The program launch window will open. You will need to enter "cmd" or "command" in the search bar, and click the "OK" button. This will open a terminal.

ubuntu

Now learn how to launch a terminal in Ubuntu. For this, in upper corner desktop, you need to find the "Applications" menu. Clicking on it with the mouse will open the menu installed apps. Here you should select the item "Standard". Next, you need to find the application "Terminal" and run this program. In some versions of this operating system, it is possible to start the command line differently. To do this, you need to go to the "K-menu" menu and click on the "System" section with the mouse. After that, select the item "Konsole" or "Terminal Program". If you have Ubuntu version 11.04 and higher, then you can simply press the “flag” button on the keyboard and enter the first letters of the program name in the “Dash” window that opens. In our case, it will be enough to write the word "term" without quotes, and then press "Enter".

Mac os

First you need to start the operating system. After that, you need to open the menu and go to the "Programs" directory. Here you will need to select the "Utilities" section. Then you need to find the "Terminal" application and launch it. In addition, you can find this command line using the Spotlight menu. Now you need to press the key combination Ctrl + Space. Then you will see a prompt where you will need to enter the word "Terminal". The program will start searching. Upon completion, you should choose the one opposite which is the inscription "Best Match". Now you can run the file by pressing the "Enter" button.

After figuring out how to launch the terminal, users should familiarize themselves with different ways its use. Using the console, you can perform various tasks, such as formatting disks, launching applications, checking the network, and much more.

The terminal is an important component in operating systems based on the Linux kernel. Windows users used to call it the command line. If earlier, in the days of an underdeveloped graphical interface, most tasks were performed through the terminal, now in this OS it is used less often. On Linux, things are different. Here the command line continues to play an important role in performing many operations. Therefore, it is important to know how to open the terminal in Ubuntu in various ways for one or another case.

Ubuntu command line

First you need to clarify what a terminal is and what it is for. It is a text environment through which the user interacts with the OS. Principle of operation command line in Ubuntu it's simple: "set the command - get the result."

The terminal has three advantages that encourage the user to use it:

  • speed up work with files and folders due to simple programming;
  • launching other programs inside the terminal and organizing their interaction;
  • work with servers that allow processing large amounts of data much faster than a personal computer.

How to call a terminal in Ubuntu

The console in Ubuntu can be called in several ways:

  • using hot keys;
  • in the Dash menu;
  • through the Launcher Unity sidebar;
  • using the Run window.

As a rule, the choice depends not only on convenience, but also on the ability to open the console in a certain situation.

Terminal shortcuts in Ubuntu

Using a keyboard shortcut to launch a terminal sets Ubuntu apart from other Linux distributions. From anywhere in the GUI, you can open the terminal by pressing Ctrl+Alt+T at the same time.

You can change the keyboard shortcut in the keyboard settings, located in the "Devices" section of the system settings. There is an item "Open terminal". He is allowed to assign any combination of three keys.

Dash Panel

You can open the command line in Ubuntu through the Dash menu, which is called by clicking on the Ubuntu logo in the upper left corner of the window, or by pressing the Win key on the keyboard. A launch line will appear at the top, in which you must enter the name of the program - “Terminal”.

Panel Launcher Unity

The Unity launcher is a kind of quick launch bar located on the left side of the workspace. To launch the terminal through it, you need to drag the program shortcut to the panel. To do this, you can use the Dash menu and the steps above, and then hold down the mouse and drag the terminal icon onto the Unity Launcher.

Run command

All versions of Ubuntu have a "Run" pop-up window called by pressing Alt+F2 at the same time. An input line will appear on top of all windows, through which you can launch both the terminal and any other program.

In the latter case, there is no way to see the output of the command, so it is better to run the console. Commands for calling the terminal in different Ubuntu environments are different. For example, in Gnome it is gnome-terminal , and in KDE it is console .

Open terminal in folder

Sometimes it becomes necessary to open a terminal from a specific folder. So, being in file manager Nautilus, the console can be launched by selecting the appropriate item in context menu.

How to open a file through the Ubuntu terminal

To open a file of any extension in a program designed for it, the Ubuntu command line provides the xdg-open command. It allows you to open not only a file, but also a web page or folder in the system. For this, the path to the right resource:

xdg-open linux/etc/pswd

If you want to open text file, while still viewing its contents, other commands are provided:


How to run a program through the Ubuntu terminal

The principle of launching programs through the Ubuntu terminal is quite simple, but it has its own catch. The command template entry looks like this:

path/to/executable/file/program Parameters

Often the path to the program is not specified completely. This is explained by the fact that all the main programs are stored in certain directories, for example: / bin, / usr / sbin and others. Therefore, to automate the process, the PATH variable was introduced, which stores all these paths. Full list directories can be found by running:

When a program name is written to the console, the system scans all folders from PATH for its presence. If the search fails, a message will appear - command not found. For example, typing ls will launch a utility that lists the contents of a folder.

If the location of the program is different, you must write the full path. Even if the folder with this program is open, it is not enough just to write its name. You can specify that you want to open the utility from this directory using "./":

Sometimes there is a need to define a utility that will be used to open certain files by default. In this case, the EDITOR variable is used:

Conclusion

Knowing how to open a terminal in Ubuntu, as well as the main list of its features, is desirable for users of this OS. Despite the convenience of using the graphical shell, the console provides more functionality, and sometimes even is the only way To solve the task. Over time, the text interface becomes familiar, which greatly speeds up the work.

Hello everyone! It would seem, why a separate note with instructions on how to open the command line in Windows 10? - In fact, many users (especially after switching to Windows 10) there are many questions, where did this damn command line go from our usual place ?! Since I had to tune in to the story, I decided to reveal this issue in as much detail as possible and show you as many as 10 various ways run command line at latest Windows 10.

Surely you are already familiar with some methods, but I think even an advanced user will find some interesting and useful points for himself. This note is written for Windows 10, but most of what is described in the article works fine on earlier ones. Windows versions- I just don’t see the point in scribbling for outdated systems ...

I was inspired to write this note about all the ways to open the command line by your questions in the missing note, where in the last paragraph we considered a way to fix the problem through the command line.

Certainly, modern systems they are quite simply controlled with the mouse and we rarely use the input of various commands, but sometimes you need to do something specific and often this is done by simply entering a command into the terminal, and we will consider how to run it today (all options I know of). We will call the line on behalf of the Administrator and with a limited account.

Open a command prompt window from the Win + X menu

This is probably the easiest way to open the command line on Windows 10 - press the combination "Win + X" on the keyboard and select the desired item in the menu that appears.

Convenience this method in that you can select several modes of operation of the command line at once - these are:

  1. Command line - normal, with limited rights;
  2. Command Prompt (Administrator) - Unlimited (be careful)

In general, there are a lot of interesting things in this menu and I recommend that you familiarize yourself with it in detail, sometimes it helps a lot and saves time.

Opening a Command Prompt Window from the Task Manager

Open Task Manager and go to verbose mode (Click for details). Click "File" in the top left corner and then go to "Run new task". Type CMD or cmd.exe and click OK to open a command prompt. In addition, you can check the box that will launch a command prompt with Administrator rights.

Command Prompt in Administrator Mode Using Task Manager - The Secret Way

Here, almost everything is the same as in the previous paragraph, to run the command line as an administrator - just hold down the CTRL key on the keyboard while clicking File> Create a new task, thereby you will open the command line with admin rights (no commands required)

Opening Command Prompt from Search Results

You can easily open a command prompt window by simply typing "CMD" in the search field (Keys Win + S on keyboard). Perhaps when Cortana is brought to Russia, we will be able to command the computer with our voice, but for now we can do without it ...

To launch the terminal this way with administrator rights, then enter CMD in the search field and click right click mouse and select "Run as administrator". Alternatively, in order not to touch the mouse at all, use the arrows to select the command line and press CTRL + SHIFT + ENTER to open a command prompt window in administrator mode.

Launching Command Prompt from All Applications in the Start Menu

Open the Start menu by clicking on Windows image in the lower left corner. Go to all applications and find "System Tools - Windows" there, and then click on "Command Prompt"

Open Command Prompt from Explorer

The command line can also be opened through Windows Explorer - just go to C:\Windows\System32 and find the cmd.exe file there. You can either double-click, or by right-clicking the mouse, select "Run as administrator" - it all depends on you and what rights you want to run the terminal with.

Command line from the Run menu

Press the buttons Win + R” on your keyboard to open the Run dialog box. Type CMD command and press OK button (or Enter on the keyboard).

Open Command Prompt from Explorer's Address Bar

Open Windows Explorer and click on the address bar (or press the keyboard shortcut ALT + D on keyboard). Just type cmd in address bar and thus you will run a command line with the path of the current folder (where were you when you called the terminal)

Command line from File menu in Explorer

Open the standard Windows Explorer, navigate to the folder or drive that will be selected as the starting one on the command line. Click File on the ribbon and select Open Command Prompt. Here you have two launch options:

  1. Open command line - opens the command line in the folder of our choice with standard permissions;
  2. Open command prompt as administrator - opens a command prompt window in the folder of our choice with administrator rights.

Open command window in Windows Explorer

To open a command line window in any folder or drive you need, just go there through the standard explorer. Right click on the folder or any empty space on the right side Windows Explorer hold down the SHIFT key on your keyboard, and from the context menu select "Open Command Window". The terminal will start with the path to the folder in which we were.

Create a command line shortcut on the desktop

Well, here we figured out how to open the command line in Windows 10 and similar systems, I hope you don’t have any questions - as a bonus, I decided to tell you how to create a shortcut on the desktop or in any other place convenient for you to launch.

Right-click in an empty space on the desktop, select "New > Shortcut" from the context menu

In the "Specify the location of the object" field, enter "cmd.exe" and click "Next"

Give any name to the created shortcut and click "Finish" (I, for example, called the Command Prompt Administrator, as I plan to run it with extended rights and I will tell you how to do the same)

If you, like me, want to run the command line from a shortcut as an administrator, then go to the shortcut properties (right-click on the shortcut and select Properties from the context menu). Click the "Advanced" button at the bottom and check "Run as administrator".

So you have created a shortcut that will open a command prompt window by double clicking on it. I hope that you no longer have an urgent question - how to open a command prompt window in Windows 10, but just in case - I'm waiting for your comments ...