19
05
2008
Posted by: admin in GNU Tools, One Liners
seq comes with the -f option, allowing us to specify a printf(3) format string.
For example, to zero pad seq output (five zeros):
$ seq -f %05g 1 10
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
See: seq(1) printf(3)
Cheers,
Kevin
No Comments »
14
05
2008
Posted by: admin in Solaris
Recent versions of Solaris come with a suite of tools known as the “/proc” tools, which list and/or modify process information in the kernel-maintained /proc filesystem. One of these tools, pcred, can be used to change (among other things) the UID of a running process, e.g.:
# ps -ef | grep sleep
root 25853 22210 0 09:55:53 pts/10 0:00 grep sleep
kevin 24088 24081 0 09:50:53 pts/11 0:00 sleep 10000000
# pcred -u 123 24088
# ps -ef | grep sleep
mrbig 24088 24081 0 09:50:53 pts/11 0:00 sleep 10000000
root 25911 22210 0 09:56:02 pts/10 0:00 grep sleep
If you run a man proc, you’ll receive the manual page for the /proc tools - highly useful!
Cheers,
Kevin
No Comments »
06
05
2008
Posted by: admin in One Liners
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
No Comments »
07
03
2008
Posted by: admin in LDOMs, Solaris
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
No Comments »
08
01
2008
Posted by: admin in One Liners
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
No Comments »
28
12
2007
Posted by: admin in One Liners
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
No Comments »
14
12
2007
Posted by: admin in Solaris, networking
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
No Comments »
10
12
2007
Posted by: admin in Uncategorized
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
No Comments »
07
12
2007
Posted by: admin in Misc
Got this from The Simpsons Movie Website - you can create your own Simpson-esque avatar.
This kinda looks like me…

No Comments »
04
12
2007
Posted by: admin in One Liners, Security, Solaris
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
No Comments »