Monthly Archives: October 2011

Bash Primer

As get to know Linux, you will inevitably use the command line (cli) at some point. Every distribution I have ever installed includes at least one terminal and at least one command interpreter. Most often the interpreter of choice is Bash. I am not going to do a history lesson on Bash other than to say it is an acronym meaning Bourne again shell. If you want to read the history follow the Wiki link above. Bash is a very versatile shell and thus has become widely popular amongst the FOSS community. I cannot think of a distribution that I have run that did not include it by default or at least make it available. Also I should point out that the terminal window itself is not Bash but rather a container for Bash to run in. This is why it might look different from one Linux distro to another.

There are two methods Bash can be run in; as an interactive shell you log into as a user and use the cli exclusively or as an interactive shell from within the graphical environment. Most of the time we are using the latter but if you work on a server, use ssh or are recovering a broken system, then you may find yourself at the login prompt of Bash. I hope that you are not facing that option until you at least have the basics down. System recovery is hard enough on its own let alone trying to remember commands.

To get started using Bash I recommend reading some blogs or websites devoted to Bash. You can also find plenty of books on Bash as well and since the core fundamentals have not changed drastically, even older books found in the used aisles or bargain bins are still very relevant to new users.

To illustrate a simple example you can open a terminal and type pwd. This is the output:

johnny@desert-bear ~ $ pwd
/home/johnny
johnny@desert-bear ~ $

The command pwd provides a method of telling you where you are in the file system. It can be helpful to verify this before running a rm command as root. Notice the prompt is a $ sign. This is the default prompt for an unprivileged user. As root the prompt will turn into the bang symbol # by default. Both of these values and many more can be customized. This is yet another reason that Bash is so popular is that it can be tailored to the user very easily, Any customizations values are stored in the file ~/.bashrc. This file is read upon opening a terminal window using Bash when in an interactive mode.

This versatility and the fact it is found in almost every distro is why you will often see help given in forums as cli commands. They are universal with very few exceptions. In the various distributions graphical environment, the instructions can vary from one distro to another pretty quick. That makes trouble shooting very difficult indeed.

So now we know what it is and the question now is how to use it? Single commands can be run one at a time and for most there will be a help file by typing -h, –help or mancommand‘ (no quotes and substitute command for the command you are needing to know more about). Commands can be connected together using the pipe symbol | and the command following the | symbol will be run after the first command. Commands can be run together as scripts and I’ll show an example later.

There are many websites and blogs devoted to Bash and the cli. I could fill an entire post with nothing but links there are so many. But this is one I have referred to over and over as I progress in my understanding of Bash; LinuxCommand.org. One more site that is sometimes a bit more advanced but gives practical uses of command is All commands | commandlinefu. The first of these is a basic primer moving into some more advanced techniques and the second allows others to post examples of commands they use for a variety of tasks.

Just today I ran across this example ot a Bash script that can be used for the discovery of large files. I needed this at work about six months ago. :) Notice the start of every Bash script is the same; #! /bin/bash . This #! symbol identifies the following commands are a script and /bin/bash is the working path for finding the commands. Open a text editor and paste the following code into it:

#!/bin/bash
# if nothing is passed to the script, show usage and exit
[[ -n "$1" ]] || { echo “Usage: findlarge [PATHNAME]“; exit 0 ; }
# simple using find, $1 is the first variable passed to the script
find $1 -type f -size +100000k -exec ls -lh {} ; | awk ‘{ print $9 “: ” $5 }’

Notice the two # symbols not followed by an !. These are used to comment on the script. To use this script type as root:

chmod a+x findlarge.sh

This sets the file as an executable and you do this in the same directory as the file or include the path. To run the script as root type:

./findlarge.sh / > largefiles.txt &

This will run the script and output to a text file in the current or working directory. The & symbol at the end tells Bash to run this in the background since this can take a while. Of course the variables of path and file size can be modified to suit your needs. Thanks goes out to Jarrod Goddard for sharing the script and Rackspace for sharing it with him.

Have a favorite example of your own or for more discussion, share in the comments.

 

 

 

How to Fix Apt Signatures

Occasionally I run across a great tip on the web somewhere and this is just one of those tips. I can’t remember where it came from so I can’t give credit at this time. This tip will fix bad signatures errors with apt and is assumed to be in a Gnome environment. Please share in the comments if any changes need to be applied for other variants like KDE or XFCE environments. If you see some lines like this after an apt-get update:

The following signatures were invalid: BADSIG….(followed by the lines with errors)

