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:

Popularity: 1% [?]

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.

Popularity: 16% [?]

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.

Popularity: 4% [?]

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?

Popularity: 3% [?]

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!

Popularity: 5% [?]

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

Popularity: 1% [?]

How to reset your Linux Password

If you’ve ever forgotten your Linux password, chances are you’ve needed to either restore your Linux installation.  Hopefully this solution will save you from having to reinstall Linux in the event that you forget your password.

Reset your Linux password using Grub:

When your machine boots into Grub, you’ll want to press “e” to edit the grub boot linux.

After pressing “e”, navigate to the kernel line and add the word “single” to the end of the long string.

Press “b” to boot into single user mode.

You should then be taken directly to a root user shell, where you can then type passwd, and change your root password.

After you’ve reset your root password, type reboot at the shell to leave single user mode.

Popularity: 1% [?]

At the office I use both my Macbook Pro running OSX 10.6.3 and a Windows XP box side by side, each with separate monitors.  In the beginning I would use my Mac as my primary desktop, and VNC into my XP machine to avoid using two keyboards and mice.  This configuration worked well, but was a pain to have to open VNC to control my Windows XP desktop.  Then I discovered synergy+ which allowed me to use only one keyboard and mouse, and control both screens as if they were one machine, moving the mouse freely to each one as if I had dual monitors. From the synergy+ website:

Synergy+ (synergy-plus) lets you easily share a single mouse and keyboard between multiple computers with different operating systems, without special hardware. All you need is a LAN connection. It’s intended for users with multiple computers, where each system uses its own display. It’s a little like having a 2nd or a 3rd desktop…

How to configure synergy on Mac OSX

I’m running the synergy+ server on Mac OSX 10.6.3, since that is my primary machine.

First, download synergy+ for the Mac, then download synergy+ again on the Windows machine.

Once installed on both machines, you will need to create a synergy configuration file on the server (Mac).  Here is what mine looks like:

section: screens
macbook-pro.local:
windows-workstation:
alt = super
super = alt
end
section: links
macbook-pro.local:
right = windows-workstation
windows-workstation:
left = macbook-pro.local
end

The config file is pretty straight forward. The first section, called screens, is where you list the hostnames (computer names) for screen1 and screen2, in this case, my macbook-pro is screen1, and my windows workstation is screen2.  The alt=super and super=alt lines are two tricks I found that will allow the Windows key on my keyboard to function properly.  In the next section, called links, you define the layout of the two screens. In my config, my macbook screen is on the left, and my windows machine is on the right, as you can see defined in the config above.

Save the config file as synergy.conf and place it anywhere you’d like.

Now that you have the synergy server configured, you need to start it.  Open a terminal, and run the following command:

synergys -f --config /path/to/synergy.conf

The -f option will run the synergy server in the foreground, in case you need to debug anything.

How to connect to your new Mac OSX synergy server from Windows

Now that you have the synergy server running on your mac, you need to connect to it via the synergy application in Windows.

If you didn’t do it in the earlier step, download synergy+ for Windows and install it.

Next, open Synergy+ and select “Use another computer’s shared keyboard and mouse (client)” and type in the IP or hostname of your mac and click Start.

If all steps were followed correctly, you should now be sharing the keyboard and mouse, and should be able to move your mouse to each screen as if you had a dual monitor setup.

Start synergy server when a user logs in

The last thing you’ll want to do is to make sure synergy starts every time you log in. To do this, you’ll want to create a LoginHook

First, launch a terminal window and become root:

sudo su -

Create a folder to store your LoginHook script:

mkdir -p /Library/LoginWindow

In this folder, create a file called LoginHook.sh that contains the following text:

#!/bin/sh
prog=(/usr/local/bin/synergys --config /path/to/synergy.conf)

### Stop any currently running Synergy client
killall ${prog[0]##*/}

### Start the new client
exec "${prog[@]}"

Make sure the script is executable:

chmod 755 LoginHook.sh

Now create the actual login hook that will call the script we just created:
defaults write com.apple.loginwindow LoginHook /Library/LoginWindow/LoginHook.sh

That’s it! Next time you log into your mac, the synergy server will start, and your windows machine should connect.

Popularity: 7% [?]

There was an interesting post on Ask Slashdot discussing the ethics of releasing non-malicious Linux malware to simply prove a point to all of the people who rant and rave about Linux being so secure.  A developer by the name of buchner.johannes

buchner.johannes writes:

“I was fed up with the general consensus that Linux is oh-so-secure and has no malware. After a week of work, I finished a package of malware for Unix/Linux. Its whole purpose is to help white-hat hackers point out that a Linux system can be turned into a botnet client by simply downloading BOINC and attaching it to a user account to help scientific projects. The malware does not exploit any security holes, only loose security configurations and mindless execution of unverified downloads. I tested it to be injected by a PHP script (even circumventing safe mode), so that the Web server runs it; I even got a proxy server that injects it into shell scripts and makefiles in tarballs on the fly, and adds onto Windows executables for execution in Wine. If executed by the user, the malware can persist itself in cron, bashrc and other files. The aim of the exercise was to provide a payload so security people can ‘pwn’ systems to show security holes, without doing harm (such as deleting files or disrupting normal operation). But now I am unsure of whether it is ethically OK to release this toolkit, which, by ripping out the BOINC payload and putting in something really evil, could be turned into proper Linux malware. On the one hand, the way it persists itself in autostart is really nasty, and that is not really a security hole that can be fixed. On the other hand, such a script can be written by anyone else too, and it would be useful to show people why you need SELinux on a server, and why verifying the source of downloads (checksums through trusted channels) is necessary. Technically, it is a nice piece, but should I release it? I don’t want to turn the Linux desktop into Windows, hence I’m slightly leaning towards not releasing it. What does your ethics say about releasing such grayware?”

This is a great thing for the community at large to see that Linux can be exploited with malware just like it’s rival operating systems.  However, I share the same concerns the developer does.  This indeed could result in a black-hat user injecting something malicious into the code and actually turning the example into real evil malware. I’m on the fence though, maybe this is what Linux users need to prove that we aren’t like typical Windows users who click any random link and download any random software from any random untrusted third-party site.  A user who goes by the name of silentcoder wrote: “Linux users (hardly ever) download and install software from the internet. We download and install packages from repositories. The average user simply cannot tell the difference between a useful piece of freeware and a bugridden-malware-spreading piece of add-ware.”

Paranoia aside, this definitely proves that Linux is just as susceptible to malware and viruses as any other operating system.  But, as I’ve always said, viruses and malware are usually a result of user error, no matter the operating system.

What do you all think, should this type of code be released as proof of concept even if it’s risking malicious manipulation?  Should we all just start using SELinux and be done with it?

Popularity: 5% [?]

Must have Linux books for Christmas

The gift giving season is right around the corner and if you have any geeky relatives or friends, then this list of Linux books to buy for Christmas is a good reference.  Click each image to find out more.

Linux Bible 2010 Edition: Boot Up to Ubuntu, Fedora, KNOPPIX, Debian, openSUSE, and 13 Other Distributions

Linux Administration: A Beginner’s Guide, Fifth Edition

Practical Guide to Linux Commands, Editors, and Shell Programming

How Linux Works: What Every Superuser Should Know

Linux Command Line and Shell Scripting Bible

Linux System Administration

Beginning the Linux Command Line

Pro Linux System Administration

Linux Security Cookbook

Hardening Linux

Popularity: 5% [?]