Monday, April 25, 2011

Instant Swap_space


Just a quick one here. Need swap? Not sure why you would if you have an awesome computer, but here's the method anyway. I've just tried this, and my computer crashed. I'm guessing that I don't really need swap, although I was intrigued at the idea that "you need swap if you want to be able to Suspend/Hibernate your computer". Anyways...

This method can be found here.

1) Create an empty file - didn't know you could to that!:
sudo dd if=/dev/zero of=/swap_file bs=1M count=1000
count=1000 can be replaced with whatever filesize you wish. It has also been noted that there is an optimum ratio for RAM/Swap space so don't make it too big as it might just do the opposite of what you want it to do. of= is essentially the location and name of the file, of=/home/person/swap_file is another example.

2) Change permissions so the file is safe from others:
sudo chown root:root /swap_file
sudo chmod 600 /swap_file

3) Tell the computer that you want this file to be swap space:
sudo mkswap /swap_file

4) Turn it on - that's what she said!:
sudo swapon /swap_file

Next is the steps to make it run on bootup. I wouldn't advise this unless you have tested the swap first, and know that it is working nicely with your system.

5) Open up /etc/fstab:
sudo gedit /etc/fstab

6) And whack this on the end:
/swap_file       none            swap    sw              0       0

So I thought that this was a nifty way to add swap space, much easier than partitioning a HDD - wouldn't be so hard if I had some free space on my HDD...I'll test out and see how my system runs. See ya!

Tuesday, April 19, 2011

Installing LibreOffice on Ubuntu 10.10


Making the change from OpenOffice and can't find another word processing (WP) program? Why not try LibreOffice!

It comes as no surprise that LibreOffice was my immediate choice when the last WP program failed to do me any good. Maybe it's my fault. Maybe I was just too ignorant in my installation and forgot something. I guess I can always go back...

What I'd like to quickly outline is how to install LibreOffice using a package downloaded from their site. This is probably the preferred way to do it as the program is not found in the repository and/or repositories suggested (not sure why). So again, this is basically just some reference material for me and anyone who needs a quick HowTo on the topic of today.

1) Download package
So, and you've probably already done this, go to http://www.libreoffice.org/download/ and download the most recent package for your computer. I'm on Ubuntu 10.10 so I downloaded the "Linux x86 (deb)".

Before I start, I'd just like to make a reference to where I got my information from http://ubuntuforums.org/showthread.php?t=1585017. I'm actually reading it as I write this...

2) Remove OpenOffice
Right. So while the ~143M file downloads, remove OpenOffice. It can be done several ways - hopefully you are familiar with those. I actually ran into a wall trying to use apt-get, so instead I just opened up the Synaptic Package Manager and removed it that way.

3) Extract file
Once download is complete. Open up the directory where it is located (Nautilus or bash) and extract it. If using bash enter this to extract files - will be different if the file you downloaded wasn't .tar.gz:

sudo tar -zxvf filename

3a) Rename the extracted folder "libreoffice"
This is not required but simply saves typing later on. Bring up bash and type:

sudo mv filename libreoffice

4) Install.
In bash, just use dpkg to install the packages. And so you don't have to continually re-enter the command for every file, use the wildcard symbol:

sudo dpkg -i ~/Desktop/libreoffice/DEBS/*.deb 

Remember to check your pathway, most likely will be different. This step may take a while, I didn't time it, I just went to sleep.

5) Install the menu icons.
Lastly, if you open up the "libreoffice" folder and then click on "DEBS", there should be another folder name "desktop-integration". There will be one .deb file in here and you simply want to install that. Again, make sure pathways are correct - I'm susceptible to pathway mutations.

sudo dpkg -i ~/Desktop/libreoffice/DEBS/desktop-integration/libreoffice3.3-debian-menus_3.3-9526_all.deb 

Now go check your "Applications" menu and if everything was done right, it should be under "Office"...YAY!

So go play, frolic in the fields of LibreOffice and don't be afraid to venture further, or even Tweet comments, I'm sure they'd like to hear em.

Before I go, I want to emphasis again where I got my information from, thankyou scouser73 on Ubuntuforums.org, thread here. I'd also just like to give some experience on LibreOffice already.

I haven't actually typed anything up yet, but the Zotero extension comes pre-installed (unless it was fetch from my Download folder while I was installing it...). I've tried adding references and there has been no hiccups as yet. Problems I was having with OpenOffice-Write was some weird thing where, if my computer went into stand-by, when I came back and logged in, if I tried to type something into my document (which I usually leave open), then it would crash. Very annoying. I will be testing that today and hopefully it doesn't crash in the lecture hall! Enjoy and post me your experience.

Saturday, April 2, 2011

Wgetting


Lately, I haven't exactly been spending enough time on my AMD laptop, traversing the Brisbane landscape with my trusty Samsung Netbook - what a joy! Not knowing where a power-point is, isn't a major issue now. But unfortunately, I end up spending much of my time on my netbook even when I get home. And the downside is that I just don't have the same processing power to do some real computer stuff - sshing, reading Ubuntu Documents (on a 15" screen is the only way), and listening to the radio!

In this quick blog, I'm just going to demonstrate how to Wget some stuff such that you don't download the same thing twice. Wget is a useful tool which can be used to download files from the web without the use of a browser. If you want to get an idea of it's power, just watch 'Social Network'. Basically it can be used to download whole websites and the number of different files that a website will contain. For example, you can download the files that makeup the Google website - the logo, the html, any animations, any javascript files etc (though I probably wouldn't try download all of Google...).

Wget is a simple program to use and should come with your Ubuntu distribution, if not, just get it from the Ubuntu Software Centre.

Open terminal (I'm assuming you're using a linux distro) and go to the folder where you want to save the downloaded files. Then invoke Wget. Invoking is simple - program url:

Wget http://www.aurl.com

This is without the use of any options. To see the options available, just type:

Wget --help

Now, I won't be going through them all, but I'm just going to detail those that are useful to me.

If my friend has a folder on his server that contains a number of files which I will need for a university assignment, and I want to download that folder to my computer, then I will need to do a recursive download. But I don't want to download anything else on his server, just everything below the folder of choice. So I will need to do a recursive download with 'no parent' - Wget jargon. Do it like this:

Wget -r -np http://www.myfriendsurl.com

All files will be downloaded to the directory that the terminal is currently in and Wget will neatly put them in a folder called 'www.myfriendsurl.com'.

Having fun yet? But you're annoyed that the pathway that it is being saved to, is too long to type aren't you? Well there is a solution! --cut-dirs. That's right!

So, I'm guessing your friend is a space-freak and keeps their server nice and tidy by using some sort of naming hierarchy which doesn't use a date or data genre structure! And now you're download from a site which is longer than 60 characters and looks like http://www.thesaferhaven.com/home/themonolounge/hinduphilosophy/yoyo-sponge-cake. What a nightmare! Well, what you do, is use --cut-dir to rid the extra directory listings that you will never need. Using:

Wget -r -np --cut-dirs=4 http://www.thesaferhaven.com/home/themonolounge/hinduphilosophy/yoyo-sponge-cake

--cut-dirs=4 will cut 4 of the folders off the download saving you clicking time and your sanity.

Now, when you go to the directory where you downloaded all these files, instead of having to click www.thesaferhaven.com > home > themonolounge > hinduphilosophy > yoyo-sponge-cake, you can just click www.thesaferhaven.com, and you will be at the files which you are interested in.

The last option I'd like to tell you about is the 'no clobber' option. All it does is tell Wget that you already have one of the files (which it is trying to download) on your computer, and it will stop Wget from downloading it. Use it like this:

wget -r -np -nc http://www.myfriendsurl.com

Of course, you must be in the same directory otherwise Wget won't see the files!

Too easy! In all honesty, Wget is more useful to those who build websites and want to download whole directories in their entirety. Wget is commonly used to download websites and mirror them from a home server. Something I need to learn more about...

Hope you enjoy this instalment of my Linux knowledge and write back to me on what I should learn next!

Tuesday, March 8, 2011

Remote rhythmbox playing...teeheehee


This is awesome. I already have a very good use for this method as you will soon see...waking up my house mates by ssh-ing to my home computer and turning on Rhythmbox, and turning it on loud!

So I really just wanted to be able to play music from the terminal. Mainly, so I can do this on a remote computer via ssh. I thought it was a crazy idea and not possible, but how wrong I was. I soon realised also, that Rhythmbox probably isn't the most process efficient program to run, but hey, it was straight forward, and did what I wanted it to do so I'll stick with it for now.

This is a guide to running a program on a remote machine over ssh.

Firstly, you'll need to ssh to the desired computer. Many docs on how to do this. I used a variant of the following command with no -X option.

ssh me@192.168.1.1

Enter the password for 'me' on the host. Then, type the command below, I lost the link to where I found it sorry.

export DISPLAY=:0.0

When you press enter, nothing will happen. However, you have just given ssh somewhere to direct programs that require a GUI. This command is also used if you want to direct the program to display on the local computer, but instead of using 0.0, another option is used. This is a little more complicated though and some files need to be edited.

Ok, so to test that you can get a program to start-up, try xeyes.

xeyes

Much easier to know if it works if the computer you are ssh-ing to is right beside you. So now that it works, we want to get rhythmbox working. The command is:

rhythmbox-client

This opens rhythmbox and then allows users to send commands to the client via terminal. To find a list of options, run:

rhythmbox-client --help

Lastly, point your terminal to the folder where all your songs are located, and queue them like so:

rhythmbox-client --enqueue FOLDER-NAME

Vuola! Use the --play and --next options to get to the songs you want to play. Of course they have to be in the playlist to play.

I will probably find an easier method for playing songs soon, but hey, this works for now. The only problem I've run into thus far, is if you add a folder, it adds all the files that are in that folder, documents, images etc. Possible solution, run an ls with a grep option to select only song files. It should work, will try it soon.

Thanks and have fun waking up your neighbours!

Saturday, February 26, 2011

Setting up a server, the nanoTux way!

Good evening. I think I've built up enough oomph to attepmt AGAIN to setup a server. Using the nanoTux guide, http://nanotux.com/blog/the-ultimate-server/, I'm really hoping that it works and that I haven't gone insane by the time I reach the end of the HowTo. This guide was found on the Ubuntu Forums website in the Server Platforms area and seeing as it's had almost 27000 views, I'm sure it's the real McCoy.

For a complete HowTo, go to the address given above as this post will simply be making references to the code I use, and any workarounds that I implement. Begin! Shit...no coffee, plunger is missing...

To be continued...

Sunday, February 6, 2011

Just some useful stuff: bash networking commands


After all that clicking and scrolling for my last post, I ended up finding several other useful commands. Most of them are to do with networking and I'd just like to have them handy. Here goes.

Display total space and availability:
df -h

Display size of a folder, a couple of options here, may need to be sudo:
sudo du -hs /path/to/folder
sudo du -chks /path/to/folder

IP Scanning with range 192.168.1.1-192.168.1.254:
sudo nmap -sP 192.168.1.1-254

Scan operating system on target IP (cool!):
sudo nmap -O 192.168.1.3


...and that was all!

Ubuntu and Windows: admiring how they share


Up late again but I've struck some success. I've just found a neat little way to access a share folder located on a windows box on your current network. This will no doubt be a short How-To since it's 12:44AM and I didn't fall asleep till 3:30 this morning because it was so hot, great.

So, basically, you have a network, and because you are leet, you run a Ubuntu machine, but of course someone else will be running Windows (and others maybe even a Mac, God help me if I have to figure that out). If you have used Windows, then you will know that there is a somewhat simple way to setup folder sharing, but this requires you to be connected via a cable to the network. Not sure why.

To share a folder in Windows with the rest of the network, you just right-click on the folder you wish to share, then Properties > Sharing Tab > go down a bit. Then, you might see "Network Setup Wizard" or you'll see two check boxes:
1-"Share this folder on the network" and
2-"Allow network users to change my files".
If you see the wizard, then you need to follow it through and hopefully select everything correctly; there's a guide here at the MS site. For you (the leet user) to be able to access your mates'(clueless drongo) computer, both of these boxes must be ticked. And I'm sorry, but you can't do this without the owners consent...

Just to check if you or your friend have done the setup right, the shared folder will come up in Network Places (I think, not using Windows atm) under the workgroup that you chose in the wizard.

Ok, so the folder is being shared, how do I access it from Ubuntu? Well the simplest way is to just click there by going to Places > Network. It might take a while to load because it does some sort of search. The other way to access it is from the command line, useful for those who want to move stuff from a dead server box that doesn't have any USB ports! Lol...

I'm running Ubuntu 10.10 and I didn't have any dependency problems but that may be different on other distros. There are two packages, CIFS and smbfs which can be used to mount local machines to a place on your computer. Currently, it seems that they can only mount machines that have a wired connection. Maybe something to do with too many fingerprints...not sure.

Create a mount point on your computer first: I went with /mnt/test. But any will do.
sudo mkdir /mnt/test

Now, assuming that you know the IP address of your mates computer and have already obtained their username/password, run the following command for CIFS:
sudo mount -t cifs -o username=drongo,password=password //192.168.1.1/shared-folder /mnt/test

And for smbfs just remove the -t cifs:
sudo mount -o username=drongo,password=password //192.168.1.1/shared-folder /mnt/test

If they didn't use a password, just leave it out and when it prompts for one, just hit ENTER. I did run into one hiccup and I'll just voice that here. The IP address that you use has to be the address of the wired modem not the wireless modem, otherwise it won't work. That's it. I'm sure I've left some other important information out so please correct me if you find it.

Other than that, the folder should now be accessible at /mnt/test for you to copy, write, delete or even put stuff there. Maybe you're a nice friend and you want to give them some music? It's possible.

Don't forget to unmount!
sudo umount /mnt/test