Tag Archives: UNIX

Quickly backup files with this bash script

<img class="alignright size-full wp-image-1256" style="margin: 4px; border: 2px solid black;" alt="Bash script" src="http://www best slimming pills.solarum.com/wp-content/uploads/2013/12/script_icon-sm.jpg” width=”150″ height=”103″ />This is something that I use on a regular basis on all of my servers. How many times have you been ready to edit a file and either don’t make a backup copy or make one but by now are real tired of typing out copy one file to another name with a date stamp and blah blah blah. It’s not hard to do, but it gets old quick typing the same thing over and over again, plus you might not always name them the same thing or the same way, so now your backup files have different naming patterns and whatnot.

Don’t worry, I have an easy solution. I created a simple script to backup the file specified and append a time and date stamp to the end of it. I symlink this to the command ‘bu’ in someplace like /usr/bin so it’s always in the path of whatever user I might be (myself, root, backup, whoever?), and then POW, it’s easy to backup files plus they are always named the same way – you just type “bu filename”. Now, if you don’t like the way I name my file copies, feel free to customize this to suit your needs. Also, I currently have the script make the copy right next to the original file, but it would be easy to always copy the files to a backup directory somewhere if you wanted, the possibilities are endless!

OK, on to the script goodness:

#!/bin/bash
 
if [ "$1" == "" ]; then
  echo "No input given, stopping"
  exit
fi
 
YEAR=`date | awk '{print $6}'`
MONTH=`date | awk '{print $2}'`
DAY=`date | awk '{print $3}'`
TIME=`date | awk '{print $4}' | awk -F: '{print $1"-"$2"-"$3}'`
 
echo -n "Backing up the file named $1 ... "
/bin/cp -p $1 $1_${YEAR}.${MONTH}.${DAY}_${TIME} > /tmp/bu_run.log 2>&1
echo "done."

There you have it, a simple file backup script it bash that can save you time and many, many keystrokes. Drop me a comment and let me know what you think, or if you have any suggestions or improvements.

Oracle Sun Microsystems T2000 (and similar) ALOM/SC Password Recovery

ServerSo today, I am working on a nice little Sun Microsystems T2000 server. It was purchased used by my customer and I am setting it up. Right away I ran into a snag, naturally, because I didn’t have the ALOM (Advanced Lights Out Management) or SC (System Controller) password for this machine go to this web-site. According to the person that sold the server, it was pulled from a working environment, the drives were wiped and it was sent out to be sold. This means that I had no way to get the old password from anyone, therefore I had to get past it myself.

Let me lay it out for you. In this situation you can’t really recover the password or see what it currently is. The only option at this point is to go in and clear out or erase the ALOM NVRAM so that you can then get access and setup a new password. In order to do this, you will need to connect your laptop to the serial management port. You can do this with a laptop or PC or whatever but for the sake of this article I am going to just use laptop. You will also need access to the power cords, because you are going to have to physically cut the power to the server to get started. OK, ready? Got everything in order? OK, let’s begin. Continue reading Oracle Sun Microsystems T2000 (and similar) ALOM/SC Password Recovery

Midnight ramblings – probly shouldn’t even read this

It’s pretty strange to me that on those rare occasions when I watch TV I see lots of commercials on from Microsoft comparing Bing to Google claiming that Bing is better when really, it’s a matter of personal preference and taste. I mean, people search the Internet for various and different things and sometimes even the same things but that doesn’t mean that they are seeking the same thing, and even if they are seeking the same thing, they may not want the same results. That’s one of the beauties of the ‘net, it’s ALL subjective! Bing is no better than Google, no more than Google is better than Bing. It’s up to the user, not some fake dork looking geek yelling “Bing it ooooooon” through a megaphone. Give me a break.

It’s about like the Internet Explorer commercials saying that they give you the power to do more, or something about family moments or whatever. I mean, Internet Explorer is pre-installed (or included, or built-in, or whatever, take your pick) on EVERY Windows™®© installation everywhere, and it is still a solid third place contender. For a long time it was second place behind Firefox, but then Chrome surfaced from Google, and now IE has slid to third. Currently, and since about March 2012, the list has Chrome in the lead with 53.2%, Firefox holding on to second with 27.8% and Internet Explorer in third with 12.1% – and that’s while still being the default and only browser on new installs of Windows. If someone wants Chrome or Firefox or anything else they have to use Internet Explorer to go get it! I know, I know, you all already know that. I just don’t know how Microsoft can even think that they have the top end product when it STILL won’t render HTML5 properly.

When we shift the subject to operating systems, the subject becomes even more based on the user and their personal preferences. But then, that’s really yes and no, because most users are pretty much held captive by Windows, and that’s nothing bad or nefarious on Microsoft’s part. It’s just that the majority of computer users out there just don’t know enough to use any other operating system. They know enough about Windows to use it, to get along, and so that’s what they choose. In most cases it’s not even a conscious choice, it’s the only choice, most don’t even know there’s an alternative. Although that’s starting to change a bit since Apple and OSX came to town. Apple took a page from Jean-Louis Gassée’s book with OSX. Jean-Louis Gassée is the man who created the best operating system known to mankind, BeOS. He had the idea that it would be easier to make UNIX user friendly rather than make Windows stable, and created a UNIX based operating system with a beautiful and incredible use interface. Ultimately BeOS didn’t make it, but OSX followed in the same foot steps in my opinion, it’s a UNIX based operating system that is beautiful and easy to use and is becoming more and more popular to date. A year or two ago (I don’t know if it’s still true), Apple was the largest seller/distributor of UNIX based computers in the world. Not bad for a company that almost went under a few years prior!

