OpenSSH Tips and Tricks

Joe ‘Zonker’ Brockmeier has a nice write up on some pretty helpful OpenSSH tricks. Two of the tricks he lists is X forwarding with SSH, and using the SSH fuse filesystem. Both of which I use on a daily basis.

Check it out here.

Quickzi: Replace all spaces with a dot in vim

Here’s a quick tip on how to replace all spaces with a dot in vim:

:%s/[ t]/./

And here’s how to remove all trailing spaces at the end of each line:

:%s/s+$//

Have any more vim quick tips? Let’s hear them in the comments.

Quickzi: Find files older than 5 days

Here’s a quick command line tip to find files older than 5 days, and execute an action on those files:

find /home/foo/* -mtime +5 -exec echo {} > oldfiles.txt ;
&& mail -s "files older than 5 days" foo@foogazi.com < oldfiles.txt

This command searches for files that are older than 5 days, and sends the output to oldfiles.txt, then an email is sent to foo@foogazi.com with a list of the old files.

Alternatively, you could search for files older than 5 days, then delete them using this command:

find /home/foo/* -mtime +5 -exec rm {} ;

Yesterday, as first reported by The VAR Guy, if you would have went to Dell.com/Ubuntu, you would have seen a “top 10″ list of “things you should know about Ubuntu.” The best one on the list at the time was number 6, which stated:

6) Ubuntu is safer than Microsoft Windows The vast majority of viruses and spyware written by hackers are not designed to target and attack Linux.

Today, if you visit the same Dell.com/Ubuntu, you’ll see the following change:

6) Ubuntu is secure According to industry reports, Ubuntu is unaffected by the vast majority of viruses and spyware.

Pretty comical huh?  Many of us in the Linux industry are claiming that this is probably an evil doing of Microsoft pressuring Dell to ‘correct’ the statement.  Which, really, would not surprise me the least bit.

I suppose I understand why Dell changed their tune, but in actuality, the first statement was nothing but a simple true fact.

What do you guys think?  Should Dell have kept their ground?

The Best Linux Articles

Chances are if you’re a new reader, you haven’t read a lot of the stuff here that seems to get buried in the archives. Here are some of our most popular articles for your enjoyment:

How to record your Linux shell session

A lot of people are probably not aware of the command script. Script is a quick and easy way to record everything you do in a terminal session.  I use script to record sessions of me fixing a server, or troubleshooting Linux issues, and save it for future needs, or to pass on to others as training material.  Here is what the Linux man page says:

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

Using script to record your terminal session

It’s really quite simple to record your bash session.  All you need to do is type script -a filename to start recording your session:

laptop:~ foogazi# script -a session1_jun162010
Script started, output file is session1_jun162010
laptop:~ foogazi#

Now that the recording has started, everything you type, as well as everything that returns as output, will be saved into the filename you chose to output to.

Linux rename user command

I’ve gotten this question a whole bunch of times in the past.  You’ve got a Linux username that you want to rename, rather than recreate, so you don’t lose any significate data or permission settings.  How do you rename a Linux user?

Linux rename user command

To rename a Linux user (rename user name), you want to use the Linux command usermod.  From the man page:

The usermod command modifies the system account files to reflect the changes that are specified on the command line.

In short, here is the command to rename the Linux user:

usermod -d "/home/current_user-name" -m -l current_user_name new_user-name

And now an explanation of what each option means:

  • -d specifies the current users home directory.
  • -m specifies that you want to move the files from the current users home directory, to the new directory. You want to make sure you specify this, otherwise the users data will not transfer over to the new user account.
  • -l specifies the current user name, and the new user name you wish to change it to.

That’s it. Now you’ve renamed a Linux user.

10 People Who Should Use Linux

I’ve been thinking lately that there are actually certain types of people out there that should be using Linux instead of Windows.

Types of people who should be using Linux

Geeks and people who enjoy tinkering with computers

If you enjoy psychically building computers, chances are you’ll like tinkering with the operating system once your machine is running.  There is no better operating system to tinker with than Linux.

People who want easy security

Linux is much more secure than windows ‘out of the box’.  If you don’t want to bother with security, you should be using Linux.

People who want a unique look and feel

With Linux desktop environments, you can customize anything and everything you see on your screen with the right amount of knowledge.  You really can’t do that in Windows.

People who like the idea of open source software

If you support the principles of open source technology and wish to practice them to the fullest, you’ll definitely want to be running Linux.

Programmers who enjoy contributing to free open source software

This title should really be for all programmers.  If you’re a code nut, you should be running Linux.

People who only use the computer for basic needs and don’t want to be bothered by viruses and spyware.

I recently moved some of my family to a basic Ubuntu desktop.  The majority of their computer use consists of browsing, email, pictures, and instant messaging.  No reason for them to be running Windows if that is all they do.  Linux can not only do it faster, but better, and much more safely.

People who don’t want to have to reboot because there computer starts “running slow” due to adware, spyware, bloatware, etc.

This goes right along the lines with the last one.  Most non-techie computer users think that their computer is always “running so slow” because it’s ‘old’.  Chances are the computer is running slow from having so many adware applications running in the background.  I’ve yet to see a Linux install on any of my family machines, receive, much less slow down from adware, spyware, etc.

Do you use Linux? What type of person are you?

The Best Resources To Help You Learn MySQL

Chances are that if you’re a Linux and open source geek like most of the visitors to Foogazi are, you probably know a little bit about MySQL.  But if you’re a true geek, you want to learn all there is to know.  Databases power just about everything on the Internet these days, and MySQL is one of the most popular web databases languages there is.  Not only is it a great tool, but it’s a great language to know.

Here are some great tips to help you learn MySQL.

Visit MySQL Forums

As with anything you’re trying to learn, it’s always best to become an active member of the community.  Not only will you gather valuable information from people all around you, but you’re in a place with other likeminded people.  Being active in forums is key to learning the most you can.  MySQL forums contain a ton of great tips and useful information.

Here are a few MySQL forums for you to check out:

MySQL Mailing Lists

Just as important becoming an active member in MySQL forums is, it is also important to participate in mailing list discussions.  Some of my biggest “oh I get it” moments have been from emails posted to mailing lists.  Along with forums, mailing lists are a great place to throw out a question and get a quick answer.

Check out the only resource for MySQL Mailing Lists you need:

Planet MySQL

Planet MySQL is an aggregation of blogs and news from MySQL developers and users.  This is site is a must resource. RSS, web browser, whatever way you like to read, this should be one of your most frequented websites when trying to learn MySQL.

Check out planet mysql here:

Official MySQL Documentation

The MySQL website offers a ton of useful documentation and resources, so obviously this is going to be one place you’ll want to frequent. The MySQL reference manuals are a must have when learning MySQL.

Check out the MySQL documentation here:

MySQL Books

MySQL books are obviously one of the best resources to learn from.  I personally prefer a tangible book I can bring with me anywhere to learn from.

Here are some of my favorite MySQL books:

Of all the things I’ve listed as being the best resources to learn MySQL, I must say for me, the most important one is active participation with the community.  The more you ask questions, the more you learn.  The more you teach, the more you learn.  You can’t lose either way.

How do you prefer to learn? Have some more resources? Let us know in the comments!

How to configure static IP on Ubuntu

Do you use Ubuntu and wish to set a static IP for your machine?  It’s simple. Follow the steps below to find out how.

  • Right click the network manager icon at the top right of your desktop
  • Select Edit Connections
  • Select Wired
  • Click the EDIT button
  • Click the IPv4 settings tab
  • Select Manual from the method drop down list
  • Click the ADD button to add your static IP address
  • Add your DNS addresses in the DNS servers field. You can separate each DNS entry with a comma
  • Click OK.
  • Restart networking using this command: /etc/init.d/networking restart