Windows.  Viruses.  Notebooks.  Internet.  office.  Utilities.  Drivers

Whether you are a beginner Linux user or you have been using Linux for a long time, you should use the terminal in your work. I want to help you get started with the terminal.

The Linux terminal is not something you should be afraid of.

The terminal is a powerful tool with great potential that actually makes it easier and, if necessary, does all the routine work for you. Through the terminal you can very quickly:

  • add new repositories (software repository)
  • install programs
  • run programs (to see possible errors)
  • customize distribution or individual programs via config files
  • and many, many more

By reading this article, you will not be able to learn all the wisdom that you need to know about the terminal Linux for beginners. Need experience, working with the terminal.

Basic use of the Linux terminal

Launch the terminal from the desktop, applications menu and you will see a running command bash shell. There are other shells, but most Linux distributions use bash by default.

You can try to run a program by typing its name on the command line. Through the terminal, you will be able to run everything that runs on Linux: from graphic applications, such as Firefox, to console utilities. Unlike Windows, you don't need to enter the full path to a program to run it. For example, let's say we want to open Firefox through the terminal. On Windows, you need to enter the full path to the Firefox exe file. On Linux, just type: firefox

Opening Firefox from the Linux Terminal

Press the Enter key after typing the command and it will run. Note that you don't need to add an extension or anything similar to the end of the name, as in Windows .EXE, files in Linux do not have an extension.

Terminal commands can also take arguments. You can use the argument types, depending on the program. For example, Firefox accepts web addresses as arguments. To start Firefox with open tab, you can run the following command:

Firefox site


Any other programs can be run in the terminal and they will work just like Firefox. There are programs that only know how to work in the terminal. They do not have graphic view, do not have a graphical interface in the form of an application window.

Installing Software via Linux Terminal Ubuntu

One of the most effective action in terminal this is setting software. To install software, there are graphical managers, for example, in Ubuntu "Software Center". Center Ubuntu applications it is a graphical shell for the few terminal commands it uses in the background. If you know what you need, then instead of clicking through all those buttons and searches, you can easily install the program from the terminal with one command. You can even install multiple applications with a single command.

I will use the example on Ubuntu / Linux Mint or other Ubuntu-like distributions (all other distributions have their own own systems package management). So here is the command to install a new software package:

sudo apt-get install packagename

It may seem a bit complicated, but it works, just like the aforementioned Firefox. The shorthand word sudo runs a program that prompts for the root (administrator) password before running apt-get. apt-get in turn reads the install arguments of the package name and installs the package you requested.

An example for installing several packages at once through the terminal.
For example, to install the Chromium web browser and the Pidgin instant messaging manager, run this command:

sudo apt-get install chromium-browser pidgin

I use the above mentioned command after I install the "fresh" Ubuntu. Installed a new release of Ubuntu, added all my favorite programs with one command. You just need to know the package name of your favorite programs. As you can see, the names of the packages are pretty easy to guess. You can also refine your guesses with tab, the trick is below.
I have dozens of programs I need in my working distribution, but I won’t enter the names of all programs in the terminal on the new installed Linux. And so I use a more automated way. Which is that before installing a new Linux distribution, I first on old installation, using the terminal, I export the name of all installed packages to a text file.

And then, after reinstallation, in the new one, through the terminal, I import this test file, which tells the distribution kit about all the programs that need to be installed. Thus, these commands are quite small, as opposed to if I entered them manually, and a lot of time is saved. This tip and other, more in-depth instructions can be found in.

Working with directories and files in the Linux terminal

The shell always operates in the current directory unless you specify a different directory. For example, NANO is an easy-to-use console text editor. Team:

Nanodocument1

will say that you need to run a text NANO editor With open file under the name "document1" from the current directory. If you want to open a document that is located in a different folder, you must specify the full path to the file, for example:

Nano /home/pavel/Documents/document1

If you specify a path to a file that doesn't exist, nano (like many other programs) will create a new empty file at that location and open it.

To work with files and directories, you need to know a few basic commands:

cd - command to change directory

~ (tilde) represents your home directory (/home/you), which is the terminal's default starting point. To change to a different directory, you must use the cd -commands.
For example:

you will go to the root directory

cd Downloads
move to the "Downloads" directory inside your user's current directory (the exact path, in my case, would be /home/pavel/Downloads), to move to your home directory /home/you/ from anywhere you would command:

command to navigate up the hierarchical directory system.

ls - lists files in the current directory


mkdir - command to create a new directory

