Linux Journal wrote this summary of myPhile:
This is an extremely simple, yet versatile front end to just about any MySQL database to which you care to connect. Newly installed, it creates a small database address book. It is easily modified for your own purposes and is usable by a small company with few changes and almost no training. It's worth a look if you need a quick and simple address book for the masses. Requires: web server with PHP, web browser.
gomenu
A simple script and associated files that allow dynamic edits for a menu - possibly useful for System Admins.
utils
A handful of scripts that can be used for doing backups, log analysis, graphing, log management etc.
myfiles
A php application to control files for download and to allow authorized uploads, description edits etc.
I had an interesting issue develop today. I was asked to help with a Solaris 10 system that failed to come up after a reboot, or rather, was unreachable remotely after a reboot. The kernel answered to a ping but ssh failed to respond. Fortunately I was able to string a console cable to a laptop and took a look at what was going on. Listing the services and grepping for ssh
# svcs | grep ssh
showed ssh failed to come online. I tried to restart it without success but no messages about why.
# svcadm restart ssh
Doing an check of dependencies
# svcs -d ssh
and a detailed check on the service
# svcs -xv ssh
showed that the filesystem/local:default service was failing to come up. Hmmmm, doing a df -k seemed ok....
So I did the next logic check of the filesyste/local:default service:
# svcs -d filesystem/local:default
# svcs -xv filesystem/local:default
It didn't report any obvious causes but there was the suggestion to go look in the service startup log file - which I did
# view /var/svc/log/system-filesystem-local:default-log
and at the end of the file entries showed failed attempts to mount several (database) partitions due to an error in the vfstab file.
This gave me the clue I needed - the vfstab file had some bogus options on each of the database mount points listed. I commented out all the bogus lines and rebooted the server... that was easier than going through all the svcadm disable and enable steps ...
The server came up and ssh was back online! We fixed the vfstab entries properly and everything was back in order.
Now, I have a problem with all of this. In my mind this is a major weakness of Solaris 10 with the SMF routines. An improper entry in the vfstab for *any* mount point - even non-essential ones can wedge the administrative remote access protocol - leaving you with no other choice but to have a console terminal access (which every one knows you *should* have anyway). This seems like a weakness in the design - am I wrong here?
Friday, February 22 2008 @ 07:07 AM EST
Contributed by: geoffm
Views: 93
apt-get install subversion subversion-tools apache2 libapache2-svn
# Create a new repository
mkdir /data/svnrepos
svnadmin create /data/svnrepos
grpadd svn
#(add the desired users to this group
# - remember they need to restart - even X
# - then
chmod -R g+rw /data/svnrepos
chgrp -R svn /data/svnrepos
# the repository is now ready
#### to import a project
cd to your dev dir eg
cd $HOME/dev
#then
mkdir myproj
cd myproj
mkdir trunk branches tags # trust me add all 3 of these
#edit some files in the trunk dir
cd trunk # $HOME/dev/myproj/trunk
cat "lots of stuff">new.fil
# now drop one dir below your project dir
cd $HOME/dev
svn import -m "myproj START" myproj svn+ssh://username@rhost:/data/svnrepos/
#Then - you *have* to move or remove the old dir out and checkout the proj
#then the .svn dir will be in the project dir making it a working dir.
# This requirement is a little different from cvs
# If the above worked then trust it enough to remove you project directory
rm -r myproj
# Now checkout your project to create you svn working directory tree
svn co svn+ssh://companionway.net/data/svnrepos/myproj/
# Go look to see that you now have svn control files in myproj/.svn
# You should see this assuming you are located in $HOME/dev
@argos ...dev $ ls -la myproj
total 24
drwxr-xr-x 6 geoffm geoffm 4096 2008-02-20 20:02 .
drwxr-xr-x 23 geoffm geoffm 4096 2008-02-20 20:01 ..
drwxr-xr-x 3 geoffm geoffm 4096 2008-02-20 20:01 branches
drwxr-xr-x 6 geoffm geoffm 4096 2008-02-20 20:03 .svn
drwxr-xr-x 3 geoffm geoffm 4096 2008-02-20 20:01 tags
drwxr-xr-x 3 geoffm geoffm 4096 2008-02-20 20:03 trunk
# double check with these commands
cd $HOME/dev/myproj
# Note that you no longer have to declare the location of the repository
# That info is in the control file under the project .svn directory
# The need connection information will be used sutomatically
svn list --verbose -R # long list of files (--verbose) recursively (-R)
# or get the status
svn status --verbose
# get in the habbit of updating your code base from the repository
# before you checkin code - or better, before you modify code or files
svn update
# update your file(s)
cd $HOME/dev/myproj/trunk
echo "more stuff">>new.fil
# to see where you are
cd dev/myproj
svn status
argos ...trunk $ svn status
M new.fil
# Note: the M tells you the file has been modified but not yet checked in
# To add a new file
svn add newfile
# To remove a file
svn remove filename
# Then checkin all the changes
svn ci
# There are a ton of other svn commands but I will leave that up to
# you to learn as you need them
# like revision checkouts, merges, tags, diffs, etc
# Other options for repository access exist but
# I like the simple ssh tunnel shown above
sudo svnserv -d -r /data/svn
#apt-get install cvs2svn - never used - so put notes here
Remember this is just a scratch of the surface.
Enjoy
-g-
Thursday, February 21 2008 @ 09:29 PM EST
Contributed by: geoffm
Views: 93
I recently had to find a way to upgrade the firmware on my
Dell 1505n. But the steps I discovered should work for any Dell laptop.
For a dell laptop - these came from a Dell wiki - some of the steps
have problems which are noted. Do the following:
Suggested steps: do not do these - do the one below:
#wget -q -O - http://linux.dell.com/repo/firmware/bootstrap.cgi | bash
#aptitude install firmware-addon-dell
#aptitude install $(bootstrap_firmware -a)
#update_firmware
Here is what it *should* be
wget -q -O - http://linux.dell.com/repo/firmware/bootstrap.cgi >bootstrap.sh
## they used the wrong shebang
vi bootstrap.sh # change the shebang to #!/bin/bash
chmod +x bootstrap.sh
./bootstrap.sh
aptitude install firmware-addon-dell
aptitude install firmware-tools # they forgot to mention this one
# needed for the next step
aptitude install $(bootstrap_firmware -a) # this one takes a *long* time
# and will report a warning or error with each trial - ultimately it will
# find the right one - and eventually use it
update_firmware # will require a warm reboot - note the firmware upgrade also
# takes some very long seconds to complete.
Tuesday, January 01 2008 @ 08:19 AM EST
Contributed by: geoffm
Views: 3,555
Customizing the eeePC
This Christmas my beautiful Bride gave me a 2 pound small paperback ( O'Reilly ) sized PC - the ASUS eeePC. I read somewhere that one is sold every 6 seconds. Put simply, this is an amazingly satisfying compact laptop. Linux Xandros based (essentially a debian Etch release with a very friendly face) that boots up in seconds, connects effortlessly to a wireless access point, and has you productively working within a couple of minutes max. Its size is rewarding enough but its flexibility may be its silent strength. It is easy to change to an advanced desktop, expand apt repositories and grab pretty much any package you need. I have searched for a good PDA that is relatively small, linux based (preferably debian), with the ability to connect to any server anywhere using pretty much any protocol I want - this comes closer to the mark than I expected. At home I use an old desktop as my gateway machine; the eeePC beats my gateway to pieces with the exception of storage - it boots much faster and operates faster.
The Xandros distribution was comfortable to use. It has a KDE foundation and that becomes apparent when you add the needed changes and packages to use the "advanced desktop". I was initially concerned that the Xandros distribution would be constraining for me but that fear has been replaced with the satisfaction of knowing I can add or change pretty much anything I want.
My guess is that you want a terminal session before you start to do any surgery on the patient - use Ctrl-Alt-t. The firsts packages I added were cvs and vim-full - because I use cvs as a universally accessible repository for all my scripts, tools, and utilities and vim-full becuase I have my own .vimrc file that makes vim more useful for me. I found a link that suggested adding a few repositories (more on that ahead) that were debian etch based and soon I had cvs on-board. The link is: http://wiki.eeeuser.com/addingxandrosrepos. To save you some time I have quoted the import info here:
Repository information
Note: The Xandros repository is for the Server 2.0 which has the same base as the EeePC but with the KDE packages removed.
Note: Not all of the listed repositories have public keys available, so you may get warnings when installing packages from them.
Note: The www.archlug.org domain is not currently (12-Dec-2007) resolving correctly giving errors for these repositories.
The following is a community repository specifically for the EeePC. In the main section are packages that have been compiled specifically for the EeePC. In the etch section are packages that have been reported to work on the EeePC and have minimal unmet dependencies in the stock distro. Leave “etch” off the end of the line if you don't want access to these packages, but it is probably the safest way to add debian packages (no warranties, explicit or implied).
If you absolutely MUST use the Debian repositories for packages, consider user apt-pinning so that you don't hose your system.
If you choose to take the risk to use unsupported repositories you should use pinning.
Note: Xandros Server 2.0 is the closest to EeePC Xandros as it is the only other Xandros OS that is based on Debian Etch; however, it has a lower version of KDE than Debian Etch uses, therefore all KDE apps from the apt repo will not work.
PINNING YOUR SYSTEM
When having multiple repositories it's not unusual that same package exists in more than one of those repositories, but with different version numbers. The default behaviour in an unpinned system is to install the one with the highest version number.
When mixing Xandros with repositories from other sites this is not the behaviour we want. Instead, what we want is to always install packages from Xandros repositories no matter what version they have and only if packages do not exist in Xandros repositories or we explicitly says so shall packages be installed from other repositories.
To achieve this we pin our system by adding following lines to /etc/apt/preferences (if it does not exist, create it).
Package: *
Pin: origin update.eeepc.asus.com
Pin-Priority: 950
-----------------------------------------
Advanced Desktop
The next venture for me was to get the "advanced desktop" up and running as opposed to the "easy" tab based default desktop. I followed the very good wiki I found here: http://wiki.eeeuser.com/ and pulled up the link off of this site for Enabling Advanced Desktop - http://wiki.eeeuser.com/howto:getkde
The wiki guide states:
----
*
From Easy Mode, press ctrl-alt-T
OPTIONAL: this will simplify the following steps, but it means explicitly trusting the Community Repository. Type the following two lines at the prompt, pressing Enter after each:
*
type “sudo synaptic” and press enter.
*
choose Settings…Repositories
*
Press New…
*
Enter the URI http://download.tuxfamily.org/eeepcrepos
*
Enter the distribution: p701
*
Enter the section: main (or “main etch”, if you want access to additional software)
*
Press OK
*
Press Reload
*
Scroll down to advanced-desktop-eeepc
*
Mark for installation
*
If you didn't complete the optional step above, you will see a warning that the package is not authenticated. This is normal.
*
Click Apply (if it's off the bottom of the screen, press and hold ALT, left-click anywhere on the window and drag it up)
*
When you shut down, choose the Full Desktop option on the left of the shutdown dialog
Each time you restart your computer, it will use the mode you were last in (easy mode or advanced desktop). To switch back to easy mode, click the Launch button and click Easy Mode (second last entry).
Other useful tweaks:
---------------------
If you want Skype to use the videocam - follow these steps.
*
You can enable the webcam in the BIOS and then it will be automatically turned on each time you start the Eee PC. Note: this will shorten your battery life considerably.
*
You can open a Terminal window (Ctrl-Alt-T in Easy Mode) and type the following:
sudo echo 1 > /proc/acpi/asus/camera
This second method is handy if you download and install the new Beta 2.0 version of Skype (get the Xandros version) that allows webcam use under Linux. To turn it off again, replace the 1 with a 0.
*
The least kludgy way: get a copy of eeecamtray written by Berkus; this is a little applet that lives in your system tray (handy if you work in Advanced Mode). Follow the forum discussion on the Skype version for more tips and details.
The screen saver on the Eee PC is set to blank the screen after 5 minutes in Easy Mode. There's no apparent way to adjust that time-out setting. However, this is Linux, so there is a way!
In Easy Mode, open a Terminal Mode (type Ctrl-Alt-T) and type:
sudo kcontrol &
Enter your normal password when prompted. If you are in Advanced Mode, just start up Control Centre. And if your Control Centre seems to be missing all of its modules, see the “Recovering from an Oops” section at the bottom of the wiki page on adding xandros repositories.
Once in the Control Centre, select Display > Screen Saver, and adjust the time delay your prefer. You can optionally require a password to turn the screen back on. Ensure you also check the “Make aware of power management” box.
Now select Power Management > Power Control, and check the box for “Enable display power management”. Set the top sliders all the way to the left to disable them, and then slide the bottom slider (“Power off after:”) to the same value as your screen saver. This will ensure that not only does your screen blank the screen, but also the power to the LCD backlight will be cut off. Your Eee PC will not power down after this delay, and will continue to run.
1. Open a terminal window by pressing CTRL+ALT+T on your keyboard.
2. Inside the terminal window type "mkdir ~/.icewm" and press enter.
3. Inside the terminal window type "copy /etc/X11/icewm/preferences /home/user/.icewm" and press enter.
4. Inside the terminal window type "cd .icewm" and press enter.
5.
Inside the terminal window type "nano preferences" and press enter.
6. Now you should be looking at the preferences file you copied at the beginning of this tutorial.
7. Navigate to the line that says "TaskBarShowStartMenu=0" and change the 0 to a 1.
8. Now save the file.
That's it your done, press CTRL+ALT+BACKSPACE and X will restart with your new startmenu.
=======================
That should get you started.
There, now doesn't everyone feel just a little bit better! :)
Enjoy
-g-
Monday, December 24 2007 @ 08:04 AM EST
Contributed by: geoffm
Views: 112
Opening a lot of xterm windows can create a confusing desktop. Adding meaningful titles to the session top bar and task bar can make the situation managable. Here is the function I use built into my sourced in .bashrc file:
###########################################################
xbar () # puts new label on Xwindow title bar and icon
###########################################################
# This function displays the title on the window bar in X
# You can pass the title you want with a parameter
{
# NOTE: in vi editor to create the Esc (which appears here as "^[") use Ctrl-v,Esc
# And to create the Ctrl-G (which appears here as "^G" use Ctrl-v,Ctrl-g
echo "Setting the title bar and icon label in your X session"
if [ "x$1" != "x" ];then
echo " Setting title... "
echo ^[]1;$*^G
echo " Setting icon label... "
echo ^[]2;$*^G
else
echo " Setting title... "
echo ^[]1;$LOGNAME@$HOSTNAME^G
echo " Setting icon label... "
echo ^[]2;$LOGNAME@$HOSTNAME^G
fi
#The title of a XTERM window can be set using the following
#escape sequence:
#
# ESC ] 0 ; title ^G
#
#Example:
#
# echo "^[]0;This is a title^G"
return
}
Saturday, December 15 2007 @ 08:24 PM EST
Contributed by: geoffm
Views: 82
This is a function I keep in my $HOME/.bashrc script.
Add the code below into your $HOME/.bashrc file and source it into you environment with "source $HOME/.bashrc". Then you can use this new function.
Just type "sshkeypush" to find out how to use it
Basically is will create a private key if you don't already have one and then
it will push your public key out to the selected sever under the selected login name...
Then you can log in to that server as the declared user without a password hence forth.
The "sshkeypush" function uses two other functions that I use in many other functions - I have included those here as well (processCMD and askYN).
The "meat" of all this code is this one line:($RNAME=remote_name $RHOST=remote_host)
cat $HOME/.ssh/id_dsa.pub | ssh $RUNAME@$RHOST 'cat >>.ssh/authorized_keys2'
This function could use some work ... but here you go:
#################
processCMD ()
################
{
## This just makes it easier to write commands that you
## also want echo'ed to the screen
## Please be sure to escape all quotes (double or single)
## EXAMPLE:
## processCMD su - $MYUSER -c "ls -la"
# #COLOR_FLAG=${COLOR_FLAG:-YES}
# DEBUG=${DEBUG:-0}
#
# ##if [ "$COLOR_FLAG" = "YES" ]; then
# BLUE=${BLUE:-'^[[34m'}
# NORMAL=${NORMAL='^[[0m'}
# #fi
echo ${BLUE}Executing:${NORMAL} $*
#
# if [ $DEBUG -eq 0 ]; then
# # Because DEBUG is off - actually run the command
eval $*
ERRFLAG=$?
# else
# echo DEBUG is on [$DEBUG] so I am not actually running the command...
# fi
## if [ $ERRFLAG -gt 0 ]; then
## doEXIT
## fi
return $ERRFLAG
} #### End of processCMD function ####
########################################
askYN () # Ask yes or no prompt function
########################################
{
# expects param 1 to be prompt string
# param 2 is optional default ans (case does not matter)
# default to N without any other direction...
# alwasy returns a capital Y or N in ANS variable
# this function will always return 0 if the ANSwer is Y else it returns 1
# EXAMPLE:
# if askYN "Are you happy" y ; then ...
#
ANS="N"
if [ $# -lt 1 ]; then
ERRFLAG=1
doEXIT "This function requires more paramters [askYN]"
fi
# Set the default
case "$2" in
[Yy]|[Yy][Ee][Ss] )
ANS="Y"
;;
[Nn]|[Nn][Oo] )
ANS="N"
;;
esac
while : ; do
printf "$1 (y/n [$ANS]): "
read myANS
case "$myANS" in
[Yy]|[Yy][Ee][Ss] )
ANS="Y"
break
;;
[Nn]|[Nn][Oo] )
ANS="N"
break
;;
* )
break
;;
esac
done
export ANS
if [ "${ANS}x" = "Yx" ]; then
return 0
else
return 1
fi
} ### End askYN function ####
#########################################################
sshkeypush () # pass your ssh public key to a remote host
#########################################################
{
if [ "x$2" != "x" ]; then
RUNAME=$1
RHOST=$2
elif [ "x$2" = "x" ] && [ "x$1" != "x" ]; then
#RUNAME=`whoami`
RUNAME=`id|sed -e "s/[^(]*(([^)]*)).*/1/"`
RHOST=$1
else
echo Usage: $FUNCNAME [remote_username] remote_host [-1]
return 1
fi
#if [ -f $HOME/.ssh/identity.pub ] || [ "$1x" != "x" ]; then
if [ -f $HOME/.ssh/id_dsa.pub ]; then
echo Attempting to pass your indentity.pub key to user $RUNAME@$RHOST...
echo $LINE
#cat $HOME/.ssh/identity.pub|ssh -v -l $RUNAME $RHOST 'cat >>.ssh/authorized_keys'
if [ "x$3" = "x-1" ] || [ "x$2" = "x-1" ]; then
processCMD cat $HOME/.ssh/id_dsa.pub|ssh $RUNAME@$RHOST 'cat >>.ssh/authorized_keys'
else
processCMD cat $HOME/.ssh/id_dsa.pub|ssh $RUNAME@$RHOST 'cat >>.ssh/authorized_keys2'
fi
ssh $RUNAME@$RHOST "chmod 0600 .ssh/authorized_keys*"
echo $LINE
echo Now you may run: ssh $RUNAME@$RHOST
if askYN "Would you like to connect now" y; then
processCMD ssh $RUNAME@$RHOST
fi
else
echo NOTE: For this to work you must have a null pass phrase.
echo " Also keep in mind that the $HOME/.ssh/authorized_keys file must"
echo " have permissions = 0600 or -rw------- and owned by $RUNAME."
echo File $HOME/.ssh/identity.pub was not found.
#echo You probably need to run ssh-keygen with a null pass phrase.
processCMD ssh-keygen -t dsa
processCMD $FUNCNAME $RUNAME $RHOST
exit 1
fi
echo Enjoy!
} ### End of sshkeypush function ###
Sunday, December 09 2007 @ 12:14 PM EST
Contributed by: geoffm
Views: 114
Removing blanks lines and comments - I use this function.
It is called doPURIFY because I often use it to "purify" config files for parse processing.
###########
doPURIFY ()
###########
{
# This function will "purify" any input - stripping out all
# comments and blank lines regardless of position in a line
# Can be called with a filename or just as a pipe
# To call as a pipe - do this cat /etc/hosts | doPURIFY
# and this will strip out all comments in /ect/hosts
# comments can also be removed with egrep -v "^[[:space:]]*(#.*)?$"
if [ "x$1" = "x" ]; then
# we did not receive a filename
sed -e "s/#.*$//" | sed "/^$/d" | sed "s/^M//g"
else
# we received a filename
cat $1 |sed -e "s/#.*$//" | sed "/^$/d" | sed "s/^M//g"
fi
}
Sunday, December 09 2007 @ 10:41 AM EST
Contributed by: geoffm
Views: 1,183
The unix screen tool one of my all time favorites. My first tangible encounter with it was rather ugly - but it did demonstrate its power. I was working with a growing business web delivery service and we had one linux desktop that was not shown in any of our inventory tools - but it did show up in network traffic monitoring tools. We finally narrowed down the location of the linux box and when we got on it I noticed screen temp files (hidden dot files). I took about two minutes to realize that the box had been root-kitted - first step - unplug the network cables. Grabbed copies of everything for forensics and in the process realized screen was running but not shown in the process table - all the process tools had been supplanted by the root kit of course. The final analysis revealed that one of our SA's had errantly accessed an irc channel as ROOT. No, the SA was not me and it was an honest mistake by the "experienced" SA who got temporarily careless. If there is anyone thing you should never do - it is to access anything remotely while logged in as root - especially chat. An eggbot delivered the rootkit in seconds without the SA ever knowing. The "cracker-hacker" set up screen and kept it running all the time - it in turn was remotely connected to another cracked "jump box" which was connected to another "jump box".... etc etc. These series of jump boxes made it all but impossible to find the original cracker box.
So I then took the time to really learn screen - I had heard from every good SA before be about it's many many powerful features - especially when making remote accesses. I started using it a lot as we had snow days where we had to work remotely from home. My use of screen was solidified when I realized what could be done with .screenrc - it made working with screen vastly more useful to me.
I have posted a sample .screenrc file here with lots of tips I have collected from others (thanks to all!)
Continue on to see...
Sunday, December 09 2007 @ 09:58 AM EST
Contributed by: geoffm
Views: 96
There are a couple of unix (small-efficient) tools that can enhance to printed output of large text files:
The most common across most unix versions is probably "pr" (the print tool).
To see the formatted output before sending to a printer:
pr <options> <file> | less
To paginate a text file to a printer:
pr <options> <file> | lpr
To see the options for "pr": man pr
Some useful "pr" options:
-d <-- double space
-f <-- use form feeds instead of newlines to separate pages
-h "your string" <-- custom header centered - use "" to make it blank - defaults to printing file name at top
-l nn <-- set page length in lines to nn - usually not needed
-o nn <-- margin offset
-t <-- omit page headers and footers
-w nn <-- alter page width
--help <-- the gnu usual for help
--- lots of other options as well
Other more powerful tools (postscript converters?) used the same way:
- enscript
# Here is a trick to create a png file with your choice text (large) in it:
echo "My headlines for `date +'%B %d'`"
| enscript -o - -B -f "Times-Bold48"
| convert -crop 0x0 - headlines.png
- mpage
#I have often used this in my .bashrc script that squeezes two pages onto one sheet
################################
mpg () # mpage -H2X - two page per sheet output
################################
# To print a file sideways in two columns try this:
# On an old LaserJet IIIP I had to force the margins a little with
# this command
# mpage -H2X -m75l50r40t file-to-print | lp
# Note: that is an "l" (ell) between the 75 and the 50
# The "l"=left "r"=right "t"=top
# See the man page for mpage - you can set environment variables too.
# other options: enscript -2rF -P<printer> <file>
# or pr <options> <file> | lpr <options>
{
if [ "x$1" = "x" ];then
echo "Usage: mpg filename [printername]"
fi
if [ "x$2" = "x" ]; then
mpage -H2X $1 | lpr
else
mpage -H2X $1 | lpr -P$2
fi
}