RHEL7 and ncat changes

One of the tools that I use on a regular basis to test network connectivity updates is the “z” option of netcat.  Apparently when RedHat rolled out the latest version of their distribution of RedHat Enterprise Linux (RHEL) they decided to move to using the nmap-ncat package instead of the nc package.  The command options a very different.

So when attempting to test single port like I would have under previous releases I now use the following syntax:

# echo | nc -w1 $host $port >/dev/null 2>&1 ;echo $?

If the result that is returned is a zero then you have successfully connected to the remote host on the desired port. This also applies to CentOS 7 since it is a “clone” or copyleft port of the RHEL7 binaries.


Checking your password expiration date

While logging into one of the Linux jump boxes at work today, it occurred to me that while I recently got notified about my password expiration from our Active Directory farm, I had no idea when my Linux password would expire or what the password life was.

To find out this information you can easily use the chage command.

Here is what the output looks like:

[user@myserver ~]$ chage -l user
Last password change : Apr 09, 2015
Password expires : Jul 08, 2015
Password inactive : never
Account expires : never
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 7

It may seem like such a simple thing to do, but knowing when your password expires can be a lifesaver on occasion.

Graphic showing several nested command line terminal application windows.

Solaris Tip of the Week: a better du experience

Graphic showing several nested command line terminal application windows.In my day job as a Systems Engineer I frequently find myself switching between different UNIX and Linux distributions.  While many of the commands exist on both sides of the aisle, I often find vast differences in the command line parameters that can be consumed by a given command when used in, for example, Linux vs Solaris.

Recently I came upon this again with the need to easily ferret out the majority consumer of drive space on a Solaris 10 system.  While we did have the xpg4 specification support available, the du command was still missing my favorite option “max-depth”.

In Linux I use this to limit the output to only the current directory level so that I don’t have to face to possibility of wading through a tremendously large listing of sub-directories to find the largest directory in the level I am in.  Unfortunately, in Solaris, even with xpg4, the du command doesn’t have this option, so my solution was to pipe the results through egrep and use that to filter out the sub-directories.

Here is some example output from a RedHat Linux 5.11 server:

[root@atl4cmweb01 var]# du -h
8.0K    ./games
8.0K    ./run/saslauthd
8.0K    ./run/lvm
8.0K    ./run/setrans
8.0K    ./run/ppp
8.0K    ./run/snmpd
4.0K    ./run/mysqld
8.0K    ./run/pm
8.0K    ./run/dbus
8.0K    ./run/nscd
8.0K    ./run/console
8.0K    ./run/sudo
8.0K    ./run/netreport
176K    ./run
8.0K    ./yp/binding
24K     ./yp
8.0K    ./lib/games
8.0K    ./lib/mysql
4.0K    ./lib/nfs/statd/sm.bak
8.0K    ./lib/nfs/statd/sm
24K     ./lib/nfs/statd
8.0K    ./lib/nfs/v4recovery
0       ./lib/nfs/rpc_pipefs/statd
0       ./lib/nfs/rpc_pipefs/portmap
0       ./lib/nfs/rpc_pipefs/nfs/clntf
0       ./lib/nfs/rpc_pipefs/nfs/clnt5
0       ./lib/nfs/rpc_pipefs/nfs/clnt0
0       ./lib/nfs/rpc_pipefs/nfs
0       ./lib/nfs/rpc_pipefs/mount
0       ./lib/nfs/rpc_pipefs/lockd
0       ./lib/nfs/rpc_pipefs
40K     ./lib/nfs
8.0K    ./lib/dhclient
8.0K    ./lib/iscsi/isns

Here is the same example ouput from the RedHat server using the max-depth option:

[root@atl4cmweb01 var]# du -h --max-depth=1
8.0K    ./games
176K    ./run
24K     ./yp
22M     ./lib
32K     ./empty
1.5G    ./log
12K     ./account
236K    ./opt
24K     ./db
8.0K    ./nis
2.9M    ./tmp
8.0K    ./tmp-webmanagement
40K     ./lock
8.0K    ./preserve
8.0K    ./racoon
16K     ./lost+found
1.4M    ./spool
8.0K    ./net-snmp
83M     ./cache
8.0K    ./local
1.6G    .

Here is the command example run without my egrep mod in Solaris 10:

[root@atl4sfsbatchb log]# /usr/xpg4/bin/du -h
  25K ./webconsole/console
  26K ./webconsole
   1K ./pool
   1K ./swupas
   2K ./ilomconfig
   1K ./current/ras1_sfsuperbatchb
   1K ./current/od1_atl4sfsuperbatchb
 4.3G ./current/ras1_atl4sfsbatchb
 2.1G ./current/od1_atl4sfsbatchb
 560K ./current/avs
   2K ./current/ebaps/output
 9.3M ./current/ebaps
 4.0M ./current/psh
 3.1M ./current/autoresponder
   5K ./current/fdms_download
  29K ./current/fdms_server
 109K ./current/fmt
   5K ./current/paris/output
 653K ./current/paris
   1K ./current/od1_sfsuperbatchb
  28K ./current/ccTemplateLoader
 633K ./current/ccTemplateLoaderLegacy
  15M ./current/whinvoices
   1K ./current/appmonitor.prod.netsol.com
 132M ./current/chase
 6.6G ./current
 160K ./archive/ccTemplateLoader
   1K ./archive/od1_atl4sfsuperbatchb
 4.9M ./archive/avs
   1K ./archive/ebaps/output
  26M ./archive/ebaps
 881M ./archive/psh
1014M ./archive/autoresponder
   1K ./archive/fdms_download
 6.8M ./archive/fdms_server
  21M ./archive/paris
   1K ./archive/ccTemplateLoaderLegacy
 4.1G ./archive/ras1_atl4sfsbatchb
 3.1G ./archive/od1_atl4sfsbatchb
 5.9G ./archive/chase
 102M ./archive/whinvoices
  15G ./archive
  22G .

And here is the improved command output using my egrep mod on the same Solaris server:

[root@atl4sfsbatchb log]# /usr/xpg4/bin/du -hx | egrep -v '.*/.*/.*'
  26K ./webconsole
   1K ./pool
   1K ./swupas
   2K ./ilomconfig
 6.6G ./current
  15G ./archive
  22G .