By command:

mkdir newfolder

a new directory will be created in the current directory named newfolder, and:

Mkdir /home/pavel/Downloads/test

will create a new directory called test in my "Downloads" home directory (pavel needs to be changed to your username).

rm - command deletes a file

For example:

rm testfile

deletes the file named test in the current directory, and:

Rm /home/pavel/Downloads/testfile

deletes the file named testfile in the /home/pavel/Downloads directory.

cp - the command copies a file from one location to another

For example:

Cp testfile /home/pavel/Downloads

copies a file named testfile from the current directory to /home/pavel/Downloads.

mv - command moves a file from one folder to another

mv works exactly like the cp command above, but it moves the file rather than making a copy. mv can also be used to rename files. For example:

Mv /home/pavelz/Downloads/testfile /home/pavelz/Documents/testfile1

moves the file named testfile from /home/pavel/Downloads to the directory /home/pavel/Documents already under the name testfile1.

It may seem a little intimidating at first, but there is nothing complicated here. These are the basic commands that you need to master in order to work effectively with files in the terminal. Navigate through file system with cd, browse files in the current directory with ls, create directories with mkdir, and manage files with rm, cp, mv commands.

Secrets to speed up work in the Linux terminal

Tab auto completion

Tab is a very useful trick. While you are entering any command, file name, or some other type of arguments, you can auto-complete the command using tab. The terminal will simply print for you.
For example, if you type fir in the terminal and press tab, firefox will automatically appear. This will save you the hassle of typing in full. You can press Tab and the shell will be ready to complete the command for you. This also works for folders, filenames, and package names.

Anyhow, when I don't know what the full command looks like, I hit the Tab key and see the command, or a list of possible matches. If you continue and enter a few more letters, then this will narrow the matches when you press the Tab key.

Additional tricks can be found in this book.

So: download, share any articles of this site and send me an e-mail: a letter with the content of the address, web pages where you have placed links, preferably several links to different pages of this site. That way, I can find that page of yours and reply to you with an email with the archive password.

Such a kind of payment for the book will help to develop this site.

