Tuesday, September 16, 2008

Setting your time zone


In /etc the file, localtime, is a link to or copy of a file containing information about your time zone. Zone information files are usually in /usr/share/zoneinfo but this depends on your distribution. So if your localtime file points to a zone info file that is not your time zone you can change it by browsing the directories in /usr/share/zoneinfo to find your country, then find your city or a city in the same time zone and link localtime to it.
    $ ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Changing the date and time

Changing the date and time requires two steps. First, Linux's date and time must be changed and then the new time has to be written to the hardware clock.
The date command can be used for both viewing and changing the date and time.





To change the time use date followed by the month, day, hour, minute, and year all numeric and no spaces. So, to set the date and time to November 2nd, 2003 12:57





The hardware clock can be updated in UTC (coordinated universal time) or your local time. It is standard practice to update it in UTC.





To update it to your local time leave off the --utc or add --localtime and leave off the --utc.





Alternatively
The date and time can be changed directly to the hardware clock and then used to update the system clock.

Saturday, September 13, 2008

How to use torrentflux

Welcome to the major part of this tutorial. Using torrentflux. For your information, this chapter have been divided into 7 major parts.
a. Entering torrentflux
b. Adding torrent file
c. Downloading
d. To the computer

1. Go to your bookmarked torrentflux main page. insert your username and password for the password protected directories and then your torrentflux username and password. Click ‘Login’


2. Wait.


3. Click ‘ok’ if this comes out.




4. Congratulations! You managed to get into torrentflux main page!


5. Click browse at the upper left.


6. Click the downloaded Metafile, click open.


7. Make sure the drop box on your right is set at ‘upload’. Then hit ‘Go’


8. Wait.


9. Yes, we have successfully added torrent metafile to our torrentflux download list!


10. Click the play button.


11. At completion activity, choose ‘Die When Done’ from the drop down menu. We don’t want to waste any bandwidth. Then tick the file you want to download. This is important since there can be more than 1 file in a meta torrent file and we do not want to download any unnecessary stuff aren’t we? Click ‘Run Transfer’ after that.

*Bandwidth is monthly transfer between a website and the surfers. For example, supposed that you go to a website and when you sum all the pictures sizes, webpage size etc and you’ll get a total 1mb. This 1mb is the amount of file transferred between the website to your computer. It is not significant for users but significant for web owner. Supposed that a web owner was given 500mb bandwidth from his or her webhosting company. Each time that 1 mb page is opened; 1mb of the bandwidth will be used. So, the website can only handle 500 visitors (500X1mb=500mb) per month and 501th visitor will not be able to view the website. This is just an example. In real life, each page files come out with different sizes. Some visitors may use 50kb, 3.4mb etc. So it is important to keep an eye on your bandwidth meter.


12. You will see this. Click stats to see the stats of the download.


13. Connecting to other seeds and peers…


14. Downloading…




15. Succeed! Now close this window and head straight to your torrentflux main page.


16. Refresh this page to get the latest update. Click ‘Home’.


17. You should see the latest update regarding your torrent now.

18. Click ‘Directory’


19. Open your username folder.


20. Open the folder. *You can download the whole folder by clicking the button that surrounded by the black box. It will save them as a single .tar file, some kind of zip file.


21. I want to download the first file, so I click the green pointing download button.


22. Save it to your computer.


23. Transferring the data.


24. Done! And it works!


25. To remove individual files, click ‘X’ button next to the file and click ‘Ok’ when asked.



26. If you want to remove the folder, simply do the same but now at the folder.


27. Files have been deleted but the torrent metafile is not. To do so, go to torrentflux main page and click ‘X’ like shown here. Click ‘OK’.

Torrent meta files and the actual files (that we download) are 2 different things. If you deleted the files, you can always redownload the files if you have the meta files. If you delete the metafiles, you can not redownload or resume your downloads.



28. Processing…


29. There you go.


30. Now, to exit torrentflux properly. Click ‘X’ on the upper right.


31. And you are cool to go now.


http://torrentflux.blogspot.com/

Installing Torrentflux

Torrentflux. Whats is torrentflux ?.

Torrent flux is a php based torrent client which runs on a web server/ website.

Conventionally, people will install torrent clients such as azureus, utorrent which runs on their computer to do the torrent job and they are not php based.

Torrentflux will download the files to the web server /website first, and users are need to redownload them into their computer after the download is complete. Whereas computer based torrent client download the files directly into the computer and users are not needed to download them again.

People use torrentflux because:

1. Their ISP (internet company that they subscribe to) block torrent.

2. They do not have time to turn on their computer 24 hours per day.

3. To achieve greater speed!

The Torrent concept

Direct download, computer to computer such as downloading file from download.com, cause a heavy load on the web server. Imagine thousands of computers download thousands of files at to the same time, from the same web server.

