Author Archives: wp

less command in linux with examples

How to

less is part of the GNU project and is free software. It is a program similar to more, but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi. Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals.

Continue reading

Sync directories between two servers using rsync

How to

Rsync is free file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. Rsync finds files that need to be transferred using a quick check that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file’s data does not need to be updated.

Continue reading

Shell script with options

scripting

For more professional like scripting is nice to use options, where we can do different work with one script just using it. In this article I will show you, how to write script, where we can switch what to do using options -h for help, or -e for echoing “hello world”. Of course, this is just example and we can use it for more complex work than just hello world :).

Continue reading

How to use SCREEN

How to

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Screen is usually used  when we do work which cannot be terminated. For example when is system patched remotely on unstable network, all work can be destroyed during network failure, in this case, screen is very good solution. Screen session will be running, even my ssh connection will be terminated by network. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would.

Continue reading

Using a SSH Key-Based Authentication

How to

This topic will show you, how easy we can setup ssh between two systems that we will not need to write password anymore during log in to system. In this case we have user testuser and two servers system1 and system2.

In first step we need to generate ssh key pair, for which we use command ssh-keygen. Note, command for generating ssh keys will ask us for passphrase, this could be empty.

Continue reading

Memory checks on LINUX part 1

How to

1. at first basic check by one command

In output we can see utilization of memory and and swap. we can change output with -b bytes -k kilobytes instead of -m megabytes. Option -t is used for showing memory with swap (-t as total).

# free -tm
             total       used       free     shared    buffers     cached
Mem:        128393      82606      45787          0       9873      40943
-/+ buffers/cache:      31789      96604
Swap:        34815       4773      30042
Total:      163209      87379      75830
#

If we are not satisfied with this output we can be more detailed by next scripts.

Continue reading