Skip navigation.

西邮Linux兴趣小组

Linux, Clocks, and Time

, ,

文章来源:http://www.linuxsa.org.au/tips/time.html

Introduction

This document explains how to set your computer's clock from Linux, how to set your timezone, and other stuff related to Linux and how it does its time-keeping.

Your computer has two timepieces; a battery-backed one that is always running (the ``hardware'', ``BIOS'', or ``CMOS'' clock), and another that is maintained by the operating system currently running on your computer (the ``system'' clock). The hardware clock is generally only used to set the system clock when your operating system boots, and then from that point until you reboot or turn off your system, the system clock is the one used to keep track of time.

On Linux systems, you have a choice of keeping the hardware clock in UTC/GMT time or local time. The preferred option is to keep it in UTC because then daylight savings can be automatically accounted for. The only disadvantage with keeping the hardware clock in UTC is that if you dual boot with an operating system (such as DOS) that expects the hardware clock to be set to local time, the time will always be wrong in that operating system.

Setting your timezone

The timezone under Linux is set by a symbolic link from /etc/localtime[1] to a file in the /usr/share/zoneinfo[2] directory that corresponds with what timezone you are in. For example, since I'm in South Australia, /etc/localtime is a symlink to /usr/share/zoneinfo/Australia/South. To set this link, type:
ln -sf ../usr/share/zoneinfo/your/zone /etc/localtime

Replace your/zone with something like Australia/NSW or Australia/Perth. Have a look in the directories under /usr/share/zoneinfo to see what timezones are available.

[1] This assumes that /usr/share/zoneinfo is linked to /etc/localtime as it is under Red Hat Linux.

[2] On older systems, you'll find that /usr/lib/zoneinfo is used instead of /usr/share/zoneinfo. See also the later section ``The time in some applications is wrong''.

Setting UTC or local time

When Linux boots, one of the initialisation scripts will run the /sbin/hwclock program to copy the current hardware clock time to the system clock. hwclock will assume the hardware clock is set to local time unless it is run with the --utc switch. Rather than editing the startup script, under Red Hat Linux you should edit the /etc/sysconfig/clock file and change the ``UTC'' line to either ``UTC=true'' or ``UTC=false'' as appropriate.

Setting the system clock

To set the system clock under Linux, use the date command. As an example, to set the current time and date to July 31, 11:16pm, type ``date 07312316'' (note that the time is given in 24 hour notation). If you wanted to change the year as well, you could type ``date 073123161998''. To set the seconds as well, type ``date 07312316.30'' or ``date 073123161998.30''. To see what Linux thinks the current local time is, run date with no arguments.

Setting the hardware clock

To set the hardware clock, my favourite way is to set the system clock first, and then set the hardware clock to the current system clock by typing ``/sbin/hwclock --systohc'' (or ``/sbin/hwclock --systohc --utc'' if you are keeping the hardware clock in UTC). To see what the hardware clock is currently set to, run hwclock with no arguments. If the hardware clock is in UTC and you want to see the local equivalent, type ``/sbin/hwclock --utc''

The time in some applications is wrong

If some applications (such as date) display the correct time, but others don't, and you are running Red Hat Linux 5.0 or 5.1, you most likely have run into a bug caused by a move of the timezone information from /usr/lib/zoneinfo to /usr/share/zoneinfo. The fix is to create a symbolic link from /usr/lib/zoneinfo to /usr/share/zoneinfo: ``ln -s ../share/zoneinfo /usr/lib/zoneinfo''.

Summary

* /etc/sysconfig/clock sets whether the hardware clock is stored as UTC or local time.

* Symlink /etc/localtime to /usr/share/zoneinfo/... to set your timezone.

* Run ``date MMDDhhmm'' to set the current system date/time.

* Type ``/sbin/hwclock --systohc [--utc]'' to set the hardware clock.

Other interesting notes

The Linux kernel always stores and calculates time as the number of seconds since midnight of the 1st of January 1970 UTC regardless of whether your hardware clock is stored as UTC or not. Conversions to your local time are done at run-time. One neat thing about this is that if someone is using your computer from a different timezone, they can set the TZ environment variable and all dates and times will appear correct for their timezone.

If the number of seconds since the 1st of January 1970 UTC is stored as an signed 32-bit integer (as it is on your Linux/Intel system), your clock will stop working sometime on the year 2038. Linux has no inherent Y2K problem, but it does have a year 2038 problem. Hopefully we'll all be running Linux on 64-bit systems by then. 64-bit integers will keep our clocks running quite well until aproximately the year 292271-million.

Other programs worth looking at

* rdate - get the current time from a remote machine; can be used to set the system time.

* xntpd - like rdate, but it's extremely accurate and you need a permanent 'net connection. xntpd runs continuously and accounts for things like network delay and clock drift, but there's also a program (ntpdate) included that just sets the current time like rdate does.

Further information

* date(1)

* hwclock(8)

* /usr/doc/HOWTO/mini/Clock

(转)vim 次常用指令列表

这里列举了vim次常用的指令,供中级vim爱好者参考。常用的指令过于简单,这里没有列举的必要。而不常用的指令列出来又没有意义。vim的使用一般只掌握到中级水平就够了。

光标移动:
===========================================
0 行首
^ 非空的行首
$ 行尾

gg 文档开头
G 文档结尾

% 匹配项,比如光标在'{'上时按%跳转到'}'
( 句首
) 句为
{ 段首
} 段尾

n| 行内第n个字符
nG 第n行

w 下一个字
b 后一个字

模式转换
========================================
R 替换模式
cc 替换整行
cw 替换字
c$ 替换到行尾
c^或者c0 替换到行首
s 插入式替换
u undo
U undo all
Ctrl+r redo

:ce(nter) 本行居中
:ri(ght) 本行靠右
:le(ft) 本行靠左
gqip 段重排
gqq 行重排

复制
======================================
yy
2yy
y^
y$
yw
y2w
yG 复制至挡尾
p 贴到游标后
P 贴到游标前
registers 察看缓冲区的内容
"ayy 复制本行到命名缓冲区a
"ap 贴上a缓冲区内容
5"ayy 拷贝5行到a缓冲区
3"Ayy 再追加3行到a缓冲区

. 重复执行上次指令

查找
=======================================
/ Find forward
? Find backward
n Find continue forward
N Find continue backward

* 查找当前游标单词
# 向上查找当前游标单词
g* 同*,但是部分匹配也可
g# 同#,但是部分匹配也可

替换
=====================================
:[range]s/pattern/string/[c,e,g,i]
c 替换前确认
e 不显示error
g 整行替换
i 不区分大小写
%代表range时表示整篇文章

书签
=======================================
mx 做书签,x代表26个英文字母
`x 回到书签位置
'x 回到书签所在位置的行首
'0 前一次编辑档的最后离开位置
'1 第二次编辑档的最后离开位置
:marks 获取所有书签

文档打开操作
========================================
vim + filename To the end of file
vim +n filename To the nth line of file
vim +/regexpr filename To the first matching line

多文档操作
========================================
对于以 argument list打开的多个文件
:n Next file
:2n Next two file
:N Previous file

通用的操作方法
:e filename 开启一个文档编辑
:e# or Ctrl-^ 编辑前一个档案

:r filename 在光标所在位置插入文件
:35 r filename 在第35行插入文件

运行外部命令
===========================================
:!cmd
:!! 运行上一次运行的命令
:sh 切换到shell
:r !cmd 把命令运行结果插入到当前位置

[C代码示例]mmap的使用和Linux下的错误处理

, ,

下面一段代码的作用是用mmap实现文件的拷贝,它可以给你演示mmap的使用,同时也告诉你在Linux上如何正确有效地处理错误。(代码可以在这里下载:http://wangcong.org/src/mmcpy.c

读完这段代码,请试着回答后面的几个问题。
/*
 * Copyright (C) WANG Cong, Apr. 2007.
 * GPLv2 applies.
 */
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
int infd, outfd;
void *from, *to;
struct stat infstat;
int ret = 0;
if(argc != 3){
fprintf(stderr, "Bad usage!\n");
ret = -1;
goto fail;
}
infd = open(argv[1], O_RDWR| O_CREAT, 0600);
if(infd == -1){
perror("Open failed");
ret = -1;
goto fail;
}
outfd = open(argv[2], O_RDWR| O_CREAT, 0600);
if(outfd == -1){
perror("Open failed");
ret = -1;
goto close_fail1;
}
if(fstat(infd, &infstat)){
perror("fstat failed");
ret = -1;
goto close_fail2;
}
if(lseek(outfd, infstat.st_size-1, SEEK_SET) == (off_t) -1){
perror("lseek failed");
ret = -1;
goto close_fail2;
}
if(write(outfd, "", 1) != 1){
perror("write failed");
ret = -1;
goto close_fail2;
}
if(lseek(outfd, 0, SEEK_SET) == (off_t) -1){
perror("lseek failed");
ret = -1;
goto close_fail2;
}
from = mmap(0, (size_t)infstat.st_size, PROT_READ,  MAP_PRIVATE | MAP_NORESERVE, infd, 0);
if(from == (void*) -1){
perror("mmap failed");
ret = -1;
goto close_fail2;
}
to = mmap(0, (size_t)infstat.st_size, PROT_WRITE, MAP_SHARED, outfd, 0);
if(to == (void*) -1){
perror("mmap failed");
ret = -1;
goto unmap_fail1;
}
memcpy(to, from, infstat.st_size);
if( -1 == msync(to, (size_t)infstat.st_size, MS_SYNC)){
perror("msync failed");
ret = -1;
}
if (-1 == munmap(to, infstat.st_size)){
perror("munmap failed");
ret = -1;
}

unmap_fail1:
if( -1 == munmap(from, infstat.st_size)){
perror("munmap failed");
ret = -1;
}

close_fail2:
if( -1 == close(outfd)){
perror("close failed");
ret = -1;
}

close_fail1:
if( -1 == close(infd)){
perror("close failed");
ret = -1;
}
fail:
exit(ret);
}
问题:
1. mmap利用了操作系统中的什么原理?
2. 我们知道好的程序应该避免goto的使用,这里的goto没有问题吗?
3. 为什么这种情况下goto比单纯的return要更好?
4. 这种情况下的错误处理有什么特点?

GNOME 操作快捷键

,

Alt+F1 打开开始菜单
Alt+F2 打开运行对话框
Print Screen 整个桌面截图
Alt+Print Screen 当前窗口截图
Ctrl+Alt+Arrow keys 在不同工作区跳转
Ctrl+Alt+D 显示桌面
Alt+Tab 不同的窗口之间跳转
Ctrl+Alt+Tab 在不同窗口之间跳转,含启动工具栏,Shift可反向
Alt+F4 关闭当前窗口
Alt+F5 恢复当前窗口,如果它被最大化的话
Alt+F8 改变当前窗口大小,方向键操作大小
Alt+F9 最小化当前窗口
Alt+F10 最大化当前窗口
Alt+Spacebar 打开窗口菜单
Shift+Ctrl+Alt+Arrow keys 把当前窗口移到别的工作区
Shift+F10 打开上下文菜单

Converting Between Unicode and Plain Strings

,

文章来源:
http://koria.blog.hexun.com/8514590_d.html

1.1. 问题 Problem

You need to deal with data that doesn't fit in the ASCII character set.

你需要处理不适合用ASCII字符集表示的数据.

1.2. 解决 Solution

Unicode strings can be encoded in plain strings in a variety of ways, according to whichever encoding you choose:

Unicode字符串可以用多种方式编码为普通字符串, 依照你所选择的编码(encoding):

1 #将Unicode转换成普通的Python字符串:"编码(encode)"
2 unicodestring = u"Hello world"
3 utf8string = unicodestring.encode("utf-8")
4 asciistring = unicodestring.encode("ascii")
5 isostring = unicodestring.encode("ISO-8859-1")
6 utf16string = unicodestring.encode("utf-16")
7
8
9 #将普通的Python字符串转换成Unicode: "解码(decode)"
10 plainstring1 = unicode(utf8string, "utf-8")
11 plainstring2 = unicode(asciistring, "ascii")
12 plainstring3 = unicode(isostring, "ISO-8859-1")
13 plainstring4 = unicode(utf16string, "utf-16")
14
15 assert plainstring1==plainstring2==plainstring3==plainstring4

1.3. 讨论 Discussion

If you find yourself dealing with text that contains non-ASCII characters, you have to learn about Unicode梬hat it is, how it works, and how Python uses it.

如果你发现自己正在处理包含非ASCII码字符的文本, 你必须学习Unicode,关于它是什么,如何工作,而且Python如何使用它。

Unicode is a big topic.Luckily, you don't need to know everything about Unicode to be able to solve real-world problems with it: a few basic bits of knowledge are enough.First, you must understand the difference between bytes and characters.In older, ASCII-centric languages and environments, bytes and characters are treated as the same thing.Since a byte can hold up to 256 values, these environments are limited to 256 characters.Unicode, on the other hand, has tens of thousands of characters.That means that each Unicode character takes more than one byte, so you need to make the distinction between characters and bytes.

Unicode是一个大的主题。幸运地,你并不需要知道关于Unicode码的每件事,就能够用它解决真实世界的问题: 一些基本知识就够了。首先,你得了解在字节和字符之间的不同。原先,在以ASCII码为中心的语言和环境中,字节和字符被当做相同的事物。由于一个字节只能有256个值,这些环境就受限为只支持 256个字符。Unicode码,另一方面,有数万个字符,那意谓着每个Unicode字符占用多个字节,因此,你需要在字符和字节之间作出区别。

Standard Python strings are really byte strings, and a Python character is really a byte.Other terms for the standard Python type are "8-bit string" and "plain string.",In this recipe we will call them byte strings, to remind you of their byte-orientedness.

标准的Python字符串确实是字节字符串,而且一个Python字符真的是一个字节。换个术语,标准的 Python字符串类型的是 "8位字符串(8-bit string)"和"普通字符串(plain string)". 在这一份配方中我们把它们称作是字节串(byte strings), 并记住它们是基于字节的。

Conversely, a Python Unicode character is an abstract object big enough to hold the character, analogous to Python's long integers.You don't have to worry about the internal representation;the representation of Unicode characters becomes an issue only when you are trying to send them to some byte-oriented function, such as the write method for files or the send method for network sockets.At that point, you must choose how to represent the characters as bytes.Converting from Unicode to a byte string is called encoding the string.Similarly, when you load Unicode strings from a file, socket, or other byte-oriented object, you need to decode the strings from bytes to characters.

相反地,一个Python Unicode码字符是一个大到足够支持(Unicode)字符的一个抽象对象, 类似于Python中的长整数。 你不必要为内在的表示担忧; 只有当你正在尝试把它们传递给给一些基于字节的函数的时候,Unicode字符的表示变成一个议题, 比如文件的write方法或网络套接字的send 方法。那时,你必须要选择该如何表示这些(Unicode)字符为字节。从Unicode码到字节串的转换被叫做编码。同样地,当你从文件,套接字或其他的基于字节的对象中装入一个Unicode字符串的时候,你需要把字节串解码为(Unicode)字符。

There are many ways of converting Unicode objects to byte strings, each of which is called an encoding.For a variety of historical, political, and technical reasons, there is no one "right" encoding.Every encoding has a case-insensitive name, and that name is passed to the decode method as a parameter. Here are a few you should know about:

将Unicode码对象转换成字节串有许多方法, 每个被称为一个编码(encoding)。由于多种历史的,政治上的,和技术上的原因,没有一个 "正确的"编码。每个编码有一个大小写无关的名字,而且那一个名字被作为一个叁数传给解码方法。这里是一些你应该知道的:

* The UTF-8 encoding can handle any Unicode character.It is also backward compatible with ASCII, so a pure ASCII file can also be considered a UTF-8 file, and a UTF-8 file that happens to use only ASCII characters is identical to an ASCII file with the same characters.This property makes UTF-8 very backward-compatible, especially with older Unix tools.UTF-8 is far and away the dominant encoding on Unix.It's primary weakness is that it is fairly inefficient for Eastern texts.
* UTF-8 编码能处理任何的Unicode字符。它也是与ASCII码向后兼容的,因此一个纯粹的ASCII码文件也能被考虑为一个UTF-8 文件,而且一个碰巧只使用ASCII码字符的 UTF-8 文件和拥有同样字符的ASCII码文件是相同的。这个特性使得UTF-8的向后兼容性非常好,尤其使用较旧的 Unix工具时。UTF-8 无疑地是在 Unix 上的占优势的编码。它主要的弱点是对东方文字是非常低效的。
* The UTF-16 encoding is favored by Microsoft operating systems and the Java environment.It is less efficient for Western languages but more efficient for Eastern ones.A variant of UTF-16 is sometimes known as UCS-2.
* UTF-16 编码在微软的操作系统和Java环境下受到偏爱。它对西方语言是比较低效,但对于东方语言是更有效率的。一个 UTF-16 的变体有时叫作UCS-2 。
* The ISO-8859 series of encodings are 256-character ASCII supersets.They cannot support all of the Unicode characters;they can support only some particular language or family of languages.ISO-8859-1, also known as Latin-1, covers most Western European and African languages, but not Arabic.ISO-8859-2, also known as Latin-2,covers many Eastern European languages such as Hungarian and Polish.
* ISO-8859编码系列是256个字符的ASCII码的超集。他们不能够支援所有的Unicode码字符; 他们只能支援一些特别的语言或语言家族。ISO-8859-1, 也既Latin-1,包括大多数的西欧和非洲语言, 但是不含阿拉伯语。ISO-8859-2,也既Latin-2,包括许多东欧的语言,像是匈牙利语和波兰语。

If you want to be able to encode all Unicode characters, you probably want to use UTF-8.You will probably need to deal with the other encodings only when you are handed data in those encodings created by some other application.

如果你想要能够编码所有的Unicode码字符,你或许想要使用UTF-8。只有当你需要处理那些由其他应用产生的其它编码的数据时,你或许才需要处理其他编码。

最近几次讲座的ppt等资料

小组项目进度

我们的开发项目──XYLFTP的当前进度如下:

客户端已经开始进入详细设计阶段,服务器端到了概要设计阶段。

这些阶段编写的正式文档如下:

1. 服务器端需求分析:
http://www.cocobear.cn/blog/download/2007/04/ssrsv0_4.pdf
2. 服务器端用户信息管理工具:
http://wangcong.org/src/xylftppass.py
3. 客户端需求分析:
http://wangcong.org/down/Requirements_Analysis_Client.pdf
4. 客户端概要设计:
http://wangcong.org/down/General_Design_Client.pdf

BTW:我刚在sourceforge.net给我们的项目进行了注册,主页是:https://sourceforge.net/projects/xylftp。以后会陆续更新。

希望大家继续努力!早日完成任务!

写给初学者:Linux下的软件安装

, ,

作者:西邮 王聪

如果你获得的是普通的源代码压缩包(*.tar/*.tar.gz/*.tar.bz2),请先使用相应的命令把它解压到一个临时目录。具体命令如下:

对于*.tar文件: tar -xvf package_name.tar
对于*.tar.gz文件: tar -xvzf package_name.tar.gz
对于*.tar.bz2文件: tar -xvjf package_name.tar.bz2
对于*.bz2文件: bzip2 -d package_name.bz2
对于*.bz文件: bzip -d package_name.bz
对于*.gz文件: gzip -d package_name.gz
对于*.zip文件: unzip package_name.zip
对于*.rar文件: rar x package_name.rar

然后进入该目录(cd your-path),在此目录下依次执行如下命令(一般情况都如此,特殊情况见后面的解释):

./configure
make
make install(<-- 此命令可能需要root权限,请注意)
我解释一下各个命令的作用:

./configure是执行当前目录中的名为configure的脚本(已经存在,注意"."代表当前目录,而".."代表当前目录的父目录──即上一层),它的作用是检查你的机器配置(比如:你使用的是什么操作系统,是Unix还是Linux;你使用的是什么芯片,是Intel还是PowerPC;你的机器上有没有安装gcc编译器,它用来编译C/C++/Java代码;你的机器上有没有安装这个软件需要的库,比如glib等),它会根据实际情况生成相应的makefile(什么是makefile下面有解释)。如果有不符合安装条件的情况,它会停止。这时请检查错误提示。

make是在当前目录中查找一个名为makefile(上一步生成的)的文件,此文件指定了安装这个软件需要的执行的一些命令,比如用什么编译,用什么选项编译,编译哪些文件等等(如果你想学习Linux开发你肯定要学习makefile的书写规则,其实一些优秀的Windows程序员也是自己写makefile的)。这一步完成后它会生成一些相应的目标文件和二进制文件(这些在安装完成后可以清除,见下面),为下一步的安装(make install)做准备。除非编译过程中出现问题(很少出现),它不会失败。

make install其实也是在执行make命令,它和上一步的相同之处是都是执行的当前目录中文件makefile中的命令,不同之处是它是执行的名为“install”的动作(动作就是一系列的命令,当然也是在makefile文件中,动作可以有不同的名称,比如install,clean,uninstall)。它的作用一般是进行进一步的编译,把编译好的二进制文件或其它配置文件放到特定目录(比如:/bin,/usr/bin,/etc,因为这些目录的写入需要root权限,所以一般要用root权限来运行此命令)或其它动作。这一步执行完这个软件就算是安装完成了。

如果你注意观察,你会发现,执行了上面的命令后此目录中还有一些不再使用的目标文件或其它一些临时文件,是的,你可以删除它们。执行make clean即可。同理,如果你想卸载此软件,执行make uninstall。

Linux的安装程序也有二进制形式,比如Redhat/Suse上的*.rpm格式和Debian/Ubuntu上的*.deb格式,它们可以直接像在Windows上那样在图形界面下安装。在命令行下请使用下面的命令:

对于rpm包:rpm -ivh package_name.rpm
对于deb包:dpkg -i package_name.deb

当然会有例外!Linux上的realplayer的安装程序是.bin的二进制形式,它的安装很简单直接运行即可(./realplayer.bin)。还有一些软件提供的安装程序是.sh(shell脚本),它的作用是代替makefile来执行相应的动作。这类安装方式的缺点也是显然的,灵活性太差,它们只能适应一种构架,所以如果软件提供商提供这种方式,它一般会为各个平台提供一种安装程序(所以在下载时请注意是否是你使用的平台上的安装包),而且这种发布软件的方式//一般//表明此软件是封闭源代码的。

可能还会有一些安装方式和上面所提的方式不同,遇到此类情况请仔细查看此软件目录中的名为README或INSTALL等的说明文件,作者会在里面说明相应的安装方法。

关于纳新

作者:西邮 王聪

小组简介:

我们这个兴趣小组主要是学习Linux系统配置,Linux应用程序开发,Linux内核编程。每周三一般都会邀请系里的老师来做一次讲座,周一周五晚上七点讨论。我们在网上有自己的新闻组进行讨论,有自己的博客发布文章。

最近在做的一个项目叫xylftp(Xi You Linux FTP),它是关于FTP的一套程序,包括一个完整的服务器端和客户端。服务器端是用C编写,而客户端是用Java编写。做这个项目的目的有两个:一是熟悉Linux上的网络编程/Java编程,二是熟悉软件工程,我们这个项目是按照软件工程的规范一步一步来的,各种文档也是按照规范写的。

我们上学期做的主要是一些小的Linux应用程序,主要是为了帮助大家熟悉Linux编程环境。其实这也是我们这学期给新手准备的内容。;-)

如果你对Linux感兴趣,并且非常想学习关于它的更多的知识,欢迎你加入我们!我们将尽力为你提供一个好的学习环境。

报名方法:

新校区:每周一,周五晚七点,周三下午4:30,到二号实验楼434,找金明洁同学。
老校区:直接联系梅延涛同学,或者发邮件到meiyantaoster@gmail.com。

相关链接:

我们的博客:http://my.opera.com/xiyoulinux/blog/
我们的新闻组:http://groups.google.com/group/xiyoulinux

致谢:

感谢金明洁同学,他能不辞辛苦地帮我们管理新来的同学。
多亏了梅延涛同学,才使得我们也能够在老校区发展。
史宇航同学虽然不是我们兴趣小组的成员,但他能帮助我们在xiyoubbs上宣传,非常感谢!

一些问题:

1. 非计算机专业的行吗?
答:没问题。其实这里有很多非计算机专业的同学,最好的例子是梅延涛,他其实是学管理的。;-p

2. 有什么要求吗?
答:一般来说没有,只要有这方面的兴趣即可。如果你的编程能力不错,那将会更好。

3. 有截止日期吗?
答:具体日期没有,但是越早加入越好,因为我们不会因为你而改变整个小组的安排。我们这样做主要是想让更多人加入,然后筛选一些能坚持下去,确实感兴趣的同学。是的,我们完全凭兴趣,所以坚持是最重要的。

4. 参加这能加学分吗?
答:不能!如果你只是想要学分的话,我劝你最好别加入。我们*每个人*绝对不会因为加入这而得到半个学分,连0.001个学分也没有。

5. 里面有什么考核吗?
答:一般不会有,但我不排除其他人安排的一些测试(可能主要是为了提高大家的积极性)。但是,请放心,那也不会成为筛选的标准。只要你肯坚持学习,我们没理由让你退出。

写给像我一样的初学者

,

作者:西邮 梅延涛

很高兴在西邮能遇到你们这些有共同爱好(Linux)的朋友们!

我已经大三了,虽然学习Linux已有一年多的,但是,我在学习上走了太多弯路。写这篇感想的目的不是想教你们什么――我没有这个份量――但是,看完我这篇感想,一定能让你们少走许多弯路,至少我不愿意看到你们再走我的老路。

1. 想学好Linux(包括其他计算机知识)要做的第一件事,就是学好English。如果你们看到我现在读资料的窘况,你们就明白英语是何等重要。Linux的大部分有价值的文档都是英文的,没有翻译。等翻译出来了,这些资料也就该过时了。我买了一本Qt3的翻译本,但是,略有常识的人都会知道,Qt4已经出来很久了。Qt3和Qt4在细节上有很大的差别,所以,我不得不把我的翻译本作为参考,硬着头皮去看QT4的下载文档。我的英语很差,虽然借助翻译工具,也能勉强看懂,但是印象不深。所以,我只能用一个本子,从电脑上看一句,再把它默写下来。只有如此,才能既记单词,又对文档内容有一个教深的印象,不至于掰一个玉米就扔一个。其速度,可想而知。

2. 学Linux就一定要学习编程(别担心,编程是对思维的良好训练,即使你以后不从事编程工作学习编程对你也是很有好处的),不然,你大可只用Window XP了。Linux可以更好的完成XP下的一切任务(游戏除外),而且不用太伤神。反着说一句,如果你学习编程,那就一定要学习Linux,不然,你可能永远只会停留在API这些抽象接口上,不会进入操作系统的本质,因为Windows是不开源的。

3. 学习Linux除了要会C这样的高级语言外,你必须熟悉两种格式的汇编语言AT&T和Intel(用nasm汇编)。关于这两种汇编的教材,我有两本非常好,都在我留给本论坛的一个链接里下载,分别是《Professional Assembly Language》(书店有翻译版)和《Guide to Assembly Language Programming in Linux》。请相信,只有熟悉了32位汇编,才能真正理解硬件的基本原理,在计算机体系里学的8086汇编是16位的,而且是基于masm的,基本上对Linux没有太大帮助。

4. 学习一门除C外的能够夸平台的、且有良好库支持的高级语言(这是最低要求),你可以选择Java,它的第三方支持很好,在网络方面很多支持都可能会成为未来的标准,而且这门语言也比较简单。我选择的是C++,这门语言功能十分强大,而且有Qt这种强大的库支持,在各种平台上都非常实用。但是,正如王聪曾经说过的那样,C++太庞大了,如果你选择了它,就不得不花费5倍于Java或C的时间去学习和实践(这个倍数可能有些夸张,但它确实很难)。有人曾经打过比方,C++是一辆驰骋在荒野上的跑车,你不仅要熟悉车的驾驶(熟悉其基本语法和常见支持),也要能辨别驾驶的方向(有较高的软件设计水平),这是技能和思想上的统一。一个意大利的大学老师曾经在ICQ上告诉我:"C++ is only for good programmer.“想必也是这个道理吧。

5. 要习惯阅读电子版的教程,因为Linux的文档不仅翻译的少,就连英文原版也很少在书店里及时找到。我就是不习惯阅读电子版,所以比别人的学习效率差了很多。

6. 学习Linux你要有淡泊名利的精神。因为在中国,人们的思想是以Windows为正统的,所以,你可能不会因为学习Linux而被周围的同学所看好。他们会告诉你Vista是如何的优秀,如何之漂亮,他们会把那些能帮他们杀毒的人最为偶像,而你,不过是一个搞些无用之事的闲散人。其实,如果你能淡泊一切,闲散会是另一种忙碌,在这种闲散的忙碌中,你的计算机水平将在不知不觉中得到提高。

7. Linux是一门复杂的技术,更是一种崇高的文化。Linux中有许多命令,死记硬背是背不完的。多动手,一次记不住,下次只要你知道怎么去查找这个问题的答案了就行了。我是很少去记各种命令的,因为记不住,而且也没必要。Linux的帮助文档如此之多,学习开源的朋友如此之众,随便找个论坛发个帖子,都会有许多人帮你的,这一点个我深有体会。当你有一些适合你的朋友时,你就会知道这种文化是什么了:Linux的世界里没有分数的束缚,没有名次的高低,没有那么多鄙视与功利――只有一声为了理想和兴趣而共同进步的号角。万一有一天你发现有人在你的帖子下鄙视你的话,那也不必介意,他只是一个刚刚入门的菜鸟,因为Linux高手都是有很深的黑客文化修养的人(关于什么是黑客文化,你可以在王聪的blog上找到这个链接),不会这么浮浅。放下所有的负担,去接受这种伟大文化的熏陶吧。

8. 不要在乎你的考试成绩。我一直再考虑要不要在这里贴出这条,因为这么写是很危险的,我极可能会遭到考研的或是品学兼优年年得奖学金的同学之围攻。Linux不是你所想的那么简单,他要求你付出比专业课更多的时间去学习,这样,势必会影响到你们的光辉仕途。请不要以为你们计算机的专业课会对Linux有太大帮助,我虽然是文科学生,但我上过计算机辅修,那些课程的教材都是10年(至少也在5年)以前,与Linux乃至于计算机技术的要求相差深远。关于这一点,我只能说到这里,因为我不想牵进太多是非之中。如果你要批评我的看法,那无论你出于什么样的理由,我都会检讨自己,承认自己的错误。子曾经曰过:“神鬼之事,敬而远之。”对考研和走仕途之路的朋友们,我也“敬而远之”……

9. 我眼中Linux的优势。免费这个我就不说了,这不算什么优点。众所周知,XP在中国也是“免费”的,F8四块钱一张,量多从优。但是,如果你要学习C/C++,Linux下有最好的编译器,而且许多技术性的东西都是从Unix/Linux上移植到Windows下的(游戏除外)。如果你喜欢上网看学习资料,而又担心受到病毒袭击,你就用Linux吧。我还没有见过针对Linux的病毒(注:Linux下是有病毒的,但相对于Windows而言,那就太少了)。此外,可能也是你们最关心的一点:Linux人才的市场需求远大于Windows下的普通程序员。因为Linux提供了许多安全性高,价格便宜而且开放源代码的各种工具。这对于不玩游戏的企业单位来说,实在是太有用了,企业需要它。尽管UNIX还是占有很大的市场份额,但是放心,Linux和UNIX使用的是同一套标准,他们在很大程度上是兼容的。此外,时代已经不同了,如果还想像几年前那样依靠会架个网站或是会写个Windows小程序这样的技术来糊口,那几乎是不可能的。普通的Windows应用程序员和会用Word的人一样多,如果你没有一些系统级和硬件级的软件设计能力,做程序员可能还不如摆地摊儿。而Linux提供了大量的文档和工具(大多是免费的),给你提供了学习这些底层设计的机会。比如现在流行的许多智能手机,内嵌的都是以Linux为雏型的系统。如果你熟悉了kernel,这些对你而言将不再是梦想!

好了,我最后再重申一遍,我和你们一样,也是初学者,文章中有不欠当的地方是再所难免的。欢迎大家指出,我们共同学习!
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31