Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, September 13, 2007

OK, I will do second backup NOW!

Last night I came across a sad story about a guy who loose almost all of his data, including some voice files of his passed mother.

Well, I do have backup. For work, I got one extra hard disk in Mac Pro, which got synchronized with the main HD whenever I am having lunch in weekdays. At home, I have tons of old harddisks storing my huge music library. In my Linux server, I scheduled important files backup to another drive every single night. But is it a bulletproof solution? I know it's not.

What if my office got fire? Then both the HD in Mac Pro will be gone. What if my home got fire or theft? Then all my personal data and work are gone. OK, may be these are a little bit extreme. How about if the power supply of my computer got surged? The result is the same. One backup = no backup.

So I just subscribed Mozy. It recently got a Mac backup solution. For about USD5 per month, I have unlimited storage for backup. Though it may take month to perform a complete backup of all my stuff (well, the approximate upload rate stays at about 60KB/s), for long term, it should be a bulletproof solution. Just no need to get worried about backup anymore.

I am glad that I have read the story, and even more glad that I have made the decision immediately.

Monday, August 20, 2007

Mac + Parallel + Ubuntu + wm6 net access

My major web development platform is Kubuntu, which I installed inside Parallels. Since I want to freely test the web application in any of my machines, I choose bridged networking (both macbook and Kubuntu are set to using static IP addresses). On the other hand, my Macbook can access the net through shared networking of my U1000, which provides the HSDPA connectivity to it. I have two problems to solve for the above setup:

1. When I am on the go, since my ethernet is unplugged, my Macbook cannot ssh to my Kubuntu.

2. And of course, my Kubuntu can't access the net, even my Macbook is connected with my U1000.

Recently, I have found a solution. But before this, I need to say something about my home networking configuration first. I have Linux server at home, acting as NAT gateway for all the machines inside my house. The Linux server has 2 ethernet cards, one connected with modem from ISP, the other connected to internal LAN. I don't have DHCP server setup, as I want to have more control on IP on each machine. Say my network is 192.168.0.0, my Linux server is having IP 192.168.0.1. So every machine in my LAN is setting 192.168.0.1 as gateway and DNS server. This includes the setting for my Macbook and the Kubuntu VM.

You may wonder why I need to setup my home networking this way instead of all set to DHCP. The major reason is this setup is exactly the same as in my working area. So my Macbook (or whatever mobile devices that I brought between my working area and home) doesn't need to change anything for joining the network of two places. Another reason is I usually like to remote access any other machine from another machine at home (mostly due to my physical laziness). So I don't want my home computers to change IP time to time.

Anyway, Below is my solution on the go:

1. During on the go, change the Kubuntu networking inside Parallels from "bridge networking" to "host guest".

2. In Macbook -> Preference -> Network, Create a new location profile, say "OnTheGo". In this profile, edit the "Parallels Host-Guest" device to have the IP address of the gateway address being used by Kubuntu. (In my case, it is 192.168.0.1)

3. In Macbook -> Preference -> Sharing -> Internet, set

Share your connection from "Bluetooth PAN" to ethernet Adaptor (en?) of "Parallels host-guest"adapter.

After the above is set, you should already be able to perform any networking operations from Macbook to the Kubuntu. After you have connected the Macbook with wm6 through BT PAN, the Kubuntu will be able to access the net also.

When I am back to home, I just need to change the Location setting back to default (or whatever used at home), and Parallels setting back to "bridge networking". This way, the "Parallels host-guest" adapter's IP address won't get conflict with my Linux server.

Wednesday, October 19, 2005

Subversion initial setup

Subversion is a project aims to build a version control system that is a compelling replacement for CVS in the open source community. Besides usual way of doing version control, this is also a good candidate for backup of anything you can imagine. There is a free online book available, if you want to further study it.

Below are some setup notes I have jotted down during my setup. May be this will be helpful to you also.

Setup in Gentoo Linux, as apache2 module

1. If you happens to have apache 2 already installed, setting up Subversion is easy:

# emerge subversion

But in case you are using apache 1.x, you can still go ahead and let portage to install apache 2 for you. There is nothing much harm (other than use more memory) to run both apache 1.x and 2.x together. All you need is just changing the port number apache 2.x is listening to.

2. Create directory for source repository: (you can use whatever directory)

#mkdir /var/repository

3. Create user account for svn:


#mkdir /var/svn/conf
#htpasswd2 -c /var/svn/conf/svnusers newusername


The second command create a new user "newusername" and store the a/c password info in /var/svn/conf/svnusers. The -c option is for file creation, if you are adding more users, you can simply go without this option.

4. To allow apache2 to load the corresponding svn modules, modify /etc/conf.d/apache2 to add "-D DAV -D SVN", e.g.:

APACHE2_OPTS="-D SSL -D PHP4 -D FASTCGI -D DEFAULT_VHOST -D DAV -D SVN"

5. Configure the modules config file /etc/apache2/modules.d/47_mod_dav_svn.conf (you may have number other than 47, depending on the portage maintainer). Assuming we use the password file and repository directory created previously, the file may look like this:


<IfDefine SVN>
<IfModule !mod_dav_svn.c>
LoadModule dav_svn_module modules/mod_dav_svn.so
</IfModule>
<Location /repos>
DAV svn
SVNPath /file2/repos
AuthType Basic
AuthName "WINS Subversion Repository"
AuthUserFile /var/svn/conf/svnusers
Require valid-user
</Location>
<IfDefine SVN_AUTHZ>
<IfModule !mod_authz_svn.c>
LoadModule authz_svn_module modules/mod_authz_svn.so
</IfModule>
</IfDefine>
</IfDefine>


6. Create your initial repository:

#svnadmin create /var/repository

Setup in Redhat, standalone server

For illustration purpose, this time, we run subversion for standalone version, and invoked through xinetd.

1. First step is also easy:

#rpm -Uvh subversion-XXXX.rpm

Just replace XXXX with the version currently available in your system.

2. Create a user for svn in your system. For security, you should set it's login shell to nologin.

3. Add 2 lines to /etc/services: (if they don't exist yet)


subversion 3690/tcp # Subversion
subversion 3690/udp # Subversion


4. Create a file /etc/xinetd.d/svn


# subversion server
service svn
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = svnuser
server = /usr/bin/svnserve
server_args = -i
}


5. Create your initial repository:


#mkdir /var/repository
#svnadmin create /var/repository


6. During initializing the repository directory, svn creates various directories and files. In particular, there is a config file svnserve.conf inside conf directory created. There are extensive comments inside the config file, with all example setting commented out because they are already set by default by svn. Anyway, you can customize them to your needs, e.g.:


[general]
anon-access = none
auth-access = write
password-db = passwd
realm = My Subversion Realm


The above disables anonymous access, and allow write access for authenticated user. Most importantly, it defines the password file for authentication as 'passwd'. Now in the same conf directory, create this file with following content:

[users]
wins=password1
user2=password2

Using subversion
The most important command to know first is help:

$svn help

To get help on a specific topic :

$svn help update

Import initial directory for a project:

For apache module:


$svn mkdir 'http://localhost/repos/NewProject' -m 'Creating new Project'
$svn import ./MyProject 'http://localhost/repos/NewProject/trunk' -m 'Import for 1st time'


Note that '/repos' is defined in Location directive in apache config.

For standalone version, use svn:// instead.


$svn mkdir 'svn://localhost/var/repository/NewProject' -m 'Creating new Project'
$svn import ./MyProject 'svn://localhost/var/repository/NewProject/trunk' -m 'Import for 1st time


Note that the '/var/repository' are actually a full path of the directory where you create for repository.

Before performing any commit, you need to perfrom an update first :

$cd ./Myproject
$svn update


To check your checked out source status :

svn status

The svn will also mark all non-version file inside your checkout directory as '?' status.

To ignore some files from subversion status cmd (or add/import), either set it globally in ~/.subversion/config :