Moreover, if the web server broke down, thousands will get affected!

So the concept behind torrent is to cut the files to thousands of pieces and begin to distribute them. After that, participants (or people who are downloading the files) will download (take) and upload (give) the pieces among themselves. Instead of relying on one computer, there are now relying and sharing on many people. More like of team work.

After all the pieces have been downloaded, ta-da! Your computer will assemble the files and now you have the complete files!

Major components

Anatomically, there are 3 major parts.

1. Torrent client – such as Torrentflux, azureus etc. Torrent client is the heart of torrent. It manages and downloads the file. It uses torrent meta files to get information regarding who have the pieces.

2. Meta file – associated with *.torrent type file, this piece of file are the navigator to the Torrent client to tell it where to get information regarding the pieces.

3. Tracker - A web server /website which manage who have the pieces. This is actually none of your concern and you have no power to it. This is the brain that manages and gathers information around the world, regarding who have the pieces. A torrent client uses meta files file to connect to trackers.

Supposed that one of these components unavailable, you cannot get the download process running.

Essential terms

Seeder – people who have complete pieces of the file(s)

Leecher – people who do not have all the pieces and are downloading it.

Ratio – The amount of availability of the file. If it is 1.00 and above, at least 1 copy of all the pieces are available and it is possible to get the complete files. 1.00 ratio means 1 complete sets of pieces. 4.00 means 4 complete sets of pieces. The more the merrier.

NEVER DOWNLOAD FILE WHICH HAS 0 SEED OR RATIO BELOW 1.00 !

What do I need to use torrentflux?

Here's what you need:

1. Linux based webserver

2. Apache

3. MySQL

4. PHP Version 4.3.x or higher

5. Perl 5.6

7. Apache

8. MySQL

9. PHP Version 4.3.x or higher

10. Perl 5.6

Frankly speaking there are more but not so significant I guess. As long as you have these stuff, your percentage to succeed is high.

One more thing, ask whether you web site company allows you to use the torrent. It is no use if you met all the requirements but your company blocks it

On your host, find out a working link for downloading Torrentflux at http://prdownloads.sourceforge.net/torrentflux/torrentflux_2.1.tar.gz?download
Choose a location near you and choose download. Cancel the download and write down the link shown below in blue (haven't found a way to paste text into my vmware-window yet)

back in your machine type:

wget

e.g.

wget http://belnet.dl.sourceforge.net/sourceforge/torrentflux/torrentflux_2.1.tar.gz

If you need to use a proxy server begin with setting up your proxy server in you current environment:

http_proxy=http://:;export http_proxy

or if you want this to be permanent: edit the /etc/wgetrc and fill the proxy settings there.
To edit the /etc/wgetrc file you need to know how to use vi, this is beyond the scope of this how-to.

Result:


All right, we downloaded Torrentflux, now on to installing it. Set mysql root password:

mysqladmin -u root -p password

when asked for a password: just press
it's the current mysql root password which isn't assigned yet.

Unpack Torrentflux:

tar zxvf torrentflux_2.1.tar.gz
cd torrentflux_2.1
mysqladmin -u root -p create torrentflux

cd sql
mysql -u root -p torrentflux <>

cd ../html


Set up the config.php:

vi config.php

Now edit the settings as below:

Consult a vi manual to find out how vi works.
After saving your updated config.php file copy the files to your web server root directory:

sudo mkdir /var/www/tf
sudo cp -rf * /var/www/tf

Create a folder to save the downloaded torrents

cd /home
sudo mkdir shared
sudo chmod 777 shared
cd shared
mkdir torrent
chmod 777 torrent

If everything went OK it's time to try if it's working and to set up the last bits in Torrentflux. To find out what the ip address is of your new server:

ip address

Look for the eth0 network card:
in my case the ip address is: 172.16.50.83

On your host: open your webbrowser and go to:

http://webserver_name/tf

Tadaaaa! :)

Login with: root and mysql password:

As a final step: change the path to: /home/shared/torrent and press 'Update settings'

Next Chapter "how to use torrentflux".


Sunday, September 7, 2008

Renaming Multiple Files with the Same Extension

sometime i have problem when i download or managing filename. because filename are same extension and disorganized.

so i use googling for searching script to help me managing file.

ok i write in here how to manage file in linux, of course command base, linux power full in command base.

To give a different file name extension to a group of files that share the same file name extension, use chcase with the `-x' option for specifying a Perl expression; give the patterns to match the source and target files as a quoted argument.

For example, you can rename all file names ending in `.htm' to end in `.html' by giving `s/htm/html/' as the expression to use.

* To rename all of the files in the current directory with a `.htm' extension to `.html', type:

$ chcase -x 's/htm/html/' '*.htm' [RET]