Run the following commands in a terminal window and this will fix them. ($ ans # are the prompt and not part of the commands)

$ sudo -s -H

$ enter password

# apt-get clean

# rm /var/lib/apt/lists/*

# rm /var/lib/apt/lists/partial/*

# apt-get clean

# apt-get update

After the update is finished be sure to close the root prompt # with exit. This should take care of any bad signatures in you apt sources list. If you continue to get errors on specific lines, you might want to examine those lines to ensure they are correct. In most Ubuntu variants you sill see a Software Sources option in the Administration menu. This gives you a graphical tool to edit the lists. In Debian and some Debian variants this might not be an option in the Administration Menu or if you prefer an editor, you can open a terminal and edit via sudo with your editor of choice this file: /etc/apt/sources.list . Another alternate method is to press alt+F2 and bring up the Run Application dialog and preface the choice of editor you want to use with gksu. This will allow you to run the application as the superuser and you can open the sources.list to edit.

One word of caution that should be said, backup the sources.list file before editing no matter which method you choose. Either copy it with a new name like sources.list.bak or do a save as sources.list.bak. It makes things much easier to return if you make a mistake.

FOSS Explained by Jeff Hoogland

FOSS is an acronym for Free Open Source Software. It is a concept Linux users use but not all of them understand. I read Jeff’s post on the subject and found it very clear to understand and with his permission I am linking to it here.

Jeff Hoogland is the author of the Thoughts on Technology blog and the creator of Bodhi Linux. A simple to use and very customizable Linux distro based on Ubuntu as a base. But this post is about FOSS and I encourage your to read Jeff’s post and explore the ideas behind it on your own. Without FOSS we probably would not be where we are in the Linux world today. Thank you Jeff for allowing me to link to your work.

How to Identify Your Wireless Chipset in Linux

Connecting via wireless has got to be in the top 10 of things people want for their computer. So many of us are opting for laptops, netbooks or tablet devices that wireless connectivity becomes a must have function. Fortunately wireless has never been easier with Linux than ever before. But there are still some cases where the driver doesn’t automatically load. I am writing this post for these situations.

First some quick background to setup the stage. Linux like other operating systems undergoes changes all the time. The main part of a Linux distribution is called the kernel. Windows and Mac OSX both have a kernel built in to their system too. You can think of it as the heart of the system. What separates Linux from OSX and Windows is the kernel undergoes development constantly and is released constantly on a pretty regular schedule. OSX and Windows develop theirs constantly too but will only release when they feel it is necessary or for new version releases. In the Linux community every distribution, Mint, Debian, Slackware, Ubuntu etc., will decide which version of the kernel they include. This can have an impact on what drivers are included since the kernel developers may decide to drop support or add support for drivers at their discretion. This part of the discussion will  be left out since it can be a topic for an entire book. Also no matter what distribution, you can change the kernel but again that becomes a new topic and is recommended only for the advanced users.

With this very basic idea in mind let’s add to it a bit more. In Linux the kernel contains modules and some of those will be drivers. Wireless drivers go into this category and if they are released as open source can be adopted into the kernel. Not every driver is released as open source or as free to use and subsequently may not appear in the kernel ever. That doesn’t mean there isn’t a driver available but it does mean you may have to find it. Identifying the chipset of your wireless controller will aid you in finding that driver you need and reduce the frustration of not connecting via wireless.

The command to find the chipset make and version ID is very simple. Open a terminal window and type at the prompt:

lspci (for card type devices or internal chips) some abbreviated output you will see is:

02:00.0 Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61)

This is the controller in my system and one of the lines from the command lspci. It clearly identifies the network controller coming from Intel and it is the 4965 chipset. The AG and AGN are the ratings for the card. Most common nowadays is the N rating but the G rating is still widely in use. For reference refer to the wireless protocol Wiki page where they are explained in detail.

and for USB devices type:

lsusb (mine is not USB but some sample output form the command follows);

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 05ca:1839 Ricoh Co., Ltd Visual Communication Camera VGP-VCC6 [R5U870]

You can see I have a camera and supprt for USB 1.1 and 2.0 but nothing else is connected via USB right now. If your wireless device were USB there would be a line similar to what’s above for the lspci command.

Now armed with the information of the chipset you can Google the chipset  ID and the Linux version you are using. I copy from the terminal window this part:

Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61) and add what version I’m using such as Mint LMDE and I will find links for the driver and or how to’s from people with the same issues. Undoubtedly someone else has the same problem and usually someone somewhere has solved it. As I write this I did Google the first part and it appears that in 2008 there were all sorts of problems with this driver. Probably fairly new back then since now it works pretty well. But the idea here is to follow what has worked before or what people are doing now to solve the problems. No since in re-inventing the wheel unless you are a developer, then by all means write the code and share it please.

Now it should be clear that to search you need to be online. That of course is the goal wireless but if not possible then cabled or the use of another computer somewhere. Libraries are great for free access to computers and you can take the laptop and test the suggestions on the spot.

I hope this post will help someone connect to wireless when they otherwise could not. I always say that the greatest thing about Linux is the community and it stretches around the entire world. There are so many people ready and willing to help. I do suggest also to read on your own a bit too. Learn the Linux basics and the language enough to understand or ask the right questions and provide the right information. Linux at its core is the same code (kernel) and forums will generally advise to use terminal commands because of this. Different distributions may have different controls and specific questions regarding those controls will be better served in the forums for that distribution.

