Friday, December 19, 2008

Eclipse + ./VM terminated Exit code=1



Solution:

root@svr5:/home/huynhnguyen/workspace/.metadata# cd .plugins/
root@svr5:/home/huynhnguyen/workspace/.metadata/.plugins# ll
total 38
drwxrwxrwx 19 huynhngu wheel 1024 Dec 16 12:32 .
drwxrwxrwx 3 huynhngu wheel 512 Nov 5 2007 ..
drwxrwxrwx 6 huynhngu wheel 512 Dec 16 14:17 org.eclipse.core.resources
drwxrwxrwx 3 huynhngu wheel 512 Nov 5 2007 org.eclipse.core.runtime
drwxrwxrwx 3 huynhngu wheel 512 Nov 5 2007 org.eclipse.debug.core
drwxrwxrwx 2 huynhngu wheel 512 Dec 16 14:15 org.eclipse.debug.ui
drwxrwxrwx 2 huynhngu wheel 512 Nov 5 2007 org.eclipse.help.base
drwxrwxrwx 2 huynhngu wheel 1024 Dec 16 12:43 org.eclipse.jdt.core
drwxrwxrwx 2 huynhngu wheel 512 Nov 5 2007 org.eclipse.jdt.launching
drwxrwxrwx 2 huynhngu wheel 512 Dec 16 12:44 org.eclipse.jdt.ui
drwxrwxrwx 6 huynhngu wheel 512 Dec 16 14:17 org.eclipse.pde.core
drwxrwxrwx 2 huynhngu wheel 512 Dec 16 12:43 org.eclipse.pde.runtime
drwxrwxrwx 2 huynhngu wheel 512 Dec 16 12:41 org.eclipse.pde.ui
drwxr-xr-x 2 huynhngu wheel 512 Dec 16 12:41 org.eclipse.search
drwxrwxrwx 4 huynhngu wheel 512 Nov 5 2007 org.eclipse.tomcat
drwxrwxrwx 2 huynhngu wheel 512 Nov 5 2007 org.eclipse.ui
drwxrwxrwx 2 huynhngu wheel 512 Nov 5 2007 org.eclipse.ui.ide
drwxrwxrwx 2 huynhngu wheel 512 Dec 16 12:34 org.eclipse.ui.workbench
drwxr-xr-x 2 huynhngu wheel 512 Dec 16 12:26 org.eclipse.update.ui
root@svr5:/home/huynhnguyen/workspace/.metadata/.plugins# ll /home/pxtung/workspace/.metadata/.plugins
total 20
drwxr-xr-x 10 pxtung wheel 512 Dec 19 17:03 .
drwxr-xr-x 3 pxtung wheel 512 Dec 19 17:37 ..
drwxr-xr-x 4 pxtung wheel 512 Dec 19 17:03 org.eclipse.core.resources
drwxr-xr-x 3 pxtung wheel 512 Dec 19 17:03 org.eclipse.core.runtime
drwxr-xr-x 2 pxtung wheel 512 Dec 19 17:03 org.eclipse.debug.core
drwxr-xr-x 2 pxtung wheel 512 Dec 19 17:03 org.eclipse.debug.ui
drwxr-xr-x 2 pxtung wheel 512 Dec 19 17:03 org.eclipse.jdt.core
drwxr-xr-x 2 pxtung wheel 512 Dec 19 17:03 org.eclipse.jdt.ui
drwxr-xr-x 2 pxtung wheel 512 Dec 19 17:03 org.eclipse.ui.ide
drwxr-xr-x 2 pxtung wheel 512 Dec 19 17:03 org.eclipse.ui.workbench
root@svr5:/home/huynhnguyen/workspace/.metadata/.plugins# cp /home/huynhnguyen/workspace/.metadata/.plugins /home/pxtung/workspace/.metadata/.plugins
cp: /home/huynhnguyen/workspace/.metadata/.plugins is a directory (not copied).
root@svr5:/home/huynhnguyen/workspace/.metadata/.plugins# cp /home/huynhnguyen/workspace/.metadata/.plugins/* /home/pxtung/workspace/.metadata/.plugins/
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.pde.core is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.ui.workbench is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.ui.ide is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.ui is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.tomcat is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.search is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.pde.ui is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.pde.runtime is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.update.ui is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.jdt.ui is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.jdt.launching is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.jdt.core is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.help.base is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.debug.ui is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.debug.core is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.core.runtime is a directory (not copied).
cp: /home/huynhnguyen/workspace/.metadata/.plugins/org.eclipse.core.resources is a directory (not copied).
root@svr5:/home/huynhnguyen/workspace/.metadata/.plugins# cp -r /home/huynhnguyen/workspace/.metadata/.plugins/* /home/pxtung/workspace/.metadata/.plugins/