By default, chcase will not overwrite files; so if you want to rename `index.htm' to `index.html', and both files already exist in the current directory, the above example will do nothing. Use the `-o' option to specify that existing files may be overwritten.

* To rename all of the files in the current directory with a `.htm' extension to `.html' and overwrite any existing files, type:

$ chcase -o -x 's/htm/html/' '*.htm' [RET]

NOTE: Renaming multiple files at once is a common request.

Tuesday, September 2, 2008

Basics of basic assembly Programming

Why learn asm?

Assembly is seen by many as being too much work to do most tasks. This although partly true assembly is the one of the fastest langs around and is a low level language so it lets you get down and dirty with your machine. Asm also is a great learning experience and teaches you how your computer works.

Ok lets get started!

CODE
.model small
.stack
.data

Message db "z0mg ASM!!$"

.code
start:
mov dx,OFFSET Message
mov ax,SEG Message
mov ds,ax

mov ah,9
int 21h
mov ax,4c00h
int 21h

END start


Ok happy? Fin.
tongue.gif alright i guess i can explain it a little bit.
First all asm programs start off with a .model call. in this situation we use the small memory model which means that the data and code segments are separate but both are less than 64k. Ill explain more about memory models in another article.

The .stack call is required for .exe programs which require a call stack to function.

We then move into the .data segment. This is where all of your variables are stored.

CODE
Message db "z0mg ASM!!$"


In this example "message" is your var name. Db stands for declare byte and sets the size of your var. The "{:content:}quot; symbol terminates the string and also stores the string length in the var.

.code
This segment stores your code! Who would of thought that? tongue.gif

The first thing you'll notice is the mov command. This copies x into y. It doesn't matter what y is so it can be a value register or var etc however you have to make sure x is able to store the amount of data and is same data type.

Now were going to take a bit of a detour here to talk about registers.

For now were only going to talk about the 16bit registers. Our general purpose registers are:
#note to use their 32bit cousins add an "E" to the front of the name #
ax
bx
cx
and dx

Now all of those above registers are 16bits in size however they each are actually 2 registers. ax for example is split into ah and al. However ax al and ah can each be used separately for some tasks.

Now the next thing you'll notice is the SEG and OFFSET. During the early computer years they felt no one would ever use more than 1mb so the chip was designed to not allow anything over 1mb. The problem however was that to access 1mb 20bits were needed. Since registers were only 16 bits and they felt using 2(32bits) was impractical they decided to use SEGMENTS and OFFSETS to access 20bits using only 1 register.
EX:
OFFSET=SEG x 16
SEG=Offset / 16( the bottom 4 bits are lost sad.gif )
1 register has the offset and 1 has the segment if you put them together you have a 20bit address biggrin.gif .

EX2:
CODE
SEGMENT 0010010000010000---- OFFSET ----0100100000100010 20-bit Address 00101000100100100010


DS stores the segment and SI stores the offset. Note any general register can be used to store an offset except for the segment registers which are CS, DS, ES, SS.

^^ I hope you understand all that it took me a while to figure out.
The mov ds,ax points or segment and offset to create our 20bit register which stores our string.

Next we move 9 into ah then use int 21. Int cmds are interrupts are like functions and int 21 is the most common as it calls dos. When we use int 21 it searches ah for the function and in this case its 9 which is print string.

The final part mov ax,4c00h then int21 returns us to DOS. Ill fully explain it in the next tutorial.

Ok now you know how it works so lets compile it. I prefer to use tasm so thats how im going to explain it. Save the file as test.asm # or wtf you want.asm

CODE
C:PerlTTASM5BIN>tasm test
Turbo Assembler Version 4.1 Copyright (c) 1988, 1996 Borland International

Assembling file: test.ASM
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 453k


C:PerlTTASM5BIN>tlink test
Turbo Link Version 7.1.30.1. Copyright (c) 1987, 1996 Borland International


Well folks you have just learned the basics "hello world" style program and how it works in x86 asm. In the next tut ill cover input control and maybe even some graphical work. If you have any questions feel free to ask away.

Sunday, August 31, 2008

How to setting SAMBA using GUI

you're going to need an easy way to share files between linux and windows. In this article we will walk through setting up a Samba share on your Suse 10 machine that you can map as a drive on your Windows machine. To start, click the House icon in the lower left of your Suse 10 desktop to open a File Manager as a normal user. This will put you in your home directory which is normally /home/yourusername, in my case it is /home/frodo



Next we will create a new folder in our home directory and name it webshare.
Click the Edit Menu and choose Create New -> Folder, then enter the name of the folder



You have probably figured out by now that linux lets you have as many desktops as you like. I have configured 6 of them as you can see 1 through 6 in the menu bar at the bottom of my screen (above). To
configure how many desktops you can right click in one of the numbered squares in the menu bar and choose Configure Desktops. In the screen above Desktop 1 is active and I have my File Manager open in that desktop. Next, click on desktop 2 and we will open YaST on this desktop. System -> Control Center (YaST), you will be prompted for the root password.