I have held back on very specific solutions since there are so many. My goal with the post is to help new Linux users find answers. Wireless is one of the top issues and knowing the chipset is the key to making it work. Please feel free to add information I may have left out or correct me where needed in the comments. Questions are also welcome there too.

~Jraz

 

 

 

LMDE 201109 Gnome – Installed Impressions

I have now had time to run LMDE 201109 Gnome for a while and can now give some first impressions. Let’s break it down from installation to usage. The computer I am installing to is a second hand Sony VAIO VGN CR120E with a 500Gb hard drive and 2 GB of RAM and I installed the 64-bit version.

The installation was extremely quick as compared to before. After the usual questions on keyboard map, location and partitioning, the copying of files commenced. The installer continues to ask the questions for the main account as this happens. The installer is also very close to what one would see in Debian Squeeze which is not to say it was bad or anything but the less experienced at the partitioning sequence may have questions here. I’m afraid I didn’t time it exactly but I’m pretty certain it was under 20 minutes. I should also mention that this was a new drive but I had partitioned in advance. I used my favorite tool Parted Magic for this and I also backed up my /home to a blank partition. Now you know I didn’t use the Debian partitioning tool. I have however used it recently when creating a web server at work using Debian Squeeze. So I do have a feel for how it works and while not very intuitive, it does offer a lot of options. Since I backed up /home I did want some configuration files but for the most part I was after a clean install. All said and done I liked this installation experience.

Once installed the re-boot was very quick. I was on the Desktop in no time. This is something I really like considering I am using a computer in the slower CPU range for Dual Cores. As with any install the first order of business is to run an update. The Mint team has quite a nice tool built in for this process called Mint Update Manager. It looks like a small shield with a check mark and will change color when updates are available. More information about this tool can be found on the Linux Mint Blog here. All of the usual items in the Mint Desktop are there and I began the process of customizing to my tastes. The Mint dev team make this extremely easy with the Control Center being right on the main menu. Also on the main menu are Package Manager and Software Center. For newer users I think the inclusion of both on the same menu might be confusing. Package Manager being Synaptic and the Software Center is the Mint dev team’s very user friendly twist on what I think was started at Ubuntu. (Feel free to correct me if I’m wrong here.) The Mint team adds the Community functionality that gives more feedback on what you are installing and polished the tool’s functionality. For me I still like to use the command line tool Apt-Get but I do browse and install from here and Synaptic once in a while.

The default DVD installation will install quite a few of the most popular packages including Gedit, GIMP, gThumb, Firefox, Thunderbird, Giver, Pigdin, Xchat, Transmission, LibreOffice Suite, Banshee (Rythmbox is out), Brasero, Movie Player (Totem), VLC and the usual system tools located mainly in the Administration menu. For me and what I use this laptop for these selections are just fine. I have added a few more to the list like Remmina (VNC/RDP/SSH GUI), Cheese, Dropbox (was loaded but of course needed activation) and Virtual Box. It was Virtual Box I was most concerned about running properly since it was installed previously on a 32-bit installation. I did not know if my VDI disk would cooperate and run after restoring the backup. I am happy to say that after the usual update for the kernel changes, VB ran as expected. I like that a lot and now with the larger disk I can test more distributions for review here.

I am happy to say that there were not any surprises with the install. The Sony camera did not work but I applied the same fix as before and it ran just fine. Once again it installed itself as the default scanning device but I know how to fix that now. Most everything works except I have yet to get the SD card reader to work. But in all fairness I have not gotten it to work ever with any distro. So it may be non-functional or it could still be my lack of experience. My Kodak camera also did not auto-load. This was something it did do before on the 32-bit install of LMDE. I have not really invested any time in solving this yet but will report when I do. Lately I have been having an issue with the Intel wireless drivers or it is interference. My access point is upstairs and this card has never been what I would call stellar in performance but it was acceptable. I was starting to get loss of signal before the upgrade also so I’m not blaming this on LMDE. When I go upstairs the signal reaches 100% and is fine until I round a corner downstairs. I think the number of networks in the area has tripled and I need to increase signal strength downstairs.

I like this release quite a bit. If you followed the link on the updater, (a must read if not), you will see how Clem and his team are working hard on making updates smooth and painless for LMDE users. I like how I can get information on the update packs and I know it has been tested. This gives me a bit more peace of mind. For me LMDE will remain my OS of choice and I will continue to support this project when I can. I encourage anyone who uses Open Source and Free software on a regular basis to send a buck or two to the project or find other ways to help support the project. A small amount from many people will go a long way into helping the project stay alive.

 

~Jraz

 

Good-Bye kmandla

Motho ke motho ka botho has always been a very enjoyable blog to read. I will be missing the easy way in which he wrote. The blog was always written in an honest and simple manner that made me feel as if we were sitting across a table. I learned a few tricks there too and I hope it remains for a while longer as I have not yet perused every page.

Good-bye kmandla.

~Jraz