eclipse + Could not reserve enough space for object heap

FreeBSD の ports を使って eclipse を作ろうとした。しかし、VM の初期化に失敗して全然先に進まない。
===> Building for eclipse-3.3.2
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
*** Error code 1

Stop in /usr/ports/java/eclipse.
$ make
$ /usr/ports/java/eclipse.

少し問題を追跡したところ、ビルドの為の ant を起動する時に、Java のヒープサイズが大きすぎるのが原因らしい。そこで、-Xmx の値を 1000M から 500M に少なくしたら、問題なくインストールが完了した。


$ vi /ports/tmp/ports/java/eclipse/work/build
#!/bin/sh

#ANT_OPTS=-Xmx1000M; export ANT_OPTS
ANT_OPTS=-Xmx500M; export ANT_OPTS
os=""
ws=""
arch=""

なお、ports をコンパイルしているディレクトリが /ports/tmp なのは、WRKDIRPREFIX=/ports/tmp を /etc/make.conf で設定しているからである。
copy from http://uyota.asablo.jp/blog/2008/09/29/3788262

warning: "YY_MAIN" is not defined

gmake[4]: Entering directory
`/tmp/usr/ports/devel/kdesdk3/work/kdesdk-3.5.10/kbabel/common/libgettext'
flex -+ -opofiles.cc ./pofiles.ll
/bin/sh /usr/local/bin/libtool --silent --tag=CXX --mode=compile
c++ -DHAVE_CONFIG_H -I. -I../../.. -D_THREAD_SAFE -pthread -DQT_THREAD_SUPPORT -I/usr/local/include -I/usr/local/include -I/usr/local/include -D_GETOPT_H -D_THREAD_SAFE -Wno-long-long -Wundef -Wall -W -Wpointer-arith -DNDEBUG -DNO_DEBUG -O2 -O2 -fno-strict-aliasing -pipe -march=nocona -fconserve-space -Wno-non-virtual-dtor -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -MT
pofiles.lo -MD -MP -MF .deps/pofiles.Tpo -c -o pofiles.lo pofiles.cc
pofiles.cc:451:5: warning: "YY_STACK_USED" is not defined
pofiles.cc:1519:5: warning: "YY_MAIN" is not defined
In file included from pofiles.cc:250:
/usr/local/include/FlexLexer.h:130: error: expected unqualified-id before
numeric constant
pofiles.cc: In member function 'virtual int GettextBaseFlexLexer::yylex()':
pofiles.cc:576: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc:732: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc:755: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In
constructor 'GettextBaseFlexLexer::GettextBaseFlexLexer(std::istream*,
std::ostream*)':
pofiles.cc:872: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In destructor 'virtual
GettextBaseFlexLexer::~GettextBaseFlexLexer()':
pofiles.cc:884: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'virtual void
GettextBaseFlexLexer::switch_streams(std::istream*, std::ostream*)':
pofiles.cc:891: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'int
GettextBaseFlexLexer::yy_get_next_buffer()':
pofiles.cc:944: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'void GettextBaseFlexLexer::yyunput(int,
char*)':
pofiles.cc:1139: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'int GettextBaseFlexLexer::yyinput()':
pofiles.cc:1181: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'virtual void
GettextBaseFlexLexer::yyrestart(std::istream*)':
pofiles.cc:1240: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc:1243: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'virtual void
GettextBaseFlexLexer::yy_switch_to_buffer(yy_buffer_state*)':
pofiles.cc:1250: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc:1253: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc:1261: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'void
GettextBaseFlexLexer::yy_load_buffer_state()':
pofiles.cc:1275: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'virtual void
GettextBaseFlexLexer::yy_delete_buffer(yy_buffer_state*)':
pofiles.cc:1312: error: 'yy_current_buffer' was not declared in this scope
pofiles.cc: In member function 'void
GettextBaseFlexLexer::yy_flush_buffer(yy_buffer_state*)':
pofiles.cc:1354: error: 'yy_current_buffer' was not declared in this scope
gmake[4]: *** [pofiles.lo] Error 1
gmake[4]: Leaving directory
`/tmp/usr/ports/devel/kdesdk3/work/kdesdk-3.5.10/kbabel/common/libgettext'
gmake[3]: *** [all-recursive] Error 1
gmake[3]: Leaving directory
`/tmp/usr/ports/devel/kdesdk3/work/kdesdk-3.5.10/kbabel/common'
gmake[2]: *** [all-recursive] Error 1
gmake[2]: Leaving directory
`/tmp/usr/ports/devel/kdesdk3/work/kdesdk-3.5.10/kbabel'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/tmp/usr/ports/devel/kdesdk3/work/kdesdk-3.5.10'
gmake: *** [all] Error 2
*** Error code 2

