SSH commands are a very important tool for any system administrator or advanced webmaster who does not host sites on a shared hosting, but on a dedicated server. These servers are usually configured through the console using Linux commands.
You can use various programs to connect, for example, PuTTY. SSH also handles the Bitvise SSH Client. In fact, they are one and the same. Therefore, most administrators use what they’re just used to.
PuTTY SSH
The photo below shows the PuTTY console. When connecting to any program, you need to specify the host (IP address) of the server and the port on which this console works. This is usually the 22nd port.
Some shells for connecting to the server offer to remember your username and password. This is not recommended. The maximum that you can remember is the login to simplify the work. But always enter the password again. Such clients are sometimes hacked, and then attackers steal your data.
Bitvise SSH Client
Also, SSH Linux commands work fine in Bitvise SSH Client. The console is exactly the same, but besides this, FTP immediately opens in this program.
You can use anything. The main thing is that you like it and everything works. The principle is the same everywhere.
SSH Commands for System Monitoring
SSH console commands allow you to monitor the server. To do this, just type the htop command. The result will be the image you see below.
All computers will have different information. In this case, a weak server with one processor and only 671 MB of RAM is provided.
The Uptime column shows how much time has passed since the system restarted. If the job of administering the server and monitoring its status as a whole is professional, it will work for a long time without rebooting. After all, if everything works well, then why restart it?
Here a very important line is the Load Average with three values. The first shows the average load in the last minute, the second in the last 5 minutes, the third in the last 15 minutes. This load is defined differently than in the standard Windows task manager.
The load can be more than 100. Even more than 200. The system works like this: if the reading for the last minute is less than or equal to 1 and at the same time the computer has one core, then the server copes with the load. That is, here you need to take into account the ratio of the number of cores and numbers on the screen. If everything is 1 to 1 or less, then that’s good. The lower the value, the faster the operating system as a whole.
If load 4 is on a dual-core server, then the load exceeds 2 times the possibility for stable operation. Try to keep track of this figure. If the load is large, then try to optimize the server and what works there.
As a rule, workload with files or with a database can give a load.
Any user on the server can use the htop command. But only the root can watch the load and queries of all the databases of all users. To do this, log in to the server via SHH and enter the mytop command.
All current requests with detailed information are displayed here:
- Request ID (the longer the server is running, the larger the number will be);
- the user who is executing the request;
- host where the request is made;
- database;
- how much time the request takes;
- the request itself.
The most important thing here is runtime. The longest processes are at the bottom. If you see some kind of mysql query executing a couple of minutes, then this is not normal. Press the k button (from the word kill) and enter the ID. As a result, you can complete the request. Kill all the long requests this way and you can unload the server.
Next, to fix the problem (and it will appear again, and you can’t always manually kick the problem lines), you need to see what kind of database it is and what request is occurring. Identify the longest and optimize them.
Basic Linux Commands
There are various SSH commands. Everyone has a different purpose. For instance:
- for working with files;
- to display system information;
- for process control;
- for archiving;
- to work with the network;
- for work with mysql;
- for searching;
- to set file permissions;
- to install packages.
It is not necessary to consider everything. You will encounter most of them as you work with the console.
Now consider the basic commands that are needed always and everywhere. If you remember them, you will always remember.
Work with files
Please note that the paths in the teams must be written based on where you are. For example, the ls command will list the current directory. Navigating folders using cd can be done right away, not one at a time.
Always look at the paths you write in commands. You can also use "masks". For example, you can delete all txt files by entering the rm * .txt command. An asterisk means anything, the main thing is that at the end there is .th.
File archiving
To familiarize yourself with this issue, check out the photo below.
System Information
The main commands are shown in the photo.
Software installation
Not all SSH commands work immediately after installing the operating system. Many utilities need to be installed. It is very simple.
For example, the htop and mytop commands do not initially come bundled. They need to be installed. To do this, enter sudo apt-get install htop.
You need to install from the root user. Others do not have enough rights.
The installation principle is the same for all programs. It’s just that at the end it changes instead of htop to the utility you need (for further commands).