It’s the Law, Part 2

Ritter’s second law of network administration: If you give a user something to click, they’ll click it.

For all the complaints we make about them, users can be a resourceful lot. They seem to find all kinds of ways to get themselves into trouble, from making their desktop fonts so large that windows no longer fit on the screen to sticking a USB drive into the Ethernet port on the side of a laptop and griping that the computer doesn’t “see” the thumb drive anymore. It’s this cleverness for getting themselves into a situation and their unwillingness to extricate themselves from it that leads me to my second law.

The problem is endemic: humans are attracted to something new and different. I have a ball-point pen that has a little blinking blue light on one end. I have no idea what purpose the cool blinking light serves, except that it made me buy the thing. Users, too, will succumb to new icons, buttons, or anything that looks extraordinary, and they often end up sticking their mouse pointer where it doesn’t belong.

The simple administrative solution is to hide things you don’t want users to see. Both Windows and Linux have policy tools that allow an administrator to remove features from the user’s desktop, reducing the probability that they’ll click the wrong thing. This is not a substitute for security: permissions and rights should still be configured to prevent a user from doing anything to the computer that’s not in their job description. But if we can save just one harried help-desk employee the horror of a single clueless call, our work will have been worth the effort.

Be seeing you.

It’s the Law

Ritter’s first law of network administration: An administrator at rest tends to stay at rest.

An administrator’s day could easily be consumed with all the little, mundane tasks that are necessary to keep things running smoothly. Backing up servers, reading log files, preparing reports on resource utilization, playing RuneScape—it all really eats into one’s time. That’s why I formulated my first law of network administration. I noted that, as a network admin, when things could pretty much take care of themselves, I could relax and better savor the more fulfilling moments of my job, like reducing a user’s disk quota or reading a user’s more provocative email messages. Here is a short, alliterative list of tips to help you achieve network nirvana:

Aggregate

Locate shared resources that have common security requirements in the same directory structure on your file server. Set access permissions only once on the highest-level directory that these files have in common. Use permission inheritance to ensure consistent security on all the files in the hierarchy.

Don’t assign permissions directly to users. Add users to appropriate groups and assign permissions to the groups. That way, you need only add a user to a group to ensure that all the access they require is properly configured.

Automate

Do nothing by hand if possible, because hands can be so error-prone sometimes. Learn a scripting language and write (or download and customize) scripts to perform common, repetitive tasks like reading log files and collecting report data. If you administer a windows network, you must learn PowerShell. It’s available for windows versions from XP onward, and is the “wave of the future.” If you administer a Linux network, you must learn bash. If you manage a mixed environment, I strongly recommend that you learn Python—it’s sufficiently platform-independent and very mature, with a smörgåsbord of cool features built in.

Alert

Let your network tell you when there are problems. Install a network monitor system that’s capable of notifying you when your file and email servers run low on disk space, or when your web server stops responding. When you can address an issue before your users even know it’s there, they’ll come to respect your precognitive powers and revere you for the system superhero you really are.

Well, that last one, not really, because they won’t know there was a problem in the first place, right? But hey, we’re geeks: we’re good at fantasy. Now roll a D20 to see whether your invisibility-from-Lumbergh spell worked before he asks for those TPS reports. Again.

Be seeing you.

William Tell Told Again

william_tell

William Tell Told Again

The Swiss, against their Austrian foes,
Had ne’er a soul to lead ‘em,
Till Tell, as you’ve heard tell, arose
And guided them to freedom.

Tell’s tale we tell again — an act
For which pray no one scold us —
This tale of Tell we tell, in fact,
As this Tell tale was told us.

—P.G. Wodehouse, Prologue, William Tell Told Again

Be seeing you.

My Family’s Fond of Gadgets

My Family’s Fond of Gadgets

technology-leon-zernitsky

My family’s fond of gadgets
and new technology.
My mother likes her radio.
My father likes TV.