from links the answer from Jason Hale

Solution:

This is a known problem with flex and kdesdk. See the following thread on the kde-freebsd mailing list: http://mail.kde.org/pipermail/kde-fr...er/003894.html
You can try to apply the following patch to the textproc/flex port: http://mail.kde.org/pipermail/kde-fr...ttachment.diff

# cd /usr/port/textproc/flex
#patch < /path/to/patch #pkg_delete -fx flex #make install clean

Alternatively, just build KDE without kdesdk.
Reply With Quote

vncserver + timeout

vncserver + Timeout

Solution:
Add IdleTimeout option to command
su user -c "vncserver :#display IdleTimeout=0"

Pango not found. Pango built with Cairo support

gnome-config: not found
checking Pango flags... gnome-config: not found
configure: error:
*** Pango not found. Pango built with Cairo support is required
*** to build GTK+. See http://www.pango.org for Pango information.


Solution:
It seems pango doesn't find cairo.
Do you have this line in pango/Makefile?
BUILDLINK_API_DEPENDS.cairo+= cairo>=1.2.2

Thursday, December 18, 2008

/libexec/ld-elf.so.1: Shared object "libaudio.so.2" not found, required by "libqt-mt.so.3"

Warning: connect() failed: : No such file or directory
/libexec/ld-elf.so.1: Shared object "libaudio.so.2" not found, required by "libqt-mt.so.3"
FreeFontPath: FPE "/usr/X11R6/lib/X11/fonts/misc/" refcount is 2, should be 1; fixing.
/libexec/ld-elf.so.1: Shared object "libaudio.so.2" not found, required by "libqt-mt.so.3"
startkde: Shutting down...
Warning: connect() failed: : No such file or directory


Solution:
cd /usr/ports/audio/nas
make install clean

Wednesday, December 17, 2008

Could not reserve enough space for object heap

===> diablo-jdk-1.5.0.07.01_13 depends on file: /usr/local/libdata/pkgconfig/xtst.pc - found
Updating time zones...Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
*** Error code 1

Stop in /usr/ports/java/diablo-jdk15.
*** Error code 1

Stop in /usr/ports/java/diablo-jdk15.
root@svr5:/usr/ports/java/diablo-jdk15#


Solution:
install without tzupdate

Thursday, December 11, 2008

relabel files + dirs + selinux

Four main commands are used to relabel file-related objects: chcon(8), restorecon(8),setfiles(8), and fixfiles(8). All these commands relabel files, but they each have a specific use. Typically, chcon and restorecon are used for small labeling changes, whereas setfiles and fixfiles are used for larger changes.

The chcon command sets the same security context, or a portion of a security context, for one or more files based on user input. It is the most basic labeling command and its use is analogous to chmod(1). For instance, consider the following example:

$ mkdir public_html
$ ls -dZ public_html/
drwxrwxr-x joe joe joe:object_r:user_home_dir_t public_html/
$ chcon -t httpd_user_content_t public_html/
$ ls -dZ public_html/
drwxrwxr-x joe joe joe:object_r:httpd_user_content_t public_html/

In this example, we changed the security context of a newly created directory, which was automatically assigned the security context joe:object_r:user_home_dir_t, to joe:object_r:httpd_user_content_t. The -t option alone specifies that the type of file should be changed while the rest of the security context is retained.

The restorecon command is similar to chcon but sets the security context of file-related objects based on the default file context files for the current policy. The user, therefore, does not specify a security context. Instead, restorecon matches the filename with an entry in the file contexts files and applies the specified security context. In some sense, it is restoring the correct security context. For example, consider the following:

