MOVING!!!

Hey there, after several years of playing with Blogger and trying to get thing sorted out how I wanted, I finally decided to host my own domain so I could manage things easier. So this blog (which, admittedly, hasn't been updated much) is getting moved to my all-new site: DavisTobias.com/Linux. Also, to make it easier to transfer RSS feeds, this is the link to the new RSS feed. I'll leave this site and it's posts up, so I don't contribute to dead links on the internet, but I'm shutting off comments and won't post any more here.

November 28, 2009

Showing the list of installed packages

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

I haven't had much time to play around in Linux for a while, what with school, but I recently got a new desktop computer and installed Windows 7 (the horror!) and am now doing some development using VirtualBox, the computer virtualization software. My desktop has all the power I will need for some time, but I would like a light-weight version of Ubuntu (my favored flavor) to install on my newly acquired Asus EEE PC 900A.

Later on I will post some of my findings, but for now I just wanted to point out the helpful command which will list all the packages currently installed: dpkg --get-selection

A word on the commands:
dpkg This is the debian package manager
--get-selection This is the command to list the installed packages

Another trick:
dpkg -L package This will list all the files associated with the package
dpkg --get-selection | grep package The "grep" command will search through the lengthy list and display anything with "package" in it's name.

This handy command will list every package currently installed, which is super helpful once you've generated your custom blend of software but haven't written down what you installed. Which I obviously did. Many times.

Of course, this list turns out to be a bit lengthy and unwieldy, especially since it outputs the list right in the terminal. Thankfully you can make the list go into a text file by using the command: dpkg --get-selection > filename.txt

The carat symbol, >, will take whatever would have gone to the terminal display, and output it to a file, "filename.txt".

June 16, 2009

IceWM Manager?

I have been configuring IceWM to suit my needs, but what would be really handy is a graphic interface to work with. There are two existing ones, but neither are still being developed. I have been considering either making a new graphic interface, modifying the needed parts from the existing, or making an updated version of one of the existing versions.

Alternately, I wonder if I could develop a web-based version, so that you can go to the web-site, interactively change theme colors/etc., and when done grab the text files and so on. The part I am unsure of is how to generate the text and image files correctly, but I could probably do this.

Anyways, any thoughts on the matter would be helpful.

June 13, 2009

Adding Samba support to Thunar

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

Thunar does not natively support Samba, which is theLinux port of the Microsoft network folder/file sharing protocol, but support can be hacked in using the following method.

Note that I stole these instructions mostly from here, but I modified them for my conditions, which were: Minimal installation of Ubuntu, plus IceWM.

First make sure you have the correct software, Samba:
sudo aptitude install samba

Now you need FuseSMB, which is the Linux "File System in User SpacE" for Samba. This is found in the Universe repositories, to enable them, run the following (two) commands, borrowed from the official wikisite:
sudo su -c '\ndeb http://us.archive.ubuntu.com/ubuntu/ jaunty universe >> /etc/apt sources.list'
sudo su -c 'echo \ndeb-src http://us.archive.ubuntu.com/ubuntu/ jaunty universe >> /etc/apt/sources.list'
Now that the Universe repository is enabled, installing fusesmb is easy:
sudo aptitude install fusesmb

Now you need to add the fuse module to be loaded when the computer starts. Do this by adding the word fuse to the file /etc/modules, either using a text editor or with this command:
sudo su -c '\nfuse\n >> /etc/modules'

At this point you will need to do a full reboot to your computer so the fuse module loads correctly. Make sure to bookmark this page so you can finish the instructions when you come back!

After rebooting, you need to make a folder where Samba can mount: I made mine /media/network for simplicity. From the command line: sudo mkdir /media/network

Now you will need to make sure the folder has the correct permissions. To do this, open Thunar using sudo thunar which will give you administrator rights, so be careful not to do anything other than this. Right click on your folder /media/network and go to properties. You need to set Group "Access" and "Others" to "Read & Write". Finally, run this command: sudo chown :fuse /media/network

You also need to add the fusesmb code to the folder /etc/init.d which is done by making a script and putting it in that folder. The script is a really simple one, just make a text file on your desktop, name it something descriptive like networkmount, and put this inside:
#!/bin/bash
# This mounts the Samba service to the folder /media/network
fusesmb /media/network

Now make the script executable with this command:
chmod +x networkmount where networkmount is the name of the file
Finally, copy the file into the correct folder, you will need to be an admin, so try this command:
mv networkmount /etc/init.d/networkmount

Now you need to make Samba mount to the correct folder whenever you log in. What I did is add the correct command to the file /home/tobias/.xinitrc , which will run the command when I start X, but you may have a different way. How my .xinitrc file looks now (make sure the exec icewm-session & is last):
fusesmb /media/network &
exec icewm-session &

Now you will need to do a full reboot once more.

That's it! If you open Thunar and navigate to /media/network it will show you the available Samba networks. Note, however, that the response time is a bit slow, I thought I had done it wrong at first, but I was just impatient. If it won't load after a while, try logging out and logging back in, or resetting, to see if it will reinstate correctly.

For added navigations, if you are using the "Shortcuts" Side Pane in Thunar (control + b) you can navigate to /media and drag the network folder to the side pane for quick access! Alternately, make a link to it and put the link wherever it's handy.

test

I feel a bit foolish: ALSA mixer

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

After installing the Ubuntu minimal core plus IceWM, as detailed previously, I could not get sound to work at all. My usual test for sound is installing VLC, which automatically installs a pretty good set of plug-ins, then adding support for DVD, WMA, and some other proprietary encodings:

This will install VLC:
sudo aptitude install vlc

This bit of shell script will enable the correct repositories, add the GPG key, and then install the required plug-ins for DVD access, as well as DivX, WMV, WMA, and a handful of other popular proprietary plug-ins. The following code was gathered in part from an old version laying around here. Beware of layout changing the font: their are five (5) lines of code to copy+paste here.
sudo su -c 'echo \ndeb http://packages.medibuntu.org/ jaunty free non-free >> /etc/apt/sources.list'
sudo su -c 'echo \ndeb-src http://packages.medibuntu.org/ jaunty free non-free >> /etc/apt/sources.list'
wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add -
sudo aptitude update
sudo aptitude install libdvdcss2 w32codecs gstreamer0.10-pitfdll libxinel-ffmpeg libdvdread4
So after I installed all that software, I opened VLC and tried to open a music file. Unfortunately for this article, I didn't write down what VLC said exactly, but it was essentially saying VLC couldn't find an actual audio device. Using the command ls /dev/a* I was able to see that an audio driver did exist: /dev/audio

After much poking around in the program aptitude, the Debian software installation program, I realized I did not have the ALSA (Advanced Linux Sound Architecture) software installed, so I installed a few of them. I know for sure that I installed more than I needed, and I can't figure out which ones I ended up installing that made it work, but my guess is installing alsa-firmware will install the rest of everything needed.

After that, when I played a tune in VLC it would appear to play correctly, but I could get no sound from the speaker. Well, after stumbling around a bit, looking for more ALSA files I could install, I noticed I had installed alsamixergui, started it, and realized everything was muted! Well, talk about embarrassing, I un-muted everything and realized I had never tried the volume buttons! I thought the volume would be automatically set to some low volume as a default, but it is installed with the sound muted.

Hope you can learn something from my mistakes!

June 11, 2009

Reinstalling Ubuntu, the core set

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

Well, I reinstalled Ubuntu Gnome twice, and then being unhappy with it (which I really have been from the start) I reinstalled the Ubuntu core and then installed IceWM: Ice Window Manager is a very light weight manager, with very limited graphical eye candy. So far I am really enjoying it: The menu, panel, and most everything else are flat text files, so they are easy to manipulate.

After I installed the base core of Ubuntu, I did this:
sudo aptitude install xorg icewm menu firefox

If you aren't familiar with the Debian install method, it's real easy:
sudo To install a program, you need root access.
aptitude This is the program which installs things. You can just run sudo aptitude and it will give you a command line interface.
install This tells the program, aptitude, to install the following list of programs.
xorg icewm menu firefox These are the programs I installed, although I am not sure if I needed the menu, I was following someone else's instructions.

Now I had a window manager and Firefox, so I could browse around online to figure out how to do other stuff. When you boot up you will end up at a command line, no graphics, and you will need to put in your login name and password. To get the window manager to start, type in: startx

The core Ubuntu, plus IceWM, didn't install a file manager (in Windows, that is just the normal file browser) so i had to browse around online to find one. I found this news post which helped, but the comments below really helped me decide. I didn't mind the Ubuntu default of Nautilus, but it was a pretty heavyweight, and I was looking for something really light.

What I decided on were two things: Thunar and Midnight Commander. Thunar is a graphically appealing, yet lightweight graphical file manager, and comes pre-installed on Xfce and on Xubuntu, which is Ubuntu using Xfce4. In this link you can find some screenshots of it, although in my installation I have not configured a MIME applied icon set.

Midnight Commander is one that I can especially appreciate: It is a console file manager, much like the good ol' DOS based Norton Commander. Two panes of beautiful text goodness, oh yeah! I managed to find a screenshot of it:

Sorry it's not a very good picture, but I think you can get the idea of it. The comments at this previously linked post give some good ideas as to the power of this program. Also, if you open this within a windows manager, you can interact with it using the mouse as well, although it is designed to use the keyboard of course. I had some real trouble figuring out how to install Midnight Commander, so I will present the way I used:

First, you need to enable the Universe repositories. You can do this using some graphical thing, or you can edit the text file. The following lines need to be added to the file "sources.list", which is found at /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe

You will need to change the word "jaunty" to whatever version of ubuntu you are using. One way to quickly append to a text file, from the command line, is this:
echo new text >> file.txt

This takes the "new text" and puts it at the end of "file.txt", that's what the >> means. To add the two lines above to the sources list, type these two commands:
sudo su -c 'echo deb http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe >> /etc/apt/sources.list'"
sudo su -c 'echo deb-src http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe >> /etc/apt/sources.list'"

Now you have added the Universe repository, you need to update the list of programs:
sudo aptitude update

And finally, install Midnight Commander:
sudo aptitude install mc

To start Midnight Commander, just type in:
mc

April 19, 2009

Recursively deleting things

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

I wanted to delete the incessant "Thumbs.db" that Windows leaves everywhere, and found three possible solutions:
rm `find /path -name '*.tmp'`
find /path -name \*.tmp | xargs rm
find /path -name "*.tmp" -exec rm {} \;

The first two probably work when there are no spaces in the folder names. The last one works even when there are spaces. I will explain all three.

First: rm `find /path -name '*.tmp'`

rm This is the "remove" command. You would say rm file to remove "file"
`find ....` Quotation marks are used to wrap things that may be interpreted as two commands. E.g., if you say rm find blah the computer will look for two files, "find" and "blah". The quotation mark found usually to the left of the 1 key is done to let the computer know you want to pass a command. Try running the find /home/user/path -name '*.tmp' by itself. Let's pull it apart:
find This is the command which is self descriptive
/path This is the path where it should start. It will look recursively through all farther out folders.
-name '*.tmp' The -name is a flag, letting the computer know that the next thing is the file it should look for.
'*.tmp' Why does this have quote marks? It doesn't really need it in this example, but if you were looking for a file with spaces in it you would need it.

Second: find /path -name \*.tmp | xargs rm

find /path -name \*.tmp This command is discussed above, the difference to note is the \*.tmp which I don't know why it is there. Sorry. Anybody?
| This is the "pipe" symbol. It takes whatever the left side makes, and passes it to the right side. In this case, the left side finds the file *.tmp and the pipe passes the location of that file to the right side.
xargs rm The xargs command is basically a way to pass commands, the important thing is that it is passing a command to do rm which will remove the file found on the left side of the pipe.

Third: find /path -name "*.tmp" -exec rm {} \;

find /path Find in the directory "/path"
-name "*.tmp" Look for the file with an extension of "tmp". If you want it to look for "TMP" as well, use -iname which is case insensetive
-exec rm {} \; The "-exec" is a flag which tells the computer to execute something, in this case the remove command, after it finds a file. Whatever command you pass has to be followed by a semicolon ; So it would be -exec blahblah ; complete with the space before the semicolon. The backslash character makes sure that the computer knows it is done doing whatever command it was supposed to do, in this case remove the file.
rm {} The rm command removes (deletes) a file. The brackets are a recursive thing, to the computer they mean "Whatever you just found".

April 18, 2009

Mounting an img disk

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

When I set up Qemu and ran Windows XP inside, I had XP updated to Service Pack 2 from a cdrom. How to mount a cdrom in Qemu is available here, but I wanted to upgrade to Service Pack 3 and didn't want to download the SP3 file inside the virtual Windows since it is considerably slower. So I went to the Microsoft web-site and downloaded the necessary file, assuming I could just put it inside the "windows.img" file.

Well, I can, and I have to mount the file as a drive. But how do you do that? I didn't know, but now I do:

The essential command is this:
sudo mount -o loop,offset=32256 -t ntfs /folder/windows.img /media/windows

You will probably need to make the /media/windows directory first:
sudo mkdir /media/windows

Okay, here is the explanation of the directory making:
sudo : You can't be a normal user to do this, you have to be an administrator
mkdir : This is the command to make the directory
/media/windows : This is the folder you are making. You could also make it /mnt/windows

And here is the explanation of the mounting command:
sudo : See above
mount : This "connects" the fake drive to the computer
-o loop,offset=32256 : These are special commands, set using -o , like you can make the fake drive read-only, or other tricks. The loop flag is used for fake drives, aka, img files. Any other command is seperated with a comma, an example would be -o loop,rw,auto,noexec . I will explain the offset just below.
-t ntfs : This is the type of hard-drive that is faked. In this case, it is Windows, which typically uses the NTFS file structure. Other common ones are fat16 and fat32 .
/folder/windows.img : This is the folder where the fake disk, windows.img , is located.
/media : This is the folder to mount the fake drive. It is the one you made earlier.

Okay, so here is where the real trick is: The offset=32256 flag is what tells the "mount" program where to look in the file. See, the "windows.img" fake drive file has some other information at the start which confuses the "mount" program, so it needs to know where in the file to start reading the fake drive. If you made your fake drive like I made mine, or if you only have Windows on it, the value of "32256" should be fine, otherwise try the following.

You will need to find the numerical value of the offset. Run the "fdisk" command, just be careful because if you mistype it you can easily destroy EVERYTHING! Run it like this:
fdisk -l /folder/windows.img

fdisk : The fdisk command is the swiss army knife to poke at drives
-l : This lists the drive information
/folder/windows.img : This is the fake drive

It will probably print something like this:

You must set cylinders.
You can do this from the extra functions menu.

Disk /folder/windows.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1ff71ff7

Device Boot Start End Blocks Id System
/folder/windows.img 1 * 1 1273 10225341 7 HPFS/NTFS
Partition 1 has different physical/logical endings:
phys=(1023, 254, 63) logical=(1272, 254, 63)


The two things to notice are the number which falls under the "Start". In mine, that is just 1. Note also the "63 sectors/track". The number to offset is: 1*63*512=32256

Now, once I mounted the "windows.img" I was able to poke around in the folders. I took the Windows Service Pack 3 file and copied it to my Desktop. Now I can install SP3 without having to download it in virtual Windows XP, this saves a lot of time!

For my next trick, I will pull a rabbit out of my hat:
Try mounting the Fake drive, and booting XP in Qemu together! (Mount first, then run Qemu) Rock on!

P.s. You may have trouble unmounting that fake drive? Type in df and see which thing on the left corresponds to the fake drive on the right. In my case it was /dev/loop0 . Now, you may have a trouble unmounting it still? In this case, you will need to exit any programs accessing the drive, I even had to exit the terminal I was in. Now go back and try again.

April 17, 2009

Running loops with Qemu

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

And now, for something completely different:


I am using Qemu to boot Ubuntu, from a different partition, inside of Ubuntu. Is this wise? Some suggest it is not, but I like to live on the wild side!

So the relevant code is pretty simple. Recall the last post on initializing Qemu, and take that, flip it around a bit, and here we go:

JUST REMEMBER YOU MAY BE DESTROYING YOUR DRIVE!!!!!

Sorry for that, here we go:
sudo qemu -m 768 -boot c -hda /dev/sda

The sudo bit is used here because apparently it's dangerous to mount the drive you are running. Pfff! The rest is:
qemu: The virtualizing program you are running
-m 768: You can tell Qemu how much memory to set aside. This is megabytes...
-boot c: It will boot from the virtual primary drive, instead of the cd-rom see?
-hda /dev/sda: The primary drive is /dev/sda, which is the drive I am running now

Note:
The command to restart the windows manager in Linux is control+alt+backspace. When you boot Qemu to another Linux and want to kill the windows manager, you can't use that because you will kill the main system you are using... Woops.

Now let me try to restart my extra Ubuntu, it took over five minutes last time...

Meanwhile, let me bore you with a story: I installed a second version of Ubuntu on an extra partition a while back. Thought maybe I could mess around with it and trim it down to nothing. Well, it worked but now I don't have any kind of anything on it. Good thing it was a spare. Okay it's back.

I mean, I messed it up bad. All it has is this:


Anyway, I won't bore you with the rest of the details, I was just noting that you could indeed boot Linux inside of Linux. I think I could even install Qemu on this virtual drive, boot the hard drive, and start Windows... Hold on...

I had to install a window manager, and I didn't want Gnome, so I picked FluxBox. It's the same window manager used in my favorite light-weight-heavy-hitter, DSL. Here I am, installing Qemu on my pretend computer on my pretend drive:


Alright, it just finished. Now to try booting another computer inside it. Instead of trying to kill it with another Ubuntu running, I will boot to my DSL file. Heh heh. Here we go:


The "inner world" Qemu is not handling the graphics very well, I can't even read the text on the screen:


Well, that didn't work very well at all. I don't think I have enough memory to really make this work. DSL finally booted after maybe 15 minutes, but it couldn't hardly load the window manager: It started and stalled, after 5 minutes I shut it down...

Well, anyway, that was fun.

April 16, 2009

Guess what I am doing?

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.


After I completely torched my previous Windows install with a virus infected software, I decided to try another way and install Windows in a virtual computer on Ubuntu!

Here is what I did, although some more differenter instructions can be found here:

Go to the famous "Add/Remove..." and install "Qemulator". I don't know how well suited this will be for my purposes, but this is a test anyway, so no big deal.

Now we need a fake hard drive. Now, go to the beautiful terminal (I made a keyboard shortcut: ctrl+alt+t) and travel to somewhere convenient and make a drive with Qemu:
qemu-img create windows.img 10000M

qemu-image: The Qemu program which makes the fake drive
create: I wonder if there is a detroy function?
windows.img: This is the file, which is a hard drive image
10000M: This is 10 Gigs, I am going to install a large program on here, so...

Now lets boot the fake machine up!
qemu -boot d -cdrom /dev/scd0 -hda windows.img

qemu: The program virtualizing an entire computer!
-boot d: This tells qemu what drive to pretend to boot from, in this case the cd
-cdrom /dev/scd0: The cdrom is this device, make sure it's your actual cd*
-hda windows.img: This is the earlier created hard drive image

Now Qemu will boot up to whatever cd you previously mounted on your computer. What? You didn't mount the disk yet? Well, do that, type the above command, and come back here.

Okay, now Qemu should boot up into whatever the cd was, in my case it was the Windows XP installation guide. The setup was all plain-text, fine with me, and took maybe 8 minutes. Then Windows wants to restart. It will restart Qemu, but exit the program first.

What you need to do is start Qemu back up, this time with only slightly different commands:
qemu -boot c -cdrom /dev/scd0 -hda windows.img

These are the same as last time, except for this one:
-boot c: This tells Qemu to boot to what Windows wants to call the C:/ drive, which is your "windows.img" fake hard drive file.

Now Windows should boot into it's familiar black screen with that awesome graphic window-esque thing, and then it will want to install all the drivers, files, etc., just like a normal Windows installation.

It seems that, to get the internets to work inside Qemu, you have to tell it to pass network capabilities through. It virtualizes everything else, network and usb support as well. To do that, add -net nic to the end of the command, so it looks like:
qemu -boot c -cdrom /dev/scd0 -hda windows.img -net nic

Other instructions said use -net user, I don't know the difference very well, but -net nic was the only one that worked for me.

Once you are comfortable with your Qemu configurations, you probably want to make a shortcut of some kind so you don't have to remember this command all the time. I don't have any cool tricks up my sleeve on this one, just copy and paste the command into a hand-made shortcut.

One more thing: I installed Qemu by using the "Add/Remove..." in Ubuntu, but I found the GUI was not useful, and had enough interface glitches that running through the command line is much easier. If I can figure out the command line way to install I will let you know, it's probably really simple.


*To double check your cd drive, go to the terminal (after you put in your cd and can open it's folders) and type:
df
This will list all the mounted things, drives and memory are both "mounted" in Linux, look for one that says "/dev/scd0" or perhaps "/dev/cdrom", but on the right it will have the title of the cd, like "/media/X1APFPP_EN" or something similarly unintelligible.

February 13, 2009

Ubuntu/Nautilus Specific

Hey there, this site has moved, so comments are disabled. Thankfully, you can go to the page, carefully linked for your satisfaction. Click here to go there.

I know this doesn't flow in the vein of "command line" that I am aiming for, but I thought this was a useful tidbit for those of us using Ubuntu.

I recently purchased a reasonably up-to-date laptop (refurbished, from ebay!) and changed the partitions so I could have XP and Ubuntu, and a 45GB media drive. It's awesome! If I can figure out a few programs I will remove my dependence on XP, but I am not hurting for hard-drive space yet, so no hurry.

Anyway, Ubuntu does not ship with mp3 support built in, since it is a proprietary codec and Ubuntu is released solely under the GPL. You can add the mp3 support along with some other proprietary support (Java, DVD's, etc) from the "Add/Remove..." in the Applications Start bar. The package is labeled "Ubuntu restricted extras", but is a very large download.

If you only want mp3 support, you can install the specific packages (the "Restricted extras" installs all restriced media drivers at once) by installing the packages:
gstreamer0.10-plugins-ugly
libmpeg2-4

This will download a few other required files, but overall it is much smaller than the entire "restricted extras"package.

One other neat trick that Nautilus, the included file manager in Ubuntu, can do to music files is play them when you hover over them with your mouse. This trick is "cool", although it may not have much practical value. To get this neat feature, install the packages:
mpg321
vorbis-tools

While you can install these packages through "System / Administration / Synaptic Package Manager" or you can always install it my favorite way: The command line!

For the flashy play-back in Nautilus:
sudo apt-get install mpg321 vorbis-tools

For mp3 support:
sudo apt-get install gstreamer0.10-plugins-ugly libmpeg2-4