Know Heads from Tails about Linux

Know Heads from Tails about Linux

July 21, 2014 0 By Eric Shanks

1981-d-washington-quarterThere are a few Linux commands that vSphere Administrators should know for basic troubleshooting purposes and I wanted to take a second to review them in case you’ve typically been a Windows Administrator (like me).

First, traversing the Linux file system is pretty similar to going through Windows directories from the command line.

 

 

 

 

 

 

 

change directories

Windows :  CD C:dirname

Linux : cd /dirname

 

Show files and folders

Windows :  dir

Linux : ls

 

Since this post is for VMware Administrators I wanted to focus on the Head and Tail commands.  If you’ve gotten into the ESXi host operating system, chances are you’re troubleshooting a problem and need to look for some logs.

There are a few commands that will help with this:

 

HEAD

Head is a way to read the top 10 lines of a file.

for instance

head /var/log/vmkernel.log would read the top 10 lines of the vmkernel log file.  (maybe not incredibly useful)

Capture

TAIL

tail is , you guessed it, a way to read the bottom 10 lines of a file.

for instance,

tail /var/log/vmkernel.log will show the last 10 lines of the vmkernel log file.  (possibly more useful)

If you use the tail command with a -f (f for follow) it will continually update the screen as new entries are added.

As an example, tail -f /var/log/vmkernel.log will initially show the last 10 lines of the vmkernel log, but as more entries are written to it, they will show up like a running log file on your screen.  Press Ctrl + C to cancel.

This can be an incredibly useful tool when troubleshooting events.

 

Summary

I know this is just the tip of the iceberg if you really want to learn anything about Linux, but this is pretty useful information for someone who spends their days in a Windows GUI and all of a sudden needs to troubleshoot ESXi hosts.

Also, if you’re looking for a neat way to turn on SSH to your hosts so you can run these commands, check out this post by a good friend of mine James Green :  http://www.virtadmin.com/virtadmin-ssh-tool-vsphere-clusters/