What does all of my useless rambling mean? Not a darn thing! LOL Except that ultimately, despite what big companies might try to tell us, and what we might believe ourselves, it’s the consume that has the power in the end to drive the industry, and we simply have to vote with our dollar bills. Buy the good stuff and ditch the bad, and for free stuff and open source stuff, it’s pretty much the same, support the good and ignore the bad.

It is my opinion that the Internet is the great playground leveler. Whether it is technology, or entertainment, singing or playing an instrument, dancing or whatever on YouTube, if it’s good … people will like it and view it and share it and it will come to the top. Whereas the bad will fall off into obscurity. The Internet gives even the little guy the chance to be a star at whatever it is that he has chose as his arena fight in. Now, go get some sleep!

A little history for all us starnix guys (and gals) out there

<a href="http://www.solarum weight reduction pills.com/wp-content/uploads/2012/08/ken-and-den-1024.jpg” target=”_blank”>Ken Thompson (seated) and Dennis RitchieIf you spend any amount of time working with or administering UNIX and/or Linux servers, especially UNIX, you should be familiar with the text editor ‘vi’ and some commands like ‘sed’ and ‘awk’. If you have been around a while, or had the good(?) fortune of working on some old(er) systems, you might even remember the line editor ‘ed’. I’ll show my age here and recall fond memories of using ‘ed’ to write code many years back.

OK, on to the point, I was looking through Wikipedia for something entirely un-related, but ran across a tidbit of information that I thought was really cool, and that I knew I had to share with Solarum’s readers. It gives a bit of history about some of the tools that we use and love today.

From Wikipedia:

“ed is a line editor for the Unix operating system. It was one of the first end-user programs hosted on the system and has been standard in Unix-based systems ever since. ed was originally written in PDP-11/20 assembler by Ken Thompson in 1971. Ken Thompson was very familiar with an earlier editor known as qed from University of California at Berkeley, Ken Thompson’s alma mater; he reimplemented qed on the CTSS and Multics systems, so it is natural that he carried many features of qed forward into ed. Ken Thompson’s versions of qed were the first to implement regular expressions, an idea that had previously been formalized in a mathematical paper, which Ken Thompson had read. The implementation of regular expressions in ed is considerably less general than the implementation in qed.

ed went on to influence ex, which in turn spawned vi. The non-interactive Unix command grep was inspired by a common special use of qed and later ed, where the command g/re/p means globally search for the regular expression re and print the lines containing it. The Unix stream editor, sed implemented many of the scripting features of qed that were not supported by ed on Unix; sed, in turn, influenced the design of the programming language AWK, which in turn inspired aspects of Perl.”

It’s pretty cool how stuff flows and comes together. Who knew or would have thought that a couple simple commands or programs would turn into what we have today.

*Note: starnix refers to the combination of UNIX, Linux and any other ix/ux OS that we work with.

Learn Solaris UNIX or Linux Today, The Real Way

OK Folks, I added this post so I could tell you about a new article that I just posted.  Just like the title here suggests, I talk about learning Solaris UNIX and/or Linux the real way or maybe it would be better said as the right way.  I don’t suppose there is a wrong or right way, but still.  In this article I reach down into the depth of not only my own knowledge but I lean heavily on my own experience as well, and use that information to share all I know and can rant about learning solid UNIX and Linux skills for the up and coming nix jockies out there.  I really hope that this article can help someone and maybe more than just one naturally.  It’s some (I think) good advice on how to get started and some of the best ways to dig in there and learn some good stuff.  Maybe in the future I’ll post more lower level hard core how to stuff and see how that goes over.  Some of that kind of stuff I have posted already (like SVM disk info and Symantec Storage Foundations (formerly Veritas Volume Manager)) has been real popular.  Anyway, for anyone interested, head on over to the Library and check out the new article on Learning Solaris UNIX and Linux today, you might find something helpful in there!  If you have any thoughts about it or something you think I should add, please drop me a line and let me know.  Thanks!

PowerUp Your Shell With Your Profile

How about some neat-o shell tricks for everyone to play with? I figured out some neat things the other day while trying to add some functionality to my shell, specifically through scripts or the profile.  What I found was that the magic is in the profile!

Have you ever wanted to have commands that performed certain functions from quick keystrokes rather than long command lines? Of course you have, that’s why we all set aliases in our profiles like ‘ll’ instead of ‘ls -al’ and the like.  But what if you want or need more functionality than simple command shortening? That’s what I was after, more function in a smaller form.  Some way to pass variables to aliases to get more out of them. Ah, but you can’t pass variables to aliases, so we are stuck right? Wrong, that’s where the functions come in to play.

Continue reading PowerUp Your Shell With Your Profile