Showing posts with label mac osx. Show all posts
Showing posts with label mac osx. Show all posts

Monday, September 30, 2013

Recover a file with LSOF....

Just a quick and dirty of how to recover a file in LSOF.



lsof (List Open Files) is a *nix tool that will show open files and network connections. Of course, it's also available for OS X.
You can recover deleted files with it.
If you have ever deleted a file by mistake you can recover the deleted file. 
For example, to recover a missing messages log used by Syslog you can search for it via this command:
bash:~  lsof | grep messages
You should see something similar to:
syslogd   15328      root    2w      REG              253,2   1419873               983175 /var/log/messages.5 (deleted)
You want to find what is marked as deleted in parenthesis.  The process (15328) still has the file open. Without this process keeping the file open we would have lost the file permanently. This is important. Once the process stops, you won't be able to trace the file this way, so avoid rebooting or stopping the process entirely, until after you've recovered the lost file.

We can view the missing info by looking inside the proc filesystem, the process id (15328), and in the file descriptor (fd). The fd is found in the 4th entry, above (2w in this example):
bash:~  cat /proc/15328/fd/2
This outputs the contents the deleted messages.5 file. As you can see, the data is still there. Now, just redirect the contents back to /var/log/messages.5:
bash:~  cat /proc/15328/fd/2 > /var/log/messages.5
That's all there is to it. You have recovered the file with all the data back to its original location. You should also restart the process, writing to the file(s) recovered.
This is just one of many examples of how lsof can be very useful. Be sure to check out the Man pages and other docs.

Friday, May 09, 2008

Mac OSX Leopard & Xnest" OMG-WTF-LOL!

Why, oh why, has my Xnest gone away when upgraded to OSX 10.5? Not that I enjoy running X remotely, from my servers, but on occasion, it's required (thanks, stoopid Oracle and your sh*tty install routine).

If you want/need Xnest on your OSX Leopard desktop, you can accomplish it, this way:

First: Get Xcode: http://developer.apple.com/tools/download/

Second: install MacPorts: http://svn.macports.org/repository/macports/downloads/MacPorts-1.5.0/

Third: Install git, and development tools:

(from teminal window)
sudo port install pkgconfig automake autoconf libtool git-core
Install X.org libraries: (45 minutes)

(from terminal window)
sudo port install xorg-proto xorg-libX11 xorg-libxkbfile xorg-libXfont xorg-libfontenc

Forth: Get X server source from git and build it: see instructions on X.org wiki.

Fifth: Run configure as follows, NOT as how stated on X.org wikki:
./configure --prefix=/usr/X11 --enable-xnest=yes --with-mesa-source=`pwd`/../Mesa-6.5.2

Sixth: Continue with the rest of the source instructions as directed in the wiki page.

Seventh: Copy the new Xquartz binary over, then copy the Xnest binary as well:
sudo cp hw/xnest/Xnest /usr/X11/bin/

Eighth: Copy the manpage:
sudo cp hw/xnest/Xnest.1 /usr/share/man/man1/

That's it. Good luck. I suggest backing up, before doing the above.

Wednesday, April 23, 2008

Veritas VEA 4.x on OSX

Update: 07.28.08
Note: This is only for version 4.x of VEA. 5.x is not currently working, with this method.
------
w00t!

I finally got around to working on this again. Sorry for those who've been asking for it.

turns out, it's quite simple, lol!

Here's how you can get the VEA GUI working in OSX:

Generally, I hate Java, but this does rock.

- Copy /opt/VRTSob from a UNIX host, put it in /opt on your Mac and replace /opt/VRTSob/jre/bin/java with a symbolic link to /usr/bin/java on your Mac.

- Run: /opt/VRTSob/bin/vea.

That's all there is to it.

Saturday, September 09, 2006

How to restart the OSX Desktop...

Without loging out and back in.

Useful for when desktop "freezes" or you have artifacts (see Macbook) and don't want to kill off background processes.

1. Open up term app