My sister likes to dance around
the house with headphones on.
My brother plays on his PC
until the break of dawn.

The baby has a smartphone
and a touchscreen-tablet too.
If we had pets, I’m sure
that even they would have a few.

We chat with instant messaging.
We email and we text.
We’re always looking forward
to the gadget we’ll get next.

The power went out recently.
That day was like no other.
Our screens went blank and, strange but true,
we talked to one another.

Kenn Nesbitt

Be seeing you.

Less is more

Searching through a file within the less pager

It is not uncommon when working from the command line to want to view a text file that is too long to fit on the screen. For those instances we can use a pager like less.

$ less some_rather_large_file

Navigating through the file is pretty straight forward. Press the enter or “j” key to scroll the document down one line and press the “k” key to scroll up one line. Press the space bar or “f” to scroll down one “page”, or screen, and press “b” to scroll up. To scroll by half a screen, press “d” (down) and “u” (up). Press “q” to exit less, and press “h” for help.

To search for text within your document press the slash key, “/”, then enter the text you’re looking for. This will search from the current cursor position forward toward the end of the document. Simply type the slash and enter to repeat your search. All instances of the search string that are currently visible on screen will be highlighted and the cursor will move to the next one. To search from the current location backward toward the beginning of the document, type a question mark, “?”, followed by the search text. Enter the question mark alone to repeat the previous search.

By default searches in less are case sensitive. If you want to search for text regardless of case, enter -i. This will switch less into case-insensitive mode until you enter -i again or exit less.

Interestingly, case insensitive searches only work if you enter your search text in all lowercase letters. If even one uppercase letter appears in your search string less will treat it as case sensitive.

Be seeing you.

They are not long

 

Wine and Roses

Vitae summa brevis spem nos vetat incohare longam.

They are not long, the weeping and the laughter,
Love and desire and hate;
I think they have no portion in us after
We pass the gate.

They are not long, the days of wine and roses,
Out of a misty dream
Our path emerges for a while, then closes
Within a dream.

Ernest Dowson

Be seeing you.

Summer Hiatus

summertime

Summertime, summertime, sum sum summertime

It’s time to take a little break for the summer. Don’t worry, though, I’ll be back in September with more cool stuff (well, cool to me anyway) and probably some more ravings and definitely some more literature. In the meantime take a look at this summary of what we’ve talked about this season.

Be seeing you.

Linux

Waits at the window wearing the face that she keeps in a jar by the door…

Editing multiple documents in vim: Using vim windows

We’ve talked about using buffers to edit multiple documents in vim. Each file lives in a buffer which, in turn, lives in it’s own tab page, rather like a tab in a web browser. But sometimes I want to view one file while editing another, and it would be handy to have both files in the same screen at once. To support that, vim gives us windows.

To split the screen into multiple windows in vim, switch to command mode and run :split or control-w followed by s. This will split the screen into two windows, each containing a copy of the file that was in the original screen. Running :split again will create a third pane, and so on.

If you want to open the new pane with a different file, run :split <filename>. This will open a new window with the other file loaded inside. To open a window with a new, blank file, run :new or control-w n.

The active window can be resized with with the command :resize # or z#, where the # sign is the number of lines high that the window should be.

To move up and down among the visible windows use control-w k and control-w j respectively. To close the selected window, run :close or press control-w c.

There are actually many commands to manipulate buffers and windows in vim. These are the basics and will get you through most common tasks. To learn more, go to vim’s command mode and run :help window.

Be seeing you.

It’s only words, and words are all I have…

Using printf in BASH

In Linux we write a lot of shell scripts to help us automate things or ease complex tasks. Sometimes we need to display some information on the screen, so it’s pretty common to find quite a few echo statements lying about, like so:

echo $USERNAME
echo "I'm sorry Dave, I can't do that."

The command is also useful when we want to examine the contents of a variable from the command line. For example, to see the exit code of the most recently run command:

$ echo $?

Continue reading