Finding your way on your first ever VPS ? Part III
Posted on 12-10-2014 05:00
Part III of the 'Finding your way on your first ever VPS' series is right in front of you right now! This time I'm going to focus on some powerful tools which can make your day-to-day life a lot easier.
I am going to assume a Debian-based distribution in my examples. I'm using Ubuntu 14.04 more specifically. Most commands should work on any Linux distribution; the only distribution-specific commands are those for the package manager.
Let's get to work!
With 'cat', you can print the contents of a file to the standard output, which is usually your terminal. This allows you to quickly see the contents of files without having to leave your terminal for another application. It works best with small files, for example, your resolv.conf or your hosts file. But, if you combine it with another piece of software I'll cover later on, this will be quite useful for large files as well.
Let's say you want to quickly see the contents of your resolv.conf, you type:
You could get an output like this:
cat was primarily designed to concatenate files, though, rather than printing to your terminal. You could, for example, cat two files and then convert those into a single file. That's for another time, though.
A pipe | is not an application, but a tool. It allows you to send the output from one application to another. This is a very powerful tool which allows you to combine the power of multiple applications together.
A good example for the use of a pipe is piping the output from a certain command to 'less' so you can calmly look at it or even search through it. The command 'lsof' (which lists all the open files on a system) usually has a long output and it may be a pain to work with. If you pipe this to 'less', you can browse through it and search through it like it's a regular text file.
To do this, type:
Which should open 'less' with the output of 'lsof' in it. Once you exit less, the contents are lost, so this is no way to save content.
grep allows you to search a file or multiple files for a pattern. grep prints every line the pattern is found in to your terminal. A pattern can be something as simple as a word or an IP address, or something as complicated as a long regular expression. In my experience it is extremely useful to quickly search several log files at once.
Say you want to find a certain domain name or IP address in a log file, you would type something like this:
The above command searches the file /var/log/syslog for the IP 126.96.36.199 and prints any lines from the file that IP address is on. But, it could also be that you want to search multiple files, or even all files in a directory. In the last case, you would type:
Where * tells grep to use all files in the current directory (not subdirectories).
grep can also be used in combination with the pipe, so you want search through data coming from another application.
top is an application that shows you all the running processes on a system in a single list. Not only does it show the running applications, but also how much CPU and memory an application uses, which user it runs under, how long it has been running, and quite some other things. If you want to know the current status of your system, top is there to help you.
You can open top by typing 'top' and quit it by pressing q.
Inside top you have a lot of options, for example to sort or filter the list. There are too many option to highlight right here, so your best option is to type ? or h when in top to see the in-application help, or to use 'man top' to view it's manual.
Or you can install htop, top's better alternative. To install it, type:
Once done, you can open it by typing:
You will now get to see a more colorful application with some bars at the top. htop has a more graphical display of the system's used and free resources. Better than that, it can work with your mouse and it works nicely with the F-keys as well as your arrow keys. You can easily sort the columns and you know where to go in this application. Have a look around and enjoy.
My recommendation is to always install htop on any server and it's simply a lot better than top. It may not be available on any system, however, so in those cases top is what you'll have to work with.
For now, this is the last in the series 'Finding your way on your first ever VPS'. After having read these three tutorials and having practiced a bit, you should have sufficient information to investigate other parts of your VPS on your own.
Warning about ParkingCrew.com! Case: ParkingCrew.com acquires NameDrive.com but earnings are not transferred despite assurances and promises. Inquiries about this are ignored! It's just a con compagny. Don't do business with them!
|Jump to Forum
|Subject||Discussion Forum||Last Post|
|Server monitoring with Icinga 2 ? Part 1: the server (Ubuntu host)||Linux tutorials, Tips & Tricks||: 1||17-10-2016|
|Server monitoring with Icinga 2 ? Part 2: the node (Ubuntu host)||Linux tutorials, Tips & Tricks||: 1||03-09-2015|
|Tutorial ? The LowEndCluster ? Part 4||Linux tutorials, Tips & Tricks||: 1||26-05-2015|
|Tutorial ? The LowEndCluster ? Part 3||Linux tutorials, Tips & Tricks||: 1||24-05-2015|
|Tutorial ? The LowEndCluster ? Part 2||Linux tutorials, Tips & Tricks||: 1||24-05-2015|