Quick Tip – A Fast Update

I have been a Linux user for seven years, and have used it exclusively for five of those years now. The more I learn, the more interested I become. It is time I give something back, regardless how simple or complex an issue might be.

One time saving trick I have been using for a long while now is using simple bash scripts to complete tasks. Running two different flavors of Linux has tought me a lot. I have been a Debian/Ubuntu user for a while, and recently started using CentOS. Both of these have the Linux kernel at heart, but work in different ways.

I have two scripts I put together to make updating quick and easy. The first part is the script for the Debian based APT system, and the latter will be for the Red Hat based RPM system.

APT

Okay, lets start. The first script will work for pretty much any Debian (.deb) based system, and it goes like this:
Open a text editor of your choice – Vim, Emacs, gedit, etc, and enter in this string of commands.

apt-get update
apt-get update
apt-get dist-upgrade -y
apt-get autoremove -y
apt-get autoclean

Now why did I do two apt-get update’s instead of one. If you were to get an error, APT will tell you that you can fix the problem by running “apt-get update” again. To knock out that message from the start, I just go ahead and update twice, it can’t hurt anything. I added in a “-y” to automatically answer yes to questions where a [Y/n] is required to continue on the process. Now save it as filename.sh, I use update.sh so I can find this script among the others I have laying around on my hard drive. Be sure to have the .sh on the end, since this is a script. Now we are going to run it using a terminal like this.

sudo bash update.sh

You have to have the sudo at the beginning of the command because an update is considered an administrative task, and running this bash script without sudo will lead you to many errors. You will see the script run line-by-line until it is finished. Here is the result of that very simple shell script you just ran:

RPM

On an RPM Linux system like Red Hat or CentOS, the script is a bit different, shorter number of commands, takes longer, but it accomplishes the same goal. You again want to open your text editor or choice and write these lines:

yum clean all
yum check update
yum update -y
yum clean all -y

Yum clean all — dumps the current cache of information so you have a clean slate to start with.
Yum check-update — scans the defined repositories for the latest software to download.
Yum update — as it says, updates the system to the latest files and programs.
Yum clean all -y — cleans up all the files once more.

You will run these as root, or you can use the sudo bash update.sh if you have sudo installed already, or have the system run automatically as a cron job. The RPM updates run differently than APT system updates do, and are known to take much longer, a lot longer actually. Here is what I see when I run sudo bash update.sh on my CentOS Linux computer:

Like I said before, RPM based Linux systems do take a considerably long amount of time to complete, compared to a Debian based system like Ubuntu. Once these scripts are completed, you will have a  fully updated system*, and can continue on with what you were doing.

This is a very very simple script. You can add or subtract from this if you want. I happen to use this script on this webserver, and have to remove the chattr immutable flags I have set on many many files to keep them protected from any type of change whatsoever, with out consent.

I have had no issue using these commands to do my quick system updates for more than a year now, and it saves time.

Side note — I have heard a few people say before that using the tack y (-y) during an update, or clean is dangerous. I am not going to say otherwise, but I have seen, and used this without any issue before. I guess you will have to decide whether to use it or not “at your own risk” as I have heard it said.

* – depending on if no errors occur because of files being locked using chattr, or for any other reason.

Tagged with:
 

Dedicating Myself This Year

I do not do New Years resolutions, because I know that I usually do not really mean what I resolve to do. There is one thing I am going to dedicate myself to working on this year though, receiving a certification in at least the LPI level 1 certification. The LPI certification program includes three levels of certification, each extremely thorough in it own account, but the payoff is great when one completes the process.

Why would I choose to do this rather than working on a MSCE or A+ certification? It is no secret that Microsoft Windows Server products, and other proprietary software solutions are dying much faster than they are growing. With this known, why would I want to waste time in obtaining these certificates, when in ten years, they will more-than-likely be obsolete. In the meanwhile, Linux server infrastructure is growing faster than ever before. I suspect this has something to do with flexibility, security, and overall financial expense benefit outweighs any modern proprietary systems that were popular in the past.

Christmas 2008, my wife bought me the book “LPI Linux Certification in a Nutshell.” I have had this book on my bookshelf since then, with the intention of studying it and working on a Level 1 certification sooner, but for no other reason than laziness, I have not completed it. Do I see this as an insult to Carrie for buying it for me, and then doing nothing with the resources she supplied me with? Yes I do. So to make it right, I am going to dedicate myself to completing this book, not just reading through it, but actually studying and learning the information included within its cover. After that, I plan to find a test center somewhere, take the test, and hopefully pass. This would only be test one of three, but it is a start, and a good goal to set for now.

Linux administration jobs have increased more than eighty percent over the past five years, and this is expected to grow even more as proprietary systems become more expensive, and none the more secure. Companies do not like vendor lock-in, and are pulling away from this old, re-skinned, proprietary computer systems that have been force fed for years and years.

With this outlook, I would like to get in on the fun, and do what I want to do, and enjoy doing now.

One final thing I would like to do is use my newest domain – highlytechnical.net – as a high level tips and trick site with the information I gain as part of the LPI course(s). Looking forward to the learning experience to come.

Tagged with:
 

Bad Behavior has blocked 269 access attempts in the last 7 days.