Bash script tip, cutting from variables

Ok, here is a quick tip that has come in handy quite a few times in my days writing shell scripts, for example in bash. Let’s say, for whatever reason, you need to chop off the end of a string (like a variable). Chopping the beginning is easy, just use the cut command, but in order to chop the end you have to know how long the string is so you can tell it where to start. In this example, we are going to us the wc command to figure out how long the string is, and then subtract 1 to cut the last character. You can subtract however many you want depending on how many characters you want to cut. Check it out … Continue reading

Creating a new MySQL database with mysqladmin

Here is a quick tip for all of my command line brothers and sisters out there. If you need to create a new MySQL database, it’s super quick and easy to do it on the command line with the mysqladmin command. Yeah, there are some GUI’s out there, but just because you have a GUI doesn’t mean it’s easier or faster. Besides, if you know how to do it via the command line, you will have a better understanding of what that GUI tool is doing, especially when it messes up.

Back to the tip, if you want to create a database named ‘mydatabase’ you would type something like this:

mysqladmin create mydatabase

See? It’s just that easy! From here, it’s easy create tables too. You can type this right into the mysql prompt, or import from a text file. I’ll have more on that coming up soon. Stay tuned!

New article on setting up sendmail

I have a new article up that I have written and dropped off into the Library about configuring sendmail on Linux. Although it should work on most any distribution that will run sendmail even if some file locations may change. Have a look, check it out, send me some feedback if you love it, hate it, or if I made a boo boo somewhere. As always, I hope you find it useful. Thanks!

Create a file of arbitrary size

Have you ever needed to create a file of a specific size? Not where the contents are anything specific, but you just need a file that is whatever size so you can test disk I/O or network transfer speed or whatever it is you want to test. For whatever reason, I have found it very handy to be able to create these test files when needed, so I thought I would pass along some tips to that end. Here are some ways you can accomplish this with Solaris and Linux.

Continue reading

Good password practices

Passwords, and why the heck are they so important?

Everyone has passwords, some have only a few, and some of us have bunches of them. In some cases, literally hundreds or thousands to manage, and let me tell you it’s a pain in the rear. However, password management is not the main thing this article is about, although it pertains to the subject. No, what I want to talk about today is the area of good passwords, strong passwords, passwords that will defend your server and shun any attack by the bad guys that try to get in while you are away playing Quidditch. I have seen lots of passwords in my day, and let me tell you that there are lots of servers that could be compromised using either “ncc1701” or “corona”.

Continue reading