Simple one liner to remove empty files older than 7 days

# find . -type f -mtime +7 -ls | awk '$7 == 0 { print $NF }' | xargs rm

Cheers,
Kevin

If you try to view LDOM configuration information as a non-privileged user, you’ll probably be greeted with this:

$ /opt/SUNWldm/bin/ldm ls
Authorization failed

You can assign the “LDoms Review” profile to grant this privilege, i.e.:

$ su -
# usermod -P "LDoms Review" username
# profiles username
LDoms Review
Basic Solaris User
All
# exit

Now, you can view the LDOM Configuration as the non-privileged user to which the privilege was assigned

$ /opt/SUNWldm/bin/ldm ls
Name State Flags Cons VCPU Memory Util Uptime
primary active -n-cv SP 4 1G 0.3% 7d 23h 48m
test-domain active -n--- 5000 6 4G 0.2% 7d 19h 55m

Cheers,
Kevin

When grabbing files with wget, it is useful to sometimes not traverse parent directories. For example, say I want to download everything under http://www.example.com/my/home recursively, but not traverse upwards into parent directories. You can add the –no-parent option for this.

$ wget -r --no-parent http://www.example.com/my/home

Cheers,
Kevin

I wanted to remove a large number of files from a directory. However, I did not want to descend into subdirectories, nor did I want to remove any .pdf or .chm files. Some of the files had non-standard characters (such as quotes and spaces) in them.

The solution? A simple one liner using find and xargs

$ find . \( ! -name "*.pdf" -a ! -name "*.chm" \) -maxdepth 1 -type f -print0 | xargs -0 rm

Cheers,
Kevin

Analysis some issues with multicast on a pair of Solaris boxes, I wanted to filter out some unwanted multicast addresses when viewing my snoop traces.

However, by default, snoop will resolve IPs, and ALL multicast IPs in the 228.x.x.x range (which I’m using) resolve to “reserved-multicast-range-not-delegated.example.com”

# dig -x multi.cast.ip.here

So… how to “play back” the snoop output without name resolution? Just use the -r option. I also added -ta to get readable timestamps.

# snoop -ta -ri ./input_file.snoop

I could then pipe this through grep -v and see only the information I cared about.
Cheers,
Kevin

This is for an old version (4.5) of Veritas NetBackup.

# pwd
/usr/openv/volmgr/bin
# ./vmcheckxxx -rt tld -rn 0

Robot Contents          Volume Configuration

Slot    Tape  Barcode           Media ID Barcode        Mismatch Detected
====    ====  =============     ======== =============  =================
1      Yes  -none-            A00000   -none-
2      Yes  -none-            A00001   -none-
3      Yes  -none-            A00002   -none-
4      Yes  -none-            A00003   -none-
5      Yes  -none-            A00004   -none-
6       No
7       No
8       No
# ./vmupdate -rt tld -rn 0
Generating list of recommended changes ...

Proposed Change(s) to Update the Volume Configuration
=====================================================
Volume configuration is up-to-date with robot contents.

Obviously, your robot type (-rt) may be different. Here, we see that the volume configuration is already up to date, thus no changes are made.

Cheers,
Kevin

Got this from The Simpsons Movie Website - you can create your own Simpson-esque avatar.

This kinda looks like me…

If you don’t have the md5sum utility installed, just use the digest tool supplied with Solaris 10

$ digest -a md5 -v /bin/ls
md5 (/bin/ls) = b57e173220af4b919f1d4bef9db11482

Cheers,
Kevin

When you build Perl modules under Solaris, they are optimised for Sun Studio, which of course, we all use :/

So, if you build with gcc, the build will likely fail.

You can use the following magical one-liner to fix this brain damage, and your modules will build correctly.

# pwd
/usr/local/src/cpan/Some-PerlMod-0.123
# find . -name "Makefile" | while read MAKEFILE; do
> sed 's/^CC = cc$/CC = gcc/' ${MAKEFILE} > ${MAKEFILE}.tmp
> sed 's/^LD = cc$/LD = gcc/' ${MAKEFILE}.tmp > ${MAKEFILE}
> sed 's/^CCCDLFLAGS = -KPIC$/CCCDLFLAGS = -fPIC/' ${MAKEFILE} > ${MAKEFILE}.tmp
> sed 's/OPTIMIZE = -xO3 -xspace -xildoff$/OPTIMIZE =/' ${MAKEFILE}.tmp > ${MAKEFILE}
> sed 's/ -xarch=v8//' ${MAKEFILE} > ${MAKEFILE}.tmp && mv ${MAKEFILE}.tmp ${MAKEFILE}
> done

Cheers,
Kevin

Another OpenSSL related tip.

If you’ve ever wanted to generate a hashed password suitable for inclusion in the /etc/shadow file (for example, during post-install procedures such as sysidcfg), you can use the openssl passwd command

$ openssl passwd
Password:
Verifying - Password:
HaShEdPaSsCoMeSoUt

Cheers,
Kevin

« Previous Entries