As shown above, click the Network Services item on the left then click Samba Server to configure Samba and add our new webshare folder as a share.
You will be prompted for a domain name. If you have a local domain name enter it here. If not feel free to make something up like we did during the Suse 10 installation when we chose a host name and domain in the network settings. I put middleearth.home for mine as shown below.


I don't have a domain controller on my local domain at home and I don't want to configure Samba as a domain controller, so I checked Not a Domain Controller.


Next I set it to start Samba during bootup then I click the Shares tab to setup my share. Also be sure to check the box and open a port in the Firewall to allow your local network to access the share.



Now I create a share named webshare that points to my /home/frodo/webshare folder. I unchecked inherit ACLs and unchecked Read Only


Next Click Finish as shown below.



I had to do some modification to the configuration file for Samba to get the share to actually work for me. I'm in no way a Samba or linux guru yet myself so don't think this is neccesarily the best practice but this is what worked for me and it should work for you. If someone with more expertise out there wants to email me with a better procedure I will update this article happily. You'll need to open System ->File Manager -> File Manager Super User Mode to do this because only root has permission on the configuration files. Now browse to /etc/samba/ and open smb.conf in a Text Editor



Scroll to the bottom of the file and you'll see the section for the share you just setup in YaST. Add the missing settings as shown above, of course put your linux user name where I have frodo. Now save and
close the file.

Before I move on I'd like to talk a little about linux configuration in general. While there are some nice GUI tools like YaST for configuring many of the settings on your linux machine, most of the GUI configuration tools are really just a front end on top of text files where the settings are stored. Almost everything you will
ever need to configure is located in a text file somewhere below the /etc folder. Its just a matter of knowing which file has which settings and what the possible options are for each setting. There is a lot of
documentation available for these settings both online and in the man and info pages locally on the linux machine Those coming from a windows world sometimes perceive this as an indicator that linux administration is difficult. But think about it, as an ASP.NET developer you are probably very familiar with storing settings for your web apps in the Web.config file and editing these settings seems trivial to you. When you are familiar with the file and the settings it seems very easy and the fact that all you need is a text editor is very convenient isn't it? I say this because this is a paradigm shift I went through. I used to think linux administration was difficult and then as I became familiar with the files and settings of interest to me my point of view changed.

Now getting back to setting up the share, we now need to restart the Samba service for our setting changes in the smb.conf file to take effect. Open YaST again or switch to the desktop where you already have it open if you still have it open. Then as shown below click System in the left pane and then System Services (Runlevel)



This is where you can configure which services are running similar to what you would do on windows using the Service Management Console.



Click on smb Samba File and Print services as shown above then click Disable to stop the service



Now after it stops click it again and then click Enable to start the service again.



Now while you're in the services administration section of YaST, scroll up the service list and see if apache2 is already running. If not start that service as well by clicking it then clicking Enable. Now click
Finish and it will save your settings.

Now most likely you are like me and working at home so you don't have a Domain Name Server (DNS) to resolve names of the computers on your local network. Since I want to be able to connect to my Suse 10 machine by name I will create an entry in my hosts file to map a friendly name to the ip address of the Suse 10 machine. On windows, this file is typically located at c:\Windows\system32\drivers\etc\

Interesting that we also have an etc folder on Windows isn't it? Anyway, the hosts file in that folder is just a text file, you can open it in Notepad or a text editor of your choosing (Don't use a Word Processor)

You will see a line with

127.0.0.1 localhost


this is how every machine knows that the hostname localhost refers to itself. The use of localhost is a conventional naming on both windows and linux. 127.0.0.1 is what is known as the loopback ip address
becuase it always points to the machine you are on.

Now we will add the ip address of your Suse 10 machine with a friendly name of your choosing. I put the following 2 lines:

172.16.0.21 isengard

172.16.0.21 isengard.middleearth.home

Note that you can map multiple names to the same ip address. I chose names that correspond to the host name I setup on my Suse machine but I could put whatever I want for host name mappings like

172.16.0.21 hamsandwich

This will resolve the host name(s) I put to the ip address I put at least for this Windows machine. Save the host file and then in a web browser on your windows machine go to http://isengard (or whatever host name you put) and you should see the default apache web page served from your Suse 10 machine. Nice huh?

Finally, open Windows Explorer
and choose Tools -> Map Network Drive, then pick an available drive letter and for the Folder put \\isengard\webshare (of course replace isengard with whatver host name you put in your hosts file.

Stay tuned for the next article and we will finally learn to setup mojoPortal on the Suse 10 machine using apache Virtual Hosts. Learning this will allow you to setup as many sites as you like on your Suse 10
machine so you can develop and test your own applications.

Thanks
to www.joeaudette.com