In the next couple lessons here at Nocturnal Slacker v1.0 we'll be discussing the Bourne Again Shell (BASH) in a bit more detail.
With that in mind, though, how 'bout we play around with a neat trick that will customize your BASH prompt whenever you go to the command line? Sound like fun? OK, here we go...
There's a file in your /home/<your_username> directory called .bashrc. You'll need to use the -a (all) option when listing (ls) that directory because the preceding . means it's a hidden file. So, let's see how joe would do this...
joe@mysystem:~$ ls -a .bashrc
There we go. So Joe now knows that he does have a .bashrc file in his /home directory. Now, let's say that Joe wants a cool BASH prompt like mine:
... that shows his username, his operating system, and his working directory. To do this, Joe is going to have to add a little data to his .bashrc file. He'll edit the file using the VIM command line editor. Remember that from a previous lesson? Here goes Joe...
joe@mysystem:~$ vim .bashrc
And poof! Up comes VIM with the .bashrc file ready to be edited. It's almost like magic, huh?
# custom prompt
PS1="u | archlinuxw:$ "
Joe is going to edit the .bashrc file to add the little bit in purple that you see above. What that will do is tell BASH to start up the command line with a prompt the shows Joe's usersname (u), his distribution (ArchLinux) separated by the | (pipe) character; and his working directory (w). After saving the file, this is what Joe's command line prompt will look like once he starts his next BASH session:
joe | archlinux~:$
Pretty neato, huh? Remember the ~ denotes the home directory. If Joe was to change directories (cd) to say /boot/grub, then his prompt would now change too to show the new working directory.
joe | archlinux~:$ cd /boot/grub
joe | archlinux/boot/grub:$
Again, pretty neato, huh? This way, Joe will always know what directory he's in at any given time. That will help prevent Joe from making any command line boo-boos.
That's it, guys and gals. Pretty simple stuff. See? You're not near as scared of that mean ol' command line as you used to be, huh? Use your imagination when customizing your prompt. I've seen some pretty cool ones out there. Here's the one my friend securitybreach and fellow Admin from Scot's Newsletter Forums - Bruno's All Things Linux uses:
‚ïî‚ïê comhack@Cerberus 02:27 PM
How's that for spiffy? For further reading see HERE and HERE.
Have a great weekend wherever you may be!
*This article appeared previously at my Nocturnal Slacker v1.0 site at WordPress.com
Let's continue now with our series of articles introducing new Linux Adventurers to the Linux shell, the command line, and command line editing.
Sometimes, there is a need to stuff a bunch of files into an archive and compress it. This is often the case when one wants to send a bunch of large files to someone else via email or serve them on a server. This practice came about in the old days of computing when disk space was at a premium. Even though disk space is now huge and cheap, bandwidth can still be tight in some cases, so archiving and compressing files is still an efficient way to store/transport them on your system or move them across the Internet.
Let's say our old pal Joe had three files that he wants to shove into an archive for storage on his own system. His files are text1.txt, joemama.text, and umeume.txt. Here's how Joe would archive these three files using the tar command. Tar stands for tape archive. It's been around since Noah ran Slackware on the Ark.
joe@mysystem:~$ tar -cvf joesstuff.tar text1.txt joemama.txt umeume.txt
Here's what the above command does... it takes the three files listed at the end of the command and stuffs them (-c = create, -v = verbose, -f = read/write to file) into an archived file called joesstuff.tar.
OK, so far? Alright then... what if Joe's three files were pretty big and he wants to send them to his buddies Bill, Mary, and Tom via his online server? Well, in that case Joe would want to compress his new archive using a compression application. Remember the old WinZip program in Windows? Well, Linux has some similar applications to squish files into smaller packages. Two that we'll talk about here are bzip2 and gzip.
So, Joe wants to compress his new archive file with bzip2 for starters. Here's how he does it:
joe@mysystem:~$ bzip2 -v joesstuff.tar
Now when Joe lists (ls) his contents of the directory he's working in, he will find that his original joesstuff.tar is now called joesstuff.tar.bz2. Cool, huh? The size will be smaller, too, because the archive has been compressed. Joe could now upload the file to his online server to share with his friends.
Another compression method that Joe could use is gzip. Here's how Joe would do that:
joe@mysystem:~$ gzip -v joesstuff.tar
If Joe used gzip to compress his archive, it would now be called joesstuff.tar.gz.
Now let's say that Mary downloaded the joesstuff.tar.bz2 to her computer and wanted to actually see/read the files it contained. She would have to decompress the archive first. She would do this from her command line with this command:
mary&larry@home:~$ bunzip2 joesstuff.tar.bz2
This command would "unzip" (decompress) the package leaving Mary with Joe's original archive --> joesstuff.tar. If Joe had put the archive on his server as a gzip compressed archive, Mary would use this command instead to unzip it:
mary&larry@home:~$ gunzip joesstuff.tar.gz
Either way, she'd still end up with Joe's original archive --> joesstuff.tar. Now though, she will need to unpack the archive in order to read the individual files. She can unpack the tar archive this way:
mary&larry@home:~$ tar -xvf joesstuff.tar
Now, when Mary lists (ls) the contents of her working directory, she would see the original joesstuff.tar and the three files that she just extracted (-x) from the archive.
That's it, folks. Those are the basics of archiving and compressing/decompressing files in Linux using the command line tools tar, bzip2, and gzip. Be sure to refer to the man pages for these commands to get some more good information. Remember how to get to the man pages? You can either read them online at places like linuxmanpages.com or you can access them right there on your own computer using the command line by entering:
you@your_computer:~$ man tar
TAR(1) BSD General Commands Manual TAR(1)
tar — The GNU version of the tar archiving utility
tar [-] A --catenate --concatenate | c --create | d --diff --compare |
--delete | r --append | t --list | --test-label | u --update | x
--extract --get [options] [pathname ...]
Tar stores and extracts files from a tape or disk archive.
The first argument to tar should be a function; either one of the letters
Acdrtux, or one of the long function names. A function letter need not
be prefixed with ``-'', and may be combined with other single-letter
options. A long function name must be prefixed with --...
I hope you've learned something from this lesson.
*This article originally appeared on my Nocturnal Slacker v1.0 site at WordPress.com
Mozilla posted a list of the worst offender addons for its Firefox browser. These are the addons that really slow down that FF start up.
Mozilla actually labels them as "slow performing addons". You can view the entire list by clicking HERE. See if any of your favorite extensions are on the list; a few of mine were, but they were down toward the bottom (minimal footprint) of the list.
You can't get something for nothing. That's just a universal truth. If you want your browser to do a boat load of extra tasks or jump through hoops like a circus animal, then you're going to have to feed it. Your browser eats RAM and CPU cycles. That's just the nature of the beast. Some are picky eaters; others are voracious monsters with bottomless pits for stomachs.
If you want your FF to be a lean mean browsing machine, you have to trim the fat a bit. Break the candy-coated addon habit. If you don't really need it or use it, why have it installed? There are some extensions that, were they not available, would probably deter me from using FF altogether. These are my must haves.
However, I also have some fluff in there. I have a smiley extension that's pretty cool. I also have one that adds "Go to top" and "Go to bottom" of my R-click context menu. Could I live without those? Sure, but I don't wanna', so I keep them. They both have very minimal footprints and seem to use next to nothing in resources within FF, so what the hell?
The beauty of FF for me is its potential for customization. You can truly make FF your own, should you care to put the effort into it. I could never do that with IE back in my Windows daze. I had to use addons for the Trident engine such as Crazy Browser and Avant to get IE to be what I wanted it to be. And even with those tools, there were limitations.
Have I mentioned lately that I LOVE Mozilla! If you have some spare change lying around, they could always use a buck or two to help defray the expenses of running that project. Mozilla creates so much for so many with so little. Help if you can.
Notes: Don't forget to click on links within my articles, folks. They often lead to informational sites to help you in some way; be they definitions of an uncommon word, or Wikipedia articles about certain items.
Disclaimer: I was at one time involved with the Avant Browser Support Team. I'm now retired from that excellent group. If you decide to give Avant Browser a try, tell 'em Eric sent ya'. ;)
*Originally published on my Nocturnal Slacker v1.0 blog at WordPress.com
Using Linux and old computers to do cool stuff. Vol. 3
In my last tutorial I went over how to use an old computer as a Linux media center for home entertainment. Now I am gonna explain how to use an old computer to store and serve your multimedia files to any network enabled device on your home network including that media center you just got setup. I am sure there are many of you facing the same problems as we speak. You have recently become aware that you can not only download music but movies and TV episodes as well. Only to find out that you can only watch them on the computer you downloaded them on, or even worse you have to copy them to a USB device and plug that into whatever you want to view it on. That works, but what happens when that device fills up? How long does it take to copy the media from one device to the next? As you can see this could all get to be frustrating and time-consuming and might even drive you to do something stupid. Like going to those crappy low def DVDs you get from Red Box. Just think, instead of that you could take an old computer that you probably have lying around, (or hell come grab one of the many lying around my house) and use it to solve all those issues in one fail sweep. Now please before anybody leaves comments saying, ‘a Buffalo NAS will do all that out of the box’, or ‘Windows Home Server does all that seamlessly’. Please remember, I am trying to give people a way to solve their problems for little or no money. Besides, what fun would that be to just throw money at it and not use our cunning Linux skills to solve things on the cheap?
Alright first things first, I don’t want you wasting a bunch of time trying to set this up on a computer that is too old and slow to do the job we need it to do. That being said I would suggest at least a Multi-core processor with cores that are at least 2Ghz. The reason is you need at least two cores at 1.8Ghz or one core at 3.2Ghz to process HD video. We don’t want our playback choppy! Cram as much compatible RAM as you can find in there and let’s get crackin! The operating system we are going to use on this old computer is Freenas. It is one of the greatest operating systems ever created. I could go on for hours about how awesome it is but let’s just put it this way. If you have never used it you will fall in love with it for sure. Go on over to HERE and get the latest ‘stable’ build in .iso format, 32bit should be fine since the machine is old anyway. If you are a Linux user you probably know how to burn an iso to a disk. If you are a windows user HERE are some dumbed down videos that might help.
Now that we have our freenas disk and our old computer we are ready to install. Now here is the one thing I would suggest you spend some money on. If you are planning on putting movies on this thing like me then the hard drive that is probably in that old thing will not cut it. Plus the way freenas works it’s much easier to install the OS to a different disk then the one where your shared data is. It’s actually best to put the OS on a cheap flash drive if you have one or if the drive that was in the old computer died, but you are still gonna need a big one for your data. Fortunately hard drives can be had on the cheep now days so I suggest you get at least a 1TB drive that is 7200 rpm or better. HERE is some info that might help with getting that thing installed. Now, plug-in a monitor and keyboard for now and put the freenas CD in the optical drive. You might have to get into the bios to set the computer to boot from CD before hard disk. HERE is some help on that. Now it is gonna boot up and give you some number options. I think number 9 should be ‘install/upgrade’ so choose that one. Now it’s gonna give you some options on what type of install you want. We need to choose ‘FULL’ install with ‘DATA’ and ‘SWAP’. The reason we don’t want embedded is because we need a lager than default data partition because we will be loading additional packages that would fill up the partition if we left it the default size. One of the key things we will be installing is the PS3 Media Server software. It does a great job of streaming movies to the PS3 or Xbox 360. So during the next couple steps it will ask you what size you want your data partition to be. The default is 380 and we need at least 500, but was are talking about megabytes here not gigabytes so I usually give it over 1000 just encase I decide to add more software later.
Alright once that finishes up it will want to reboot, make sure you remove the installation media. Now once you get it booted up one of the options there is to set the IP address of you LAN adapter. Just give it something that isn’t being used on your local network there. Or better yet you could leave set on automatic DHCP and make a reservation for it in the DHCP scope on your router. That way if you ever have to replace your router with one with a different internal subnet you can still find your NAS without too much effort by scanning your subnet for it. If that sounds confusing don’t waste time on it as long as you can access the IP address it has we are good. Alright once you have that done you shouldn’t need the monitor or keyboard any more. We can do the rest of what we need via the web interface or ssh. So head over to your normal computer or laptop and put the IP address of that thing in your browser. The default username is ‘admin’ and the default password is ‘freenas’. Now once you are in you will need to configure that big huge hard drive you bought and setup some shares. Some good tutorials on that can be found HERE and HERE. Once you get that done you just need to load the PS3 Media Server packages. A good how to on that can be found HERE. That’s really all you need. Freenas has the Transmission bittorrent client-server installed already. All you need to do is go into services and enable the bittorrent service and you can find torrents on the internet and let your NAS download them for you and automatically put them in the folder that your PS3 media server software makes available to the network. Now you can have all your media on one box and have it available to every device in your house. Enjoy!
Steven Rosenberg just wrote at insidesocal:
Eben Moglen of the Software Freedom Law Center talks about how there should be alternatives to ceding our rights and freedoms for "free" services -- and how free, open-source software can attack this problem with cheap hardware in the new Freedom Box project. I'm still absorbing all of this and turning it over in my head, and I'll have more to say when that process is further along...
In a related post about free as in freedom webmail, Rosenberg also wrote:
"[using self hosted or ISP-provided webmail] I can tap into the relative ubiquity of web-based e-mail services such as Gmail, Yahoo Mail, AOL Mail, etc., that you can get from any web browser yet not be subjected to the advertising, spying and general lack of control inherent in those "free" (but not free) services... Can you tell I'm falling under the influence of Eben Moglen?"
Since I already went through the same process last year and have already thought a lot about it, since it is (I hope) useful for everybody, and since I do want as much feedback and general discussion as possible around this, I repost here the comment I wrote to Rosenberg's first post:
reading in this and your other post (the one about Roundcube as a webmail interface) that you are "falling under the influence of E. Moglen", that is thinking around free as in freedom email services, I think that you may be interested in what I wrote about "Virtual Personal Email Servers". I look forward to hear your opinion about this.
Oh, and I too heard Moglen speaking about the Freedom Box at the Open World Forum last year. Here is my summary of what he said about it in that occasion. Again, feedback is welcome
Previously here, while discussing the Linux shell, we briefly touched upon the need to have a command line editor that you're comfortable using.
While there are quite a few very good editors out there (EMACS, Nano, etc.), vi/vim are my favorites. Some would say that I'm into self-flagellation to like vi/vim, but I think it's probably due to the fact that they were my first exposure to command line editors. I've only recently found and used Nano (in Arch Linux). It's pretty cool, but vim is my baby when it comes to editing on the command line.
Billions of electrons have been spent discussing the merits of one editor over another. We're not going there today, though. I've become kinder to electrons in my old age. Instead, I'm going to show you the very basics you need to create or edit an existing text file from the command line using vim (vi - improved). If you learn just these few simple keystrokes, you should be able to edit a file should you ever need to.
OK, let's start with how to start vim in the command line. Well, that's pretty simple. Here are a couple ways. You can just type the executable for vim into your command line:
If you do it this way, the command will tell vim that a not-too-experienced user just called up the application and it will come up assuming you need some help:
That is the vim intro page. Now, a bit more experienced user will never see that page because he/she knows how to start vim in another way. Let's say that we want to create a text file called testing and open it in vim ready-to-edit. This is how user Joe would do that:
joe@mysystem:~$ vim testing
In this example, a wiser Joe knows that this command will open the vim editor application with file testing just sitting there waiting to be edited, or created, in this case.
You can see that Joe has typed in a bit of text already. He must have done that when I got up to get my coffee refilled. Sneaky guy, ain't he? Anyway, You'll also notice at the bottom left of the editor window is the word INSERT. What this means is that vim is in one of its Input modes. The other mode is the Command mode, but we'll get to that in just a sec.
To get into the Input mode, you would press the key i on your keyboard. This would put vim into the Insert mode right where the cursor is. If you hit the a key instead to get into the Input mode, vim will advance the cursor one spot and then enter Input mode. You can also get into the Input mode on most keyboards by using the Insert key, which is usually located just above the Delete key in that block of six keys just above your navigation (arrow) keys.
Oh, and speaking of those arrow keys... those are used to navigate within the file while using vim. You can also use the h, j, k, and l keys to move left, down, up, right, respectively. When you're done moving and typing, you can leave the Input mode and enter the Command mode by using the ESC key in the upper left of your keyboard. Once in Command mode, you can do another very important chore that everyone needs to know how to do when editing text files... save your work. To save the testing file, just type this while in Command mode:
This command tells vim to write the file (save it) and quit vim. Here's what that looks like:
Here's another neat trick, too. Some folks like to see the line numbers displayed while editing a file. Actually, often it's a necessity when editing code files. To display the line numbers in vim just enter this command while in the Command mode:
To turn the numbering off use:
Here's a look at that in the vim editor:
You see? There's nothing really to be afraid of while using vim. It's nowhere as near as scary as folks would have you believe, huh? When you get a little practice with it and start learning some more of its tricks and shortcuts, it's really a cool little editor. Oh, and don't forget to type:
while in Command mode. It will bring up all kinds of useful vim info. For further reading, check out vim's website and the man page. Of course, you can access the man page from your own computer using the command line:
joe@mysystem:~$ man vim
I hope this lesson on the vim editor has been helpful to you. Don't let it scare you. Just open up your terminal in Ubuntu or Mint or whatever your favorite GNU/LINUX distro is and create and play around with a practice file using vim. It's a great way to learn without risking breaking something.
Stay tuned... next up we're going to learn a little bit about archiving, compressing, and decompressing files using tar, gzip, and bzip2. Should be fun.
*This article was originally posted on my Nocturnal Slacker v1.0 blog at WordPress.com
Gnu Free Call is a Free Software, server-less alternative to Skype. Here is an introduction to Gnu Free Call written specifically to help non-geeks to understand why such a project is important for everybody, both in normal life and when disasters strike. Includes explanations from Haakon Eriksen, the project coordinator: Gnu Free Call, the freedom to call out when you really need to.
This is not one my common linux blogs, however it is one that I feet people should be aware of.
We have heard of the disasters in Japan. The 9.0 earthquake and the Tsunami that flooded Japan's nuclear reactors causing massive blackouts and raising the radiation alert is of great awareness. Japan as of now is still struggling to recover from these disasters and it may take months before this situation is under control, if it can.
What is more critical, is Japan's inability to continue to produce computer chips for Apple products, computers and cars. Because Japan is the leader in semiconductor chip production, the world wide supply of computer chips has slowed down dramatically. Only a few factories are operational but at limited production capability. There is no telling when the others will be fully operational. Some of the factories has been damaged so bad that they may never come back online.
Also facilities that produce hydrogen peroxide that allows the product of silicon wafers to build computer chips have suffered greatly. Any new computer devices in current production has stopped which will mean, we will not see much of any new technology products for a while.
What really concerns me, is what indication these disasters have? We have been told the world will end in 2012 according to Nostradamus. I don't believe in people claiming to predict the end of any race, yet I'm starting to wonder if these things are part of a serious pattern. Perhaps we lost our way and we need a wake-up call. If we are to survive for several more generations, maybe its time to re-evaluate how we view human priority.
One country should not be solely in-charge of an essential production material. All countries should at least have distributed assistance in something that has world demand. We all use it, we all should help build it.
Please send your prayers out to the victims in Japan.
She sells seashells by the seashore. Well, yes... that may be true, but that's not the type of shell we're going to talk about here today.
I'm going to talk a bit about the Linux shell. What is the Linux shell? What does it do? How can I interact with it on my GNU/Linux operating system? Those are all good questions. While today's most popular distributions of GNU/Linux are morphing into operating systems that are more and more graphic user interface oriented, the real power of Linux still resides in the command line.
When you boot up your Ubuntu or Mandriva GNU/Linux operating systems, most of you see a graphical login screen. Others, like myself, might see a non-graphic command line login. Both do basically the same thing. They log the user into the Linux shell so that he may begin to utilize his system's potential to perform tasks. That's what we do with our computers, regardless of what the tasks happen to be... emailing pics to auntie Myrtle or hacking cloud and cluster security systems.
The Linux shell is the interface between you in that seat in front of your monitor and the operating system that controls the hardware in that box under the desk that does the actual stuff you want done. There are numerous shells in Linux; the most commonly used one is called BASH - Bourne Again Shell. You're in the shell anytime you're logged into your GNU/Linux operating system; whether you're interacting with it graphically or from the command line.
Graphic User Interfaces or GUIs are just "front ends" to applications that are running in the shell. I'll be talking mostly about the non-graphical command line interface here today, though. You can access your command line interface from within your GUI by using the graphic front end application for the command line provided by your desktop environment. For example, in Gnome, you could use Gnome Terminal; or in KDE, you could use Konsole. Either way, these are both just graphical front ends for the BASH shell command line.
When you first login, you'll get what's known as a prompt. It is just a blank line waiting for your input (commands). It'll look something like this:
The first part, "joe", is just the user's login name. "@mysystem" is the name of the computer the user is logged into. The "~" character tells us that user Joe is working from his home directory. The "$" character is the standard character denoting a non-root, regular user.
Let's say Joe wants to list all the files in his home directory. All he has to do is type:
This command, known as "list", tells the shell that user Joe wants to see a list of all the contents of his home directory. The shell immediately responds after Joe hits the Return (Enter) key on his keyboard with this output:
Desktop joe_archives joe_common joe_private
Dropbox joe_backups joe_downloads
It looks like Joe has five regular directories, a Dropbox directory, and the directory that contains his desktop icons. In reality, there are more directories and files in Joe's home directory, but they're what are known as "hidden" files. Their names are usually preceded by a .(period) to make them hidden. If joe wants to see all his directories and files he can list them this way:
joe@mysystem:~$ ls -a
The "-a" option means all. The list command will list all items in a directory when using the -a option. Joe's list now looks something like this:
.dropbox .macromedia .thunderbird
.ICEauthority .esd_auth .moz_icons .viminfo
.PySolFC .fontconfig .mozilla .wicd
.Xauthority .gconf .mozilla_3.x .xchat2
The above directories are hidden by the preceding .(period), as mentioned above.
Let's say Joe want's to create a grocery list for his afternoon shopping chores. He can do this via the shell and command line also by using a command line editor such as vim. He would first do this by bring up the vim application in the command line interface:
joe@mysystem:~$ vim groceries
This command would initiate the vim application using a new file called "groceries". Vim or Vi-Improved, as it's known, is a non-graphical text editing application. It would look something like this to Joe:
--INSERT-- 10,1 All
Once Joe had finished typing out his grocery list, he would save it using the vim command :wq, which would also close the vim application and bring Joe back to the command line prompt. He could also print his list from the command line like this:
joe@mysystem:~$ lpr groceries
The lpr command would tell the shell that Joe wants to output the contents of the groceries file to the printer. The printer would receive the data and the command to print from the computer's hardware and begin printing Joe's grocery list.
All of this we've talked about today doesn't even scratch the surface of the power at your finger tips when using the Linux shell. Your first step should be to read the Linux manual page for the BASH shell. There is some very useful information in that document. Stay tuned here... I'll come up with some other lessons in the future. Remember what I always say...
Learn something. It won't hurt you none. I promise.
*A republish from my Nocturnal Slacker @ Lockergnome blog
I've been reading some GNOME 3 design documents recently and while I'm trying to build some kind of analysis out of it, it's the end of the semester and I've put the project on hold. In the meantime, please enjoy these two utilities! [Edited with smaller images]
It's not quite a program, but it's very useful if you spend most of your days in front of a computer screen. It's the Terminus font. It is, according to the project page, "designed for long (8+ hours per day) work with computers". I believe them. It is now my favorite monospace font and I use it wherever I need monospace fonts: consoles, code editors... name it! Here are a couple of screenshots:
Have you ever worked with a HP calculator? If so, then you are probably familiar the Reverse Polish notation. It is a way of entering mathematical equations that, in most cases, makes parentheses obsolete (making equations faster to input with less keystrokes). It is a bit weird to work with in the beginning, but when you get used to it, there's no going back. I've been looking for a RPN-capable calculator for some time and I found galculator. It's simple and fast - probably not as comprehensive as your 200$ graphic calculator, but it sure gets the job done! Here's a screenshot:
I hope you enjoy these two tools - they may not be as "life-changing" as desktop environments, but they sure make it easier!