[miscellany]
### Set global-ignores to a set of whitespace-delimited globs
### which Subversion will ignore in its 'status' output.
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.class


or set it in svn cmd:

$cd WEB-INF
$svn propset svn:ignore "*" work/

(first arg is the wildcard pattern, second is the path)

to view back any prop set to a path:

$cd WEB-INF
$svn proplist work


To commit your changes:

$svn commit -m 'Some changes...'

Thursday, June 09, 2005

Elinks

If you like lynx, you will love Elinks. It has direct mouse support, frames and tables, menus (even pop up menu), within your text terminal. Oh, did I mention it also supports tabbed browsing? (better than IE6, ha ha...)

Besides Midnight Commandar, this is another cool text (or cli) mode application with good mouse support. Anyone know any others?

Sunday, June 05, 2005

GNU Screen

GNU Screen enables you to work in multiple sessions in single a telnet/ssh sesion. After you have installed it :

- run screen. Now you are presented still in your shell prompt as usual. Ctrl-a c will create another new session.
- Ctrl-a " will list all your session. Use arrow key to select one, enter to goes to that session.
- Ctrl-a A will prompt you a name for the current session.
- Ctrl-a w will shows you some info of all sessions.
- Ctrl-a Ctrl-a toggles between current and previous session.
- Ctrl-a d will detach the curren screen sessions, and goes back to your original shell prompt. In fact if you are in a remote terminal, just close your terminal emulation app will achive the same effect. After detached, screen -ls will list all the detached sessions. screen -r will restore the first one. screen -d -r will try to detach the session, then attach it. (Good for detaching the session from another remote terminal, and steal it to current one). Think about it, it's really handful!
- For help, Ctrl-a ?
- Hint: If you usually set your bash setting in .bash_profile, you can make a symbolic link of .bashrc back to this file. This way, when screen invokes bash, it will read back your profile setting.
- Hint: If you see ~ appearing when pressing backspace key, it means your terminal emulator is setting wrong. For PuTTy, change it to Ctrl-H.

Don't use vim just as vi

Most Linux nowadays comes with vim instead of vi. But many people just keep using vim as vi. (I am one of them, how about you?) Actually when I first met vim, I am excited, and try to learn all those new techniques. But later on, as using GUI editor much more often, I forgot everything. :x

Below are some difference that I think vim really stands out:

0. Visually copy/cut/paste!
- just type v to start visual mode. Then navigate to whereever you want. This will creates a marked block. Just type 'y' for yanking (copy), or 'd' for cut. Move your cursor to elsewhere, then 'p' to paste your text!
- 'V', will start marking lines
- Ctrl-v will start block mode marking!
- During cursor movement, 'o' will move to the other corner of your current cursor
- For block Visual mode, 'O' moves to the other corner, in the same line
- 'gv' highlight back the previous marked area.
- In addition to yank(y) and delete (d), you can also perform change 'c', 'I' for insert, 'A' for append. For block mode, this means you are repeating what you change for the marked areas. Pretty cool.