2. ps -aux|grep Graphics

3. Find the following:
windowse 52 0.9 5.6 915688 57592 ?? Ss 11:02AM 0:20.62 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/WindowServer -daemon

4. then HUP the found process:
sudo kill -HUP 52

52 is the process id tht I found. Yours will be different.

This will restart the GUI, logging you out, but at least you won't have to reboot the whole machine.

Sunday, September 03, 2006

Veritas Cluster GUI 4.x in OSX howto

I hacked this together, so I can run the VCS cluster GUI on my Mac, instead of relying on Winbloze. I am almost ready to dump MicroCrap altogether! :-)

I'll be working on the VEA gui, later.

While I prefer command-line, sometimes a GUI is still nice. Especially, in a complex cluster arrangement, such as the one I admin.





Veritas Cluster Manager 4.x in Mac OS X


Configuring the Veritas Cluster Manager to use the Mac OS X using OS X native Java.

1- Copy the Veritas GUI from server (/opt/VRTSvcs/gui) to a location of choice on your Mac.
2- Edit hagui script (this script, below) to reflect the location of VRTSvcs and the path to your JAVA Home
3- Open a terminal and run /path/to/VRTSvcs/hagui

The following is a copy of the modified hagui script (modify to your liking):
**************************************************************
#!/bin/sh
#
# START COPYRIGHT-NOTICE: 1998, 2003
#
# Copyright 1998, 2003 VERITAS Software Corporation.
# All rights reserved.
#
# VERITAS, VERITAS SOFTWARE, the VERITAS logo and all other VERITAS
# product names and slogans are trademarks or registered trademarks
# of VERITAS Software Corporation in the USA and/or other countries.
# Other product names and/or slogans mentioned herein may be trade-
# marks or registered trademarks of their respective companies.
#
# END COPYRIGHT-NOTICE.
#

# change the environment's classpath and
# java_home
#unset JAVA_HOME
#unset CLASSPATH
PATH=".:$PATH"
export PATH

#VCS_HOME="/opt/VRTSvcs"
VCS_HOME="/Users/wallen/VRTSvcs"

#JAVA_HOME=$VCS_HOME/gui/jre
LIB_PATH=$VCS_HOME/gui/lib
LANG_PATH=$VCS_HOME/gui/lang

LD_LIBRARY_PATH=$LIB_PATH
export LD_LIBRARY_PATH

BCLASSPATH=${LANG_PATH}:${LIB_PATH}/VCSGui.jar:${LIB_PATH}/gui_images.jar:${LIB_PATH}/sounds.jar:${LIB_PATH}/VxHelpViewer.jar:${LIB_PATH}/VxHelpViewerl10n.jar

DEBUG=0
if [ "$1" = "-D" ] ; then
DEBUG=1
shift 1
fi

if [ "$#" = 0 ] ; then
if [ "$CSGA_DIR" = "" ] ; then
CONF_PATH=$VCS_HOME/gui/
else
CONF_PATH=$CSGA_DIR
fi
elif [ "$#" = 1 ] ; then
CONF_PATH=$*
shift 1
elif [ "$#" -gt 1 ] ; then
if [ -d "$1" ] ; then
CONF_PATH=$1
shift 1
elif [ "$1" != "-h" ] && [ "$1" != "-p" ] ; then
echo "$1: configuration directory doesn't exist."
exit 1
fi
else
echo "$SELFNAME: configuration directory is incorrect!"
exit 1
fi


CLASSPATH=${CONF_PATH}:$BCLASSPATH:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/i18n.jar
export CLASSPATH

if [ $DEBUG = 0 ] ; then
exec $JAVA_HOME/bin/java -Dbase.dir="/opt/VRTSvcs/gui" -classpath $CLASSPATH -mx128m VCSGui $* > /dev/null
else
exec $JAVA_HOME/bin/java -Dbase.dir="/opt/VRTSvcs/gui" -classpath $CLASSPATH -mx128m VCSGui $*
fi