cordump.com

General System Administration

TIP: Figuring out which RPM’s contain which files

by daven on Feb.18, 2009, under General System Administration, Quick Tips

If you ever need to know what files an RPM will install or what RPM’s “own” a file on your system then the rpm command has a few switches that can help you out.
If you want to know which file’s an installed RPM’s owns:

rpm -ql

If you have an RPM file and want to know what file’s it will create or modify before you install it:

rpm -qpl

And finally if you have a file or directory and you want to know which RPM installed it:

rpm -qf

Leave a Comment more...

TIP: force sudo to forget your password

by daven on Jan.26, 2009, under General System Administration, Quick Tips

Very rarely you need to force sudo to forget your cached password or token in super secret decoder ring lingo. All you need is one little flag an you are ready to

% sudo -k

See simple

Leave a Comment more...

TIP: search and replace, in place, across multiple files

by daven on Jan.20, 2009, under Automation, General System Administration, Quick Tips

Ever have that need to change one little thing in a bunch of files? You know after you accidentally misspelled your Boss’s name as “Marvin Blowhard” on every page of the Company website.
Now you could open up each file in vi and find every reference to Mr. Blowhard to Joe Smith, even using search & replace
s/Marvin Blowhard/Joe Smith/ inside vi get’s kind of tedious after a while. That joke doesn’t seem so funny now, does it?
Now consider a little BASH and sed foo

for i in `ls *.html`; do sed "s:Marvin Blowhard:Joe Smith:g" $i >temp;mv temp $i; done

All nice and done so you can get back to planning your next BOFH moment, like sending him in the into the server room with a flash light to look for breaks in the fiber runs.

Leave a Comment more...

TIP: X forwarding after su’ing to another user

by daven on Oct.19, 2008, under General System Administration, Quick Tips

It is a fairly common occurrence now days for security purposes to disable remote login access for “role accounts” like Oracle or Mysql. This restricts you to logging as a normal user then using the su command to become the role users. It works great in almost every circumstance but what if you need access to a remote X display while su’ed to the role account? Just trying to run the X program as normal will give you an error.
So what do you do? Why you find the Magic Cookie!
Before doing su to the become the new user do

$ xauth list

You should get back a result that looks something like this

hostname.domainname.com:11 MIT-MAGIC-COOKIE-14d22408a71a55b41ccd1657d7923ae

Now that you have your Magic Cookie don’t forget to stock up on the munchies.
su to the new user and tell it what the Magic Cookie is so it can communicate with the Xserver.

su - someuser
password: *******
xauth add MIT-MAGIC-COOKIE-14d22408a71a55b41ccd1657d7923ae

Then export X programs as normal

Leave a Comment more...

TIP: Are we there yet part 2, using a watch dog

by daven on Jan.22, 2008, under Automation, General System Administration, Life in General, Quick Tips

As a follow up to the previous tip on getting notified. What do you do when you have an already running process that you would like have notify you when it completes?
So you kicked off this update that was only supposed to take a few minutes but now an hour later it is still running and you are tired of having to check up on it, wouldn’t it be nice if you could just get a nice little e-mail letting you know when its done. Well, this little one liner just might make your day, ok maybe your hour…

while [ $(ps auxww | grep -i SOMEPROCESS | grep -v grep > /dev/null; echo $?) -eq 0 ]; do echo -n “.”; sleep 5; done; echo `/bin/date` | mail -s “SOMEPROCESS has completed” me@example.com

This little ditty will print a “.” every 5 seconds while the process is running, then when it completes will shoot you a nice little e-mail with the time it completed in the body. Now just don’t forget to the processes in screen so they can keep running even if you get disconnected.

1 Comment more...

MTR: traceroute that works

by daven on Jan.08, 2008, under General System Administration

mtr is an update to the classic traceroute that is able to continue giving results even if one of the hops times out. The homepage
for mtr explains it below:

As mtr starts, it investigates the network connection between the host mtr runs on and a user-specified destination host. After it determines the address of each network hop between the machines, it sends a sequence ICMP ECHO requests to each one to determine the quality of the link to each machine. As it does this, it prints running statistics about each machine.

Leave a Comment more...

A manual version of killall

by daven on Jan.01, 2008, under General System Administration

Sometime you don’t want to use the killall or maybe you work at a site with Solaris servers where getting used to killall is a Bad,Bad Idea. Either way it can be handy to have another method to terminate all copies of a process, or even a related set of processes, with extreme prejudice .
So here we go a little pipe love and we are on our way

$ ps auxww | grep -i "SOMETHING UNIQUE I WAN'T TO KILL" | xargs -i kill -9 {}

The ps and grep parts should be fairly obvious xargs will run whatever you specified substituting {} for STDIN and will repeat on it has processed everything on STDIN, it does use return to separate STDIN so now CSV here.
Have fun killing stuff just use it wisely and if you do decide to try killall on a Solaris machine will you will probably kill what you wanted to as well.

Leave a Comment more...

TIP: using BASH for loops on the command line

by daven on Dec.07, 2007, under Automation, General System Administration, Quick Tips

Sometime you want to run a command or a series of commands in a loop to say shutdown all the nfs daemons via their init scripts. Now we could do them one at a time like:

$ /etc/init.d/nfs stop
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
$ /etc/init.d/nfslock stop
Stopping NFS locking: [ OK ]
Stopping NFS statd: [ OK ]

Or we could use a bash for loop with a little copy & paste

$ for i in /etc/init.d/nfs /etc/init.d/nfslock
> do
> $i stop
>done
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Stopping NFS statd: [ OK ]

Or just completely automate it and get it down quick and easy

$ for i in `ls /etc/init.d/nf*`
> do
> $1 stop
>done
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Stopping NFS statd: [ OK ]

It’s that simple and you saved your self a bunch of typing.

Leave a Comment more...

TIP: VIM — displaying line numbers

by daven on Nov.05, 2007, under General System Administration, Quick Tips

Sometimes in VIM it is useful to display line numbers, for example you want to be really accurate when deleting to line number X. Fortunaly, VIM includes a mode to display line numbers
To enable the display of lines numbers in command mode type:

:set number

To disable the display in command mode type:

:unset number

Now if you decide you would like line numbers to always be displayed simply add set number to your ~/.vimrc and you are all set

2 Comments more...

Installing mytop on OS X

by daven on Oct.08, 2007, under DataBases, General System Administration, Quick Tips

install via CPAN DBI & DBD::mysql & Time::HiRes
CPAN install fails for Term::ReadKey & Term::ANSIColor so install via fink
then hack mytop to
use lib ‘/sw/lib/perl5/5.8.8/darwin-thread-multi-2level’;
then run
mytop -u username -p passwd -h hostname -d any real DB on the host

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...