$ mkdir public_html
$ ls -Zd public_html/
drwxrwxr-x joe joe joe:object_r:user_home_dir_t public_html/
$ /sbin/restorecon public_html/
$ ls -Zd public_html/
drwxrwxr-x joe joe user_u:object_r:httpd_user_content_t public_html/

This example is functionally the same as the previous example using chcon but only because the file context files for this policy has the following entry:

/home/[^/]*/public_html(/.+)? user_u:object_r:httpd_user_content_t

The file context entry specifies that directories in user home directories named public_html/ should be labeled user_u:object_r:httpd_user_content_t.

We can also use the restorecon command to check whether the labels on file-related objects match the specification in the file contexts files. For example:

$ mkdir public_html
$ /sbin/restorecon -nv public_html/
/sbin/restorecon reset /home/joe/public_html context
joe:object_r:user_home_dir_t->user_u:object_r:httpd_user_content_t

Thursday, December 4, 2008

history command

Làm chủ command history trên Linux

Posted by dongthao on August 18, 2008 http://kythuatmaytinh.wordpress.com

Khi bạn thường xuyên sử dụng dòng lệnh trên Linux, kĩ năng dùng history hiệu quả sẽ giúp bạn tăng hiệu suất công việc lên rất nhiều. 15 ví dụ sau đây giúp bạn thấy sử dụng dòng lệnh thú vị và hiệu quả như thế nào.

1. Hiển thị thời điểm với HISTTIMEFORMAT

Thông thường khi bạn gõ “history” vào dòng lệnh, nó sẽ hiển thị số thứ tự và lệnh đó, chẳng hạn:

t3318@honey:~$ history
2 ./configure
3 sudo apt-get install gettext
4 ./configure
5 gmcs
6 sudo apt-get install mono-gmcs
7 ./configure
8 make
9 make install

Để theo dõi hiệu quả hơn, ta có thể hiển thị thời điểm kèm theo như ví dụ sau đây:

t3318@honey:~$ export HISTTIMEFORMAT=’%F %T’

t3318@honey:~$ history | more

5 2008-08-18 13:04:06gmcs

6 2008-08-18 13:04:06sudo apt-get install mono-gmcs

7 2008-08-18 13:04:06./configure

8 2008-08-18 13:04:06make

9 2008-08-18 13:04:06make install

10 2008-08-18 13:04:06sudo make install

2. Tìm kiếm trên history bằng Control+R

Chắc chắn chức năng này sẽ rất hữu ích. Khi bạn vừa thực hiện xong một lệnh rất dài, bạn có thể tìm kiếm trong history một cách đơn giản bằng một từ khoá và thực hiện lại y chang lệnh đó mà không cần phải gõ lại từ đầu. Hãy nhấn Control+R and type the keyword.

Trong ví dụ sau, tôi giả sử muốn tìm lại URL của một đoạn video youtube đã lấy về bằng youtube-dl. Tôi tìm chữ “you”, và kết quả như sau:

# [Nhấn Ctrl+R từ dấu nhắc lệnh sẽ hiện ra như sau]

(reverse-i-search)`you’: youtube-dl -g “http://www.youtube.com/watch?v=YuppZpVNpiA”

[Nhấn Enter khi bạn thấy lệnh mình muốn xuất hiện và nó sẽ được thực hiện]

t3318@honey:~$ youtube-dl -g “http://www.youtube.com/watch?v=YuppZpVNpiA”

http://lax-v195.lax.youtube.com/get_video?video_id=

YuppZpVNpiA&signature=B740C32BDF978EE6AFE62344948C59

Đôi khi bạn lại muốn hiệu chỉnh một một lệnh từ history trước khi thực hiện nó. Bạn chỉ cần sử dụng phím mũi tên sang trái hoặc sang phải khi kết quả tìm kiếm xuất hiện để chỉnh sửa, sau đó nhấn Enter để thực thi lệnh.

3. Lặp lại lệnh trước đó một cách nhanh chóng theo 4 cách

  1. Dùng mũi tên lên để tìm lệnh trước đó rồi nhấn enter để thực thi
  2. !! rồi nhấn enter
  3. !-1 rồi nhấn enter
  4. Nhấn Control+P để hiển thị lệnh ngay trước đó rồi nhấn enter để thực thi (nhấn Control+P nhiều lần sẽ giống như dùng mũi tên lên)

4. Thực hiện một lệnh xác định từ history

Giả sử bạn muốn lặp lại lệnh số 10, hãy gõ !10 như ví dụ sau:

t3318@honey:~$ history | more

10 2008-08-18 13:04:06sudo make install

11 2008-08-18 13:04:06cd

12 2008-08-18 13:04:06cd .mozilla-thunderbird/q0d4500j.default/extensions/

13 2008-08-18 13:04:06ls

14 2008-08-18 13:04:06cd ..

15 2008-08-18 13:04:06ls

t3318@honey:~$ !12

cd .mozilla-thunderbird/q0d4500j.default/extensions/

t3318@honey:~/.mozilla-thunderbird/q0d4500j.default/extensions$

5. Thực thi lệnh trước đó bắt đầu với một chữ xác định

Gõ ! tiếp theo là vài chữ bắt đầu của lệnh mà bạn muốn thực hiện lại.

t3318@honey:~$ !y

youtube-dl -g “http://www.youtube.com/watch?v=YuppZpVNpiA”

http://lax-v195.lax.youtube.com/get_video?video_id=YuppZpVNpiA&signa…

6. Thiết lập tổng số lệnh lưu trong history bằng HISTSIZE

Thêm hai dòng sau vào file .bash_profile sau đó đăng nhập lại vào shell để thay đổi có hiệu lực. Ví dụ ta muốn history chứa 450 lệnh

HISTSIZE=450
HISTFILESIZE=450

7. Đổi tên file history bằng HISTFILE

Mặc định, history được lưu trong file /.bash_history. Hãy thêm dòng sau vào file .bash_profile và đăng nhập lại shell, để lưu các lệnh trong history vào file .commandline_store thay vì .bash_history. Nếu bạn chưa biết thủ thuật này dùng để làm gì, thì theo dõi các lệnh thực thi trên nhiều terminal khác nhau bằng nhiều file history khác nhau là một trường hợp ví dụ.

HISTFILE=/root/.commandline_warrior

8. Loại bỏ các dòng trùng nhau liên tiếp trong history bằng HISTCONTROL

Chạy lệnh sau trước khi dùng lệnh history:

t3318@honey:~$ export HISTCONTROL=ignoredups

9.Loại bỏ các dòng trùng nhau trong toàn bộ history bằng HISTCONTROL

Thao tác ignoredups ở trên chỉ loại bỏ các dòng trùng nhau khi chúng nằm liên tiếp. Để bỏ các dòng trùng trong toàn bộ history ta thiết lập như sau:

t3318@honey:~$ export HISTCONTROL=erasedups

10. Không cho history lưu lại 1 lệnh cụ thể bằng HISTCONTROL

Khi thực thi một lệnh, bạn có thể cho history bỏ qua lệnh đó bằng cách thiết lập HISTCONTROL ở chế độ ignorespace VÀ gõ một khoảng trắng phía trước lệnh đó

t3318@honey:~$ export HISTCONTROL=ignorespace
t3318@honey:~$ pwd
t3318@honey:~$ ls
t3318@honey:~$ rm -rf new.pls [có khoảng trắng trước rm]
t3318@honey:~$ history | tail -3
527 2008-08-18 14:37:12pwd
528 2008-08-18 14:37:37ls
529 2008-08-18 14:38:17history | tail -3

11. Xoá tất cả các history trước đó bằng tùy chọn -c

Sometime you may want to clear all the previous history, but want to keep the history moving forward.

t3318@honey:~$ history -c

t3318@honey:~$ history

31 2008-08-18 14:40:42history

12. Điền tham số thích hợp từ các lệnh trong history

Khi tìm kiếm trong history, bạn có thể muốn thực thi một lệnh khác nhưng dùng cùng các tham số như là một lệnh vừa tìm ra trong history.

Trong ví dụ sau, kí hiệu !!:$ theo sau vim sẽ lấy tham số của lệnh trước đó làm tham số cho lệnh hiện thời:

t3318@honey:~$ ls postfix-large-fs.patch
postfix-large-fs.patch
t3318@honey:~$ vim !!:$
vim postfix-large-fs.patch

Còn trong ví dụ này, kí hiệu !^ theo sau lệnh vim lấy tham số đầu tiên của lệnh trước đó (trường hợp có nhiều tham số) làm tham số cho lệnh hiện thời

t3318@honey:~$ ls postfix-large-fs.patch sources.list_hardy
postfix-large-fs.patch sources.list_hardy
t3318@honey:~$ vim !^
vim postfix-large-fs.patch

13. Điền một tham số cụ thể từ một lệnh cụ thể

Trong ví dụ sau, !cp:2 tìm kiếm những lệnh trong history bắt đầu bằng cp và lấy tham số thứ hai sau đó điền vào ls -l

t3318@honey:~$ cp sources.list_hardy /home/t3318/Documents/New/sources.list
t3318@honey:~$ ls -l !cp:2
ls -l /home/t3318/Documents/New/sources.list
-rw-r–r– 1 t3318 t3318 292 2008-08-18 15:02 /home/t3318/Documents/New/sources.list

Còn ở ví dụ sau, !cp:$ tìm những lệnh bắt đầu với cp và lấy tham số cuối cùng (cũng là tham số thứ 2 của lệnh cp ở trên)

t3318@honey:~$ ls -l !cp:$
ls -l /home/t3318/Documents/New/sources.list
-rw-r–r– 1 t3318 t3318 292 2008-08-18 15:02 /home/t3318/Documents/New/sources.list

14. Tắt history bằng HISTSIZE

Nếu bạn không muốn lưu lại bất kỳ lệnh gì, hãy thiết lập HISTSIZE bằng 0

t3318@honey:~$ export HISTSIZE=0
t3318@honey:~$ history
t3318@honey:~$

15. Loại bỏ những lệnh xác định ra khỏi history bằng HISTIGNORE

Đôi khi bạn không muốn bị nhiễu khi tìm history bởi quá nhiều lệnh “pwd” hay “ls”. Use HISTIGNORE để xác định tất cả các lệnh bạn muốn loại khỏi history. Lưu ý là thêm lệnh ls vào HISTIGNORE sẽ chỉ loại “ls”‘ chứ không phải “ls -l”. Bạn phải cung cấp lệnh đầy đủ cả tham số nếu cần.

t3318@honey:~$ export HISTIGNORE=”pwd:ls:ls -ltr:”

Wednesday, December 3, 2008

install g++ + centos

How to Install g++ on CentOS 4 and CentOS 5

g++ is often necessary for building various packages. But It’s quite hard to install it in CentOS if you don’t know a simple thing: yum install g++ will not work here. yum install compat-g++and yum install gcc-g++ won’t give any result too. The only command for yum to install g++ on CentOS is the following:

yum install gcc-c++

You might also want to install it with some more useful packages. Then your command will be:

yum install gcc-c++ compat-gcc-32 compat-gcc-32-c++

Hope this helps you to install g++ under CentOSAddThis

rsync + centos

Setup rsync server on CentOS

Step-by-step installation and configuration rsync server on CentOS
From transamrit.net
  • Make sure xinetd and rsync is available, if not type
    # yum -y install rsync xinetd
  • Add xinetd service to system
    # chkconfig --add xinetd
  • Make sure xinetd running on init 3 and 5
    # chkconfig --list xinetd
  • Enable rsync
    # vi /etc/xinetd.d/rsync
    Change disable = yes into disable = no
  • Create username and password for rsync client to use
    # vi /etc/rsyncd.secrets
    adminname:hispassword
  • Create configuration and shares for rsync daemon
    # vi /etc/rsyncd.conf
    max connections = 2
    log file = /var/log/rsync.log
    timeout = 300

    [shares]
    comment = shared data stored here
    path = /home/adminname/shares
    read only = false # chg to true if you want read only
    list = yes
    uid = adminname
    gid = adminname
    auth users = adminname
    secrets file = /etc/rsyncd.secrets
    hosts allow = 10.10.105.0/24
  • Secure /etc/rsyncd.*
    # chown root.root /etc/rsyncd.*
    # chmod 600 /etc/rsyncd.*
  • Restart xinetd
    # service xinetd restart
  • Make sure rsync now running
    # chkconfig --list
  • Perhaps you also want to enable port 873 tcp and udp on your firewall so other can connect to your server

Tuesday, December 2, 2008

rsync over ssh

rsync -avzr -e ssh root@src:/ dest

Option:
a = archive
z = compress
--exclude=".*/" # excluded hidden file or hidden directory
r = recursive directory
e = over ssh
vv verbose
--delete = xoa cac file co tren dest ma ko co tren src
-u, --update skip files that are newer on the receiver