Conclusion:
I hope that after reading and putting into practice this article, you will feel a little more comfortable in the terminal. To learn more about the terminal—and ultimately master it—continue your journey with this book.

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 type of data: if it is latin letter"d", then we have a directory, and if a hyphen (-), then a regular file.
  • ls -a will list all files and directories in the current folder, including hidden items (whose names start 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 the 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, it is required to take into account a small, but important nuance: there is no Recycle Bin, so the data is deleted permanently.

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

The two commands perform almost similar actions, so they have the same list of parameters. 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 called test.txt in the Terminal window, but you will not be able to edit it (you will need to use a text editor like nano, vim or emacs), only to view it.
  • You can always cancel the execution of any command (be it ping or a shell script) using the universal key combination Control+C .
  • Clear the Terminal window from a large number text is easy enough by issuing the clear command.
  • You may need administrator privileges to run some commands. The fastest way to do this is to add to the beginning of the line sudo commands. In this case, the Terminal will ask you to enter the password for your account.
  • You can view the list of running processes using the top command, however, in this case, the data will look less clear 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 tool 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.

By analogy with Windows, Linux has a certain set of commands for the most convenient and fast work in the operating system. But if in the first case we call the utility or perform an action from the “Command line” (cmd), then in the second system, actions are performed in the terminal emulator. In fact, "Terminal" And "Command line"- It is the same.

For those who have recently begun to get acquainted with the line of operating systems of the Linux family, below is a list of the most significant commands that each user needs. Note that the tools and utilities called from "Terminal", are preset in all Linux distributions and do not need to be preloaded.

File management

In any operating system, interaction with various file formats is indispensable. Most users are used to using file manager, which has graphical shell. But all the same manipulations, or even a larger list of them, can be carried out using special commands.


Work with text

Entering into "Terminal" commands that directly interact with files, sooner or later you will need to make changes to them. To work with text documents the following commands are used:


Process management

Prolonged use of the OS during one session stimulates the appearance of many active processes that can significantly degrade the performance of the computer to the point that it will not be comfortable to work with.

This situation can be easily remedied by completing unnecessary processes. IN Linux system For this purpose, the following commands are used:


User environment

Important commands include not only those that allow you to interact with system components, but also perform more trivial tasks that contribute to the convenience of working at a computer.


user management

When more than one person works at one computer, but several, then the best option will create multiple users. However, you need to know the commands to interact with each of them.


Viewing Documents

No user is able to remember the meaning of all the commands in the system or the location of all the executable files of a program, but three easy-to-remember commands can come to the rescue:


Network management

In order to set up the Internet and subsequently successfully make adjustments to the network parameters, you need to know at least a few commands responsible for this.


Conclusion

Knowing all the above commands, even a beginner who just installed the system on Linux-based, will be able to perfectly interact with it, successfully solving the tasks. At first glance, it may seem that the list is very difficult to remember, but with frequent execution of a particular command, over time, the main ones will stick into memory, and you will not need to refer to the instructions presented by us every time.

Operating system tasks can be performed in the console or terminal by entering certain commands. On 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. To do this, in the upper corner of the desktop, you need to find the "Applications" menu. Clicking on it with the mouse will open the menu installed applications. 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 differently command line. 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 run 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 the different ways its use. Using the console, you can perform various tasks, such as formatting drives, running applications, checking the network, and much more.

Users currently Ubuntu systems on home computer may not resort to working in the terminal at all and perform all the usual tasks, such as: surfing websites, watching movies, working in the office and with email as well as other typical tasks in a graphical environment.

But users whose level of work on a computer can be assessed as advanced still need to use the terminal from time to time to solve various problems, because there are a lot of programs and utilities without a graphical interface in the Linux environment and they are often more functional and intuitive to use than software with a GUI ( GUI). And some do not have adequate analogs with the interface at all.

Also, advanced users cannot do without a terminal to fully customize their system using editing various text configuration files and writing bash scripts.

But even beginners need to be able to open the terminal for work, because most of the instructions on the Internet offer solutions to various problems from installing programs to configuring the system in the form of commands for the terminal. Indeed, it is much easier this way, because you can write a program installation command, and a user who is not yet very well versed in the system can simply copy it and execute it on his computer. With this approach, the author of the instruction will be sure that the reader will do everything right, because most of the commands will be interpreted in the same way in the system of the author of the manual and the one who will use it. In this blog, I myself constantly refer the reader to some actions in the terminal, but so far I have not given a detailed answer - how to open it, and this is the basis of the basics.

Text console

I'll start, perhaps, with the holy of holies - the text console. This is an interface for the system to communicate with the user by receiving information from him from the input on the keyboard and outputting the response to the monitor in text form. It does not require a graphics subsystem to work with it. graphical environment environment, and you can continue to work in it even if you remove the X graphics server or an environment such as GNOME or KDE from your computer.

To access text terminals in Ubuntu you need to use keyboard shortcuts CTRL+ALT+F1- CTRL+ALT+F6. The first console is F1, then F2 and so on until F6. It turns out that you can simultaneously use up to six work environments with six users authorized in them. On the seventh console - CTRL+ALT+F7 usually there is a graphical terminal - a familiar system with windows and a mouse. And it is CTRL + ALT + F7 that needs to be pressed to return to the familiar environment after working with the console.

But usually we don’t get into the text console often, but only when some kind of malfunction occurs with the graphics, for example, when the drivers for the video card fly off. For normal system setup and installation of programs, you should use a terminal emulator in graphical mode.

terminal emulator

Hotkeys

Ubuntu uses a default keyboard shortcut to open a terminal. CTRL+ALT+T.

After pressing the combination, a window will open with a terminal prompt on behalf of the current user - this means that commands in this terminal will be executed on behalf of the one who is currently authorized in the system.

To execute commands on behalf of the superuser, you must prescribe sudo before the command. This special program, which allows you to replace the user to execute the following command. By default in Ubuntu, it replaces the user with the superuser (root) so that you can work in the terminal with its privileges. This is necessary, for example, to install programs via apt.

At using sudo you will need to enter the system administrator password that was specified during its installation (in most cases, the password of the only user of the system).

Using the Run command

The system also has a special dialog that opens by pressing a key combination ALT+F2 and allows you to run an arbitrary program by entering its name.

For different graphical environments, the name of the standard terminal emulator will be different, I will give the most common ones:

  • gnome-gnome-terminal
  • xfce-xfce4-terminal
  • kde-konsole
  • Unity-gnome-terminal
  • The terminal emulator installed in all *buntu versions by default is xterm

Application menu

On any system, the terminal emulator can also be found using the application menu. This is the menu from which the user launches their programs such as a browser or text editor. In the menu, the terminal will have the name "Terminal Emulator" or "Terminal" or "Terminal emulator" - in English.

I am using the XFCE desktop environment and will give an example in its application menu.

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE: