Shell 自动补全

1) /etc/passwd

It shows like this

in format of

Make sure the Command/shell is the “/bin/bash” and not the “/bin/sh” which may be the default value.

2) $HOME$/.bashrc or /etc/bash.bashrc
Make sure the code blew is not commented out.

3) Reference
http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/

使用密钥自动登录SSH(更新ssh-copy-id)

【更新】
lyxint提醒,发现了ssh-copy-id命令,第二步可以更简单的实现
ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname
其中username为用户名,hostname为服务器\VPS的IP\地址

1)在本机生成公钥密钥
ssh-keygen -t rsa
一路回车,选择默认路径即可,默认路径为~/.ssh/

2)将本地公钥上传至服务器
cat ~/.ssh/id_rsa.pub|ssh username@hostname ‘sh -c “cat – >>~/.ssh/authorized_keys”‘
其中username为用户名,hostname为服务器\VPS的IP\地址

3)ssh设置文件的几点说明(一般是默认即可)
路径:/etc/ssh/sshd_config
相关行:
PubkeyAuthentication yes #开启公钥验证
#AuthorizedKeysFile %h/.ssh/authorized_keys #公钥的位置,建议使用默认路径

Android平台下FreePascal的交叉编译器

0) Preface
0.1) The Operating System is Ubuntu 10.10
0.2) All the softwares are the latest stable version by April 12, 2011

1) Download the Source of Free Pascal Compiler
The ‘fpc-2.4.2.source.tar.gz’ on http://sourceforge.net/projects/freepascal/files/Source/2.4.2/

2) Install the fpc-source. Just extract it.
The root folder of fpc-source for me is ‘/home/victorhu/fpc-source’

3) Download the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
The ‘IA32 GNU/Linux Installer’ on http://www.codesourcery.com/sgpp/lite/arm/portal/release1600

4) Install the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
The installation need the system shell to be bash not dash which is default for Ubuntu. So
4.1)

Choose NO to make the bash as the system shell.
4.2) Goto the root folder of Arm-Eabi for me is ‘/home/victorhu/toolchain/’
4.3)

4.4)

5) Get the Cross Compiler
5.1) Goto the root folder of fpc-source
5.2)

5.3) The ‘ppcrossarm’ under ‘/home/victorhu/fpc-source/compilers/’ is just what we want.
Note: CROSSBINDIR is depend on the folder of Arm-Eabi.

6) Write a Hello Word in Pascal
The path for me is /home/victorhu/hello.pas
[pascal]
Program hello;
begin
writeln(‘Hello World!’);
end.
[/pascal]

7) Compile the Hello World in Pascal via CrossCompile Environment.
7.1) Goto the folder contains ‘ppcrossarm’
7.2)

Note: -Fu is the unit path, -FD is the compiler utilities path.
7.3) The ‘hello’ under ‘/home/victorhu/temp’ is just the what we want (not hello.pas).

8) Test the Crosscompiled Hello World in Android Emulator
8.1) the tools under Android SDK or the ADT of Eclipse is where we can find it.
8.2) Goto the adb root folder under Android SDK .
It’s ‘platform-tools’ under the main root folder of Android SDK now while it’s ‘tools’ before.
8.3) Test whether is device is connected.

If it shows somthing like ‘Emulator-5544 device’ (for me), then it’s right.
8.4) Push the program into Android Emulator.

8.5) Run the program on the Android Emulator.

If it shows ‘Hello World!’ (the result of the original program), then everything is done now!

9) Reference
9.1) http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/
9.2) http://wiki.freepascal.org/Android_Interface
9.3) http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM

P.S.本文参与“第二届 Google 暑期大学生博客分享大赛 – 2011 Android 成长篇”,感谢大家支持