Environment, ahead of thought

desktopIf hundreds of articles are devoted to effective work in cli / bash / vim, then there are hardly a few pieces to the organization of the working environment of the system administrator. Most often these are screenshots of some Enlightenment with 1 transparent terminal, clock, calendar, 15 CPU loading widgets and a naked anime woman in the background. Suitable for the film "Hackers", not suitable for work. We need the terminal to appear even before we thought about it, do our job and disappear without a trace until the next measure.

Disclaimer

It is assumed that you have been working as admin / devops for about five years and are able to find answers in Google. My task is to ask the right questions. Implementation examples will be given for Windows. I offer alternatives for * nix-shaped systems to readers as homework.

Login

imageFirstly, all authorization should be on a key. I did not see anything more awkward than driving a host from memory every time, after which entering a login and copying a password from a special secret file passwords.txt on the desktop. The key (or keys, if you maintain a good relationship with employers) must be uploaded to the agent. The key, of course, must be password protected. After all, he probably lies in My Documents. And they backup in some Dropbox / Wuala / ownCloud storage. And this story is probably connected in your favorite mobile phone with a password. Lost your mobile phone - go to all all the hosts where your key has been, and change it. Sounds like a branch of hell, doesn't it?
Implementation : Install PuTTY . Generate and put your .ppk in the Start-up folder. Pageant will do the rest.

Fast access

imageSecondly, choosing the right host should take no more than 700ms. Many people guess to create sessions in Pageant for all hosts, but after all the same, they search for a tiny tray icon with the mouse, select Saved Sessions, look for the name you need in the huge list ... I’ll skip the obvious point that all work should be done from the keyboard. Well, maybe lazy paging of web pages using mouse gestures, but this is not our case. Access to the host list by shortcut is required with the ability to search.

Implementation : Launchy (freeware) + PuTTY plugin . I hang on Alt + Space . In addition to an excellent search for files and commands, it allows you to search for Pageant sessions, guessing the names by several letters. Suppose if you have sessions:
  • Client1_Host1
  • Client1_Host2
  • Client2_Host1
  • Client2_Host2

all you have to do is enter “c2h1” to get to Client1_Host2 (in this artificial case even just “21” is enough). You can even enter “c1” and select the desired car from three - Launchy will remember your choice and will not ask questions next time.

Window manager

imageThirdly, windows should be optimally positioned on the screen, not crawl on top of each other and resize when resizing neighbors (docking). I appreciate (almost without sarcasm) Windows trying to implement Win-Arrow tiling. But with modern resolutions of 24 ″ + monitors, two giant panels of terminals are a clear overkill. Yes, and two windows are usually not enough - you need 2-3 terminals, a browser with mana, mail or skype - anyone like that.

Implementation : Plumb(for personal use). Automatically arranges windows according to the grid you specify. My screen is divided into 5 parts - on the left, a full third of the screen is allocated to the most active window, the rest is 2x2 divided by other background tasks (tail -f, watch -d, mtr). I don’t need to drag new windows from place to place with my mouse, freeing up space among other windows - the last 5 active windows on my screen.

What does this give us?

Now consider a fictional situation from real life in which all the bonuses of this system will become clear. You read Habr, a colleague-programmer approaches you and asks: “Pasha, Client1 on the first host has already completed that very long request, which I composed without the slightest knowledge of the internal architecture of the database, carefully ignoring indexes and using the most poorly optimized operators?”
You put your fingers on the keyboard and give the first chord: Alt-Space c1h1 ENTER. I bet people don’t even notice what happened. You just touched the keys, and at the same second the window with Habr was pushed to the side, and its place was taken by the open terminal Client1_Host1. For a person who is accustomed all his life at best to search for the desired tab in a long list of open sessions, this will already look like magic.

In the terminal, you do something like “pgrep -af long_query”, you see that the process is still hanging and press Ctrl-D. The window closes, and the Habr (previous active window) returns to its place. You don’t need to minimize the terminal, thinking that you will still be working with this host - you know that opening a new one is faster than looking for the old Alt-Tab or mouse aiming in the taskbar.

After 2 minutes, a colleague returns with the same question. This time you will be faster than the train station. Watch your hands. Alt-Space ENTER UP ENTER Ctrl-D . What was it - Fatality? Launchy remembers your last command, you don’t even have to look at his window. They opened the terminal, called the previous command in the shell, saw a non-zero result and closed the window.

Here he comes for the third time, and to get rid of him, you run “watch -d !!” in the freshly opened terminal and drag the window to the corner. Habr again occupies the main part of the desktop, and watch in a small window will highlight you changes in the list of processes when a long query to the database ends.

This is only one part of the doctrine of the Quick Hand. It completely consists of the following sections:

1. Environment, ahead of thought;
2. Fast bash;
3. Unix-way in working with files;
4. Vi (m), strict but fair.

Also popular now: