Thursday, November 06, 2008

Useful, stupid Unix tricks

Today on Slashdot there is an article that asks people to submit their stupid, yet useful unix tricks.  While there are a number of good ones on there, I did pick up a couple of interesting ones. 

One of the things I picked up was to type "ssh username@" and then hit tab and you would get a list of available hostnames to connect to.  These are pulled from the machine's hosts file.  Now, one thing it doesn't do is get a list from your local, internal DNS, so don't get discouraged if you don't see your host name on there but know you can connect it.  That is the reason.

There was also a bit of a heated exchange regarding the use or lack of use of the 'sudo' command.  There are a bunch of people that claim, and I quote...  "Pshaw! All 1337 sysadmins just live as root!".    This is obviously someone who only administers his own system and nobody elses.  I would personally be very scared to have this person as a sysadmin.  I have done sysadmin work a number of times and at my present job we maintain our own machines, so root is part of the curriculum.  But, you won't see us exclusively "su -" into the root account all day.  If I need to do anything as root, I either use sudo for a quick job or if its more intensive, I use 'sudo bash', which makes you root as well.  But once done, I get out of it and back to my account. 

See, what these apparent noobs to the sysadmin scene don't realize is that the root account was not meant to be logged into all day doing all of your work.  That is what you have a user account for and the reason you should use your own account whenever you can.  Granted, I know that there are people I have dealt with who have systems that ONLY have a root account and that's it, but that would be one of the few exceptions to the rule. To run as root all the time just "because you can" is juvenile, inexperienced and immature.  Most sysadmins who have earned their titles know the rules of root and abide by them for a reason.  I yearn to be there when one of those "pshaw" kids makes a wrong move as root and looses a TON of needed data that makes them drop to their knees and cry.  I don't wish extensive data loss on anyone, but my hopes would be that they would learn their lesson.

Another command I recently discovered before seeing this list was the screen command, which is used during remote access to execute commands that may take a while to run.  You can then disconnect from the console and then reconnect later and reconnect to the screen session you had running.  Its pretty sweet really and allows your machine to not be tied up on a process.  Unix is so sweet like that, always a way to do something!

Friday, October 24, 2008

The [sometimes] trouble with updates

No, I am not referring to Windows updates. Instead, I am referring to Linux updates. There are mixed views on whether you should do updates or not on your system(s). Here is my view.... if it is a server, update it ONLY when you are absolutely needing to. This means only if there is a security hole that is fixed by a newer version. On the other hand, if it is a desktop system, if you update then it is up to you.

If you do updates though, you really need to watch out. Make sure you know what exactly is happening during the update(s) as things tend to change and also stop working.

I did an update earlier this evening after booting up my laptop. No worries, right? Wrong. When I tried to start my apache web server (which was previously installed and working fine), I discovered that it was no longer working. Strange if you ask me, but it wasn't starting up. It kept giving me the same errors:

# /etc/init.d/apache2 start
* Starting web server apache2 [Fri Oct 24 22:15:10 2008] [warn] module php5_module is already loaded, skipping
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

I started by plugging in the different errors into Google, but kept going in directions I didn't think were the answer. Then I looked at the last error: "Unable to open logs". That was odd because I hadn't changed anything, but...... then there was the updates.

So I checked and the /var/log/apache2 directory and saw that it was owned by root and had a group of adm. I distinctly remember that being the group root the other day. So, instead of changing permissions (which is someting I was not wanting to do, I decided to add root to the adm group.

I restarted apache and VOILA!!! Problem fixed. So, the lesson.... know what updates are being applied and if something doesn't work afterwards, you will at least know why.

Reblog this post [with Zemanta]

Sunday, October 12, 2008

Linux Filesystem Layout

I was "stumbling" around and I stumbled across a page that showed a graphical layout of the Linux Filesystem. For those that are beginning in their Linux ventures, I can imagine that this will be quite helpful. Without an understanding of the filesystem, a lot of things will be lost in your learning process, so learn it well.
Reblog this post [with Zemanta]

A change to my previous posting

In my previous posting of MySQL commands, #6 talked about granting permissions to a user on all databases. It should be noted that it is much wiser to first:

- create the user account in mysql first and set the password.
- then, set the permissions that the user has for said database(s).

Thursday, October 02, 2008

Some useful MySQL commands

Lately I have been getting quite intimate with the MySQL database and have been doing things beyond the standard queries and adds. Here is a list of some other useful commands that I have been working with lately. Please know that any options to these commands that are in [ ] are considered optional:

1. Delete a databse:

Format: drop {database | schema} [if exists] db_name;

This command drops all tables in the database and then deletes the database. You need to have 'drop' privilages to do this. *Note: As of MySQL 5.0.2 "schema" is a synonym for database.

2. Delete a table:

Format: drop [temporary] table [if exists] table_name[, tablename, ...] [restrict | cascade];

This command will delete one or more tables from a database. Again, you must have drop permissions for each table.

3. Back up a table to file (in case a recovery is needed after doing something like an alter on a table):

CLI Format: mysqldump --user=<username> --password -B <database_name> --tables <table_name> > filename.sql

This command should be issued from the command line, not from within mysql's interface, as the two previous commands would be. The '.sql' extension on the file tells you that the data inside is for sql. If you open the file, you will see a plethora of sql commands to recreate the table as it was.

4. Restore a table from a backup sql file:

CLI Format: mysql -u <username> -p <database_name> < filename.sql

This will restore the table to its original glory.

5. Delete all data from a table:

Format: truncate <table_name>;

This will erase all data from the table, leaving the defined schema in tact.

6. Grant permissions on database's to a specific user:

Format: grant {comma separated permissions list} on <db_name>.* to `username`@`localhost`;

This will grant whatever permissions needed to the specified user. Now, if the user account in MySQL does not exist, then after the username@localhost piece, you will need to specify:

identified by password `password`;

Now, the tic marks around `password` and `usrename`@`localhost` are all back tics. That is what I tend to use and have never had a problem.

One note of caution, BE CAREFUL using the above commands. They are commands that will cause serious changes to your database and tables. Practice on a test database before doing ANYTHING on a production database. Also, make sure to back up any tables or databases that you work on. As we all know, whatever can happen.... usually will.

Wednesday, September 24, 2008

Cheap is as cheap does

The way that the economy is today and how it is driving the price of everything up, its no wonder that people are looking for cheaper and cheaper ways to do things. 

One area that people are always looking for a free way to get what they want is with regards to creating a website.  To have a website, you typically need a domain name and a place in which to have that domain hosted.  Domain names are typically about $8 to $10 per year to register (depending on where you go) and if you are a teenager or don't have a credit card at the present time, then you need some way to get one. 

*Note:  If you are starting a small business then it is highly advised that you buy your own domain and get a good hosting provider.  A free host and free domain are not really the way to go as it may effect your reputation depending on your business and its model.  This is especially true for those in any geek related profession. 

For this example, I will use Geocities by Yahoo.  They provide you with free web space, all you have to do is have an account with them.  Granted, you won't have available all of the services of a real hosting provider, but believe me, when you are just needing to have a web presence and don't have a lot of $$$, you cannot just look free in the mouth. 

Once you have setup your free site at Geocities, you will now have a domain name that looks like "http://www.geocities.com/username", where username is your account name on Yahoo's system(s).  Again, this does not really that descriptive of you, I know.  So, how can we get a domain name that we would like, while maintaining the free nature of this article?  Why not turn to dot.tk.  The provide you with URL re-direction.  You simply create the domain name that you would like and tell them where it should point to.  That way, you can give out your easier to remember .tk address and it will re-direct the incoming traffic to your Geocities site. 

Note:  Please know that I am not associated in any way with Geocities or dot.tk.  After browsing around and seeing mention of the dot.tk website, I figured I would write this so others would know about it.  Please don't read anything into this article as its for informational purposes only.

There is always a catch, isn't there

I came across a link today that said "Free Domain Name for 1 Year to Small Businesses".  So, I clicked it and it brought me to Register.com.  At that link is the offer that was in the advertisement. 

So, I typed in a domain that I was thinking about and hit "Go".  Voila, the domain was available and all I had to do was select that I just wanted the Free Domain, without any extra services, which I did.  Next, I was asked to either log in(for existing / returning Register.com customers) or create an account.  Ok...

Being the anal person that I am, I decided to read through the fine (light grey) print at the bottom of the page, you know, the stuff they hope you won't notice and read.  In there it said that even though the first year was free, you are required to supply them with a credit card number anyway as part of their "standard registration policy". 

This is something I did not want to comply with at this time.  Why do I have to enter a credit card number if there is no charge to me?  I know that a lot of businesses require this, but its ridiculous if you ask me.  Why get a card number on file if its not needed?  Wait until after checkout, and if there is a balance, obtain it at that time.  Is that so hard?  Sheesh!!

Needless to say I closed the site and left as I wasn't about to divulge the digits from any plastic I may have.  I just wanted to post this so everyone else was aware of this fact before clicking on said advertisement should you happen across it. 

Tuesday, September 23, 2008

A little catch up

I must say that when you get up at 6:30ish in the morning, spend the entire day working on coding issues, writing code or some kind of sys admin issues (usually all within the same day), come home to two little ones in the evening, by the time bedtime for them comes, you just don't find much energy to blog.  Lately, in the evenings, I find myself either "stumbling" around the internet or just playing a mindless game to relax.  That is pretty much what I have been doing (and not blogging) as of late. 

Every once in a while, like now, it hits me that I haven't blogged for some time and I should really get back to it.  Now, this isn't to say that I haven't been learning anything.  My, oh my, have I been learning stuff.  As of late, I have Ubuntu 8.04 on my laptop and have been learning the best, right way to configure it. 

I started by downloading MySQL, PHP, and Apache2 and compiled them all by hand, getting them installed the way that I want them, configured with the options I want/need.  From there, I have been setting each up.  I have learned a ton about the Apache2 config and how it works.  Not only that, I have created my own Certificate Authority, created and signed my own key pair and have secured my internal website (on that machine) to have an "https://" alternative.  There are things that I am investigating right now, like how to make it so a site or a page is required to be loaded with https vice http. (for security reasons of course) 

On the flip side, MySQL has been another bit of knowledge that I have been actively acquiring.  Of course it certainly  helps that at work they use MySQL for what we do, so interacting with and learning the database is crucial to doing my job.  I have wanted to learn it for long enough that I am glad to have this opportunity. 

Also, because there are some new sites at work (internally) that use PHP for the pages, I am learning that as well as I am sure I will have to support them or create new pages in the future. 

So, to all of you out there who are saying, "Wow, I would love to learn about that technology!", there is no time like the present.  Install it, play with it, learn it. If you don't play with it, you won't learn it.  You could read the books and absorb what you could, but unless you have a photographic memory and a memory search engine equivelant to Google's algorithm, then you will need to play with everything you can to learn its intricacies. 

Wednesday, July 16, 2008

My Latest Addiction

Every day you hear about people getting addicted to things like drugs, alcohol or even cigarettes. Being a geek though, I am a little modified in my addictions. See, I don't do drugs (never have), I don't smoke (anymore, gave it up cold turkey 10 years ago) and I only occasionally drink.

Instead, my addictions tend to orbit around computers. My latest however happens to be a plugin for the Fire Fox web browser called StumbleUpon. After installing the plugin and restarting your browser, go into the configuration and select all of the topics that you want to "stumble upon". I warn you though, there are an overwhelming number of topics but you can right click on each and open in a new tab or window to see what the types of sites it finds.

After you are done with the configuration, open a new tab and click the "stunble" button. It will then randomly select a site from the entire list of topics and display it for you. I have been building up my del.icio.us bookmarks for the past few weeks with an overwhelming number of links to things I have found useful and/or interesting. I suggest you give it a try, you might stumble upon something you could use too.

Something New

Wow, has it really been almost 2 months since my last entry? Believe it or not I hadn't noticed. Work has kept me pretty bogged down during the day with stuff to do (yes, that is a good thing as I am loving my job) and things like blogging have had to take a slight back burner with my nightly exhaustion (that is only enhanced by the activeness off our kids.

Speaking of work, we hired an intern for the summer to take on some work that we need to do. He hails from WPI (Worcestor Polytechnic Institute) and has turned out to be a pretty nice guy. He is going into his senior year there and has a pretty interesting senior project going.

He and I have had the chance to chat it up a bit on a number of topics and during such chats, I have been intrigued by how positively he speaks of coding in Python. I always saw Python as an interesting language and had thoughts of learning it but hadn't settled definitely, until now that is.

For the past couple of weeks I have been actively reading about and playing with, Python on a regular basis. It is actually quite an elegant and neat language. The way that you do things in Python is taking a bit to get used to (as well as having to switch back and forth between Python and Perl), but I can handle it just fine.

I see Python added to my coding arsenal for the long haul and am sure that there will be some posts on it here, in the future.

I will try and put together a post containing links to get you started if you are interested. You will be surprised at how easy Python is to learn, even if you haven't done any coding before.
 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.