1. Resizable windows
- To split current session to two horizontal windows, :split
- To jump your cursor location from one to another, Ctrl-w w (or Ctrl-w Ctrl-w)
- To close one of the window created by split, just Ctrl-w c
- The usual jkhl navigation key works as expected, just add Ctrl-w before it. e.g. Ctrl-w j will move your cursor to the window below your current one.
- To create a new window of a new file, :new
- Ctrl-w + (don't just press the '=' for +, you need to add a shift key!) increase your current window by one row. Type a number before Ctrl-w will repeat this action. So 5 Ctrl-w + increases 5 rows. Similarly, Ctrl-w - will decrease by one.
- <N> Ctrl-w _ will set your current window to <N> rows. Ommitting will maximize your current window as large as possible, but still keep other windows there.

2. File browsing
- : edit <filename> (e <filename> will also do) will try open another file. You will be warned if you havent' save your current file. Also note that you can perform filename completion by pressing <Tab> key.
- Even better, for vim 6.x, edit . will brings you the directory listing. The usual vi navigation (jkhl) keys works as expected. You can perform / search. Just press enter for a directory name will navigate to this directory. Pressing enter for a file will start edit this file. 'D' (capital D) will delete the file, don't worry, it will ask you to confirm.
- You can keep editing another files during your session by using :edit , but just you need to save before moving to another. If you don't want to save yet, try :hide edit filename . (type hid instead of hide will also do.)
- Vim keeps a buffer list of all the editing sessions, and assign a number to each buffer. To view all the buffers, :ls When you knows the buffer number, you can switch to this file by :buf <N> (or even just :b <N>). Still , add hid before if you don't want to save for the moment. In the buffer list, '#' means your current session, '+' means modified session.
- Another way to switch between buffer number is <N>Ctrl-^ (press Ctrl-6), where <N> refers to the buffer number.
- To quickly leave all sessions without saving, :qa!

3. text completion
- Ah, this is really cool. Keep pressing Ctrl-N will goes through all possible strings appears in your current session.

4. Tag list
- The Taglist plugin shows all the functions/scope in another window, just like Function Lists in PsPad/Ultraedit. It will also show the buffer list at the top for easier navigation. Cooo...l!

5. Undo/Redo
- You know 'u' will do undo. For vim, you can perform multiple undo <N>u
- The other way round, Ctrl-R perform redo.

5. Insert mode change
- under insert mode, you can move around using cursor, and keep inserting text. No need to type <Esc> i

6. Marks and Jumps
- To create a mark: m[a-zA-Z] lowercase marks will lost when the current file is removed from buffer list. Upper case marks won't.
- To return to marked: either use ' or ` , follows by the marked character. e.g. 'c
- To view the mark list, :marks
- Whenever you perfrom any jumping actions (like ', /, G etc.), a new jump list is created. To view jump list, :jumps
- Use Ctrl-o for to goes up the jump list, use Ctrl-i to goes down the jump list

7. Search/Replace
- To perform global replace, with confirmation :%s/pattern/replacement/gc
where % means perform on all lines, g is multiple time in each line, c means confirm.
- just pressing * will search the word under cursor. g* search for partial match. # search in backward direction, while g# search for partial word in backward direction.

8. Command Line Editing
- To edit another file, :e , then press <TAB>, this will
show the first file in current directory. This is vim word completion. Keep pressing TAB gives you more files in the internal list in forward direction. To get back the reverse direction, Ctrl-P. Press Ctrl-D will show the whole list for overiew.
- For set option, in addition to the option keyword completion, if you TAB after =, vim will even auto complete with the current option value.
- Under command line, you can Ctrl-P to show your command history. After you press at least one time of Ctrl-P, you can use Ctrl-N to go forward the history again.
- q: will open a command line window. The usual jkhl keys works, and you can edit any line. After you have modify any available command line (or just go to the line w/o editing), press enter. Bingo, this command is executed, and the command line window is auto closed.

Misc. Hints
- To scroll your page one line at a time, use Ctrl-Y and Ctrl-E
- change your vim init setting in your ~/.vimrc
- If you use screen with vim, you can change your .bash_profile (or .bashrc) to set TERM=xterm-color. This will allow mouse=a setting to work. FYI, default screen TERM is set to 'screen'.

Saturday, June 04, 2005

CoLinux with Gentoo

Do you wish to have both XP and Linux at the same time with your notebook anytime anywhere? No, I am not talking about virtual machine, which does't have good performance. Thanks to CoLinux! Now I can have the best of both world : XP for my PsPad, Filezilla, and Putty, plus good looking Chinese fonts without any needs of tweaking. And Gentoo Linux for all my web development needs!

I installed CoLinux with Gentoo inside my Libretto U100 (Japanese page). With my Libretto upgraded to 1G RAM, XP and Gentoo live happily together. Gentoo can even run without any problem after my Libretto wakes up from Standby mode. Very cool. :)