ssh连接速度很慢的解决方法

问题现象:

公司有几台服务器,SSH连接的时候很慢,半天才连接上,连上后一切操作正常,网络速度没问题。

处理方法:

用命令:ssh -v 服务器IP或者域名

参数v能显示连接过程中的一系列步骤,看看在哪一步完成后卡得比较久,就是那一步出问题了。

发现卡得比较久的有

XML/HTML代码
  1. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password  
  2. debug1: Next authentication method: gssapi-keyex  
  3. debug1: No valid Key exchange context  
  4. debug1: Next authentication method: gssapi-with-mic  

说明卡在了尝试gssapi认证过程上,编辑服务器上的SSH配置文件

vi /etc/ssh/sshd_config

将#GSSAPIAuthentication no这一行前面的#号删除,同时在GSSAPIAuthentication yes这行前面加上#号,禁用gssapi认证。

重启SSH服务:service sshd restart

再次连接,发现还是有点慢,但是比之前快了一些,继续用ssh -v 跟踪,卡在这:

XML/HTML代码
  1. debug1: Authentications that can continue: publickey,password  
  2. debug1: Next authentication method: publickey  

这是因为服务器要将客户机的IP解析成域名,再次编辑SSH配置文件,将

#UseDNS yes

这行改成

UseDNS no

重启SSH服务,再次连接,终于是飞一般的感觉。

 

各种SSH终端软件对比

Xshell

收费软件

ssh secure shell

免费软件

secureCRT

Secure[1] CRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单的说是Windows下登录UNIX或Linux服务器主机的软件。SecureCRT支持SSH,同时支持Telnet和rlogin协议。SecureCRT是一款用于连接运行包括Windows、UNIX和VMS的理想工具。通过使用内含的VCP命令行程序可以进行加密文件的传输。有流行CRTTelnet客户机的所有特点,包括:自动注册、对不同主机保持不同的特性、打印功能、颜色设置、可变屏幕尺寸、用户定义的键位图和优良的VT100,VT102,VT220和ANSI竞争.能从命令行中运行或从浏览器中运行.其它特点包括文本手稿、易于使用的工具条、用户的键位图编辑器、可定制的ANSI颜色等.SecureCRT的SSH协议支持DES,3DES和RC4密码和密码与RSA鉴别。

SecureCRT也是一个收费软件

PuTTY

Putty是一个免费的、Windows 32平台下的telnet、rlogin和ssh客户端,但是功能丝毫不逊色于商业的telnet类工具。
用它来远程管理Linux十分好用,其主要优点如下:
◆ 完全免费;
◆ 支持公钥认证;
◆ 全面支持ssh1和ssh2;
◆ 绿色软件,无需安装,下载后在桌面建个快捷方式即可使用;
◆ 体积很小,仅484KB(0.63 版本);
◆ 操作简单,所有的操作都在一个控制面板中实现。

11个rsync使用实例

rsync表示 remote sync,其用于在本地或与远程主机间进行文件或目录备份。相比较scp等工具,rsync有以下优点:

  1. 速度:除首次全拷贝外,其他时候实现增量拷贝,加快传输速度
  2. 安全:传输数据时可用ssh加密传输
  3. 带宽占用:rsync可对数据进行分块压缩传输,相比其他文件传输工具占用更少带宽
  4. 权限限制:非root用户也可安转和执行rsync命令

rsync执行方式如下:

$ rsync options source destination

source 和 destination 既可以指示本地,也可以是远程机器。下面通过实例说明rsync的用法。

1.在本地两个目录间进行数据同步

以下命令用于在两个目录间完成文件拷贝:

$ rsync -zvr /var/opt/lx/ /root/temp/
sending incremental file list
a.c
b.c

sent 211 bytes  received 50 bytes  522.00 bytes/sec
total size is 81  speedup is 0.31

以上选项表示意思如下:

  • -z 传输前进行压缩
  • -v 显示命令执行详细信息
  • -r 递归拷贝目录

此时我们看本地和目的地两个文件属性,注意到两者的时间戳是不同的:

$ ll /var/opt/lx/a.c /root/temp/a.c 
-rw-r--r-- 1 root root 73 04-06 21:11 /root/temp/a.c
-rw-r--r-- 1 root root 73 04-06 21:05 /var/opt/lx/a.c

若要保留原文件时间戳、属主/属组、权限属性,我们可以使用 -a 选项:

$ rsync -azv /var/opt/lx/ /root/temp/

-a选项亦包含递归的作用,因而可以替代-r选项。

2.本地与远程主机间完成数据同步

我们可以用rsync将本地的文件,同步到远程机器:

$ rsync -avz /root/temp/ lx@192.168.1.103:/home/lx/tmp/
Password:  
sending incremental file list
created directory /home/lx/tmp
./
a.c
b.c

sent 216 bytes  received 53 bytes  21.52 bytes/sec
total size is 81  speedup is 0.30

以上我们指明了目的机器ip、登录用户以及所路径,并且需要输入相应用户的登录密码。以上命令完成本地到远程机器的同步,调换source和destination的位置,我们亦可完成远程机器到本地的数据同步。

3.使用ssh通道进行数据同步

在与远端进行数据同步时,我们一般采用ssh通道,使用 -e ssh 选项可以完成该功能:

$ rsync -avz -e ssh /root/temp/ lx@192.168.1.103:/home/lx/tmp/

4.不覆盖目的地对文件已作的修改

经常出现这样的场景,我们对源文件和目的地文件均作了修改,同时想将源文件作的修改同步到目的地,但又保留对目的地文件的更改,此时可以使用 -u 选项:

$ ls -l /root/temp/b.c 
-rw-r--r-- 1 root root 12 04-06 22:19 /root/temp/b.c
$ ls -l /var/opt/lx/b.c 
-rw-r--r-- 1 root root 8 04-06 21:06 /var/opt/lx/b.c
$ rsync -avzu /var/opt/lx/ /root/temp/
sending incremental file list
./
a.c

sent 172 bytes  received 34 bytes  412.00 bytes/sec
total size is 101  speedup is 0.49 

以上目的地 b.c 文件经过修改,与源文件不相同,此时使用 -u 选项,可以看到对 b.c 并不进行同步,目的地 b.c 的修改得以保存。

5.删除不存在于源目录的目的地文件

对于不存在于源目录,但存在于目的地的文件,有时我们想在做文件同步时删除它们,–delete 选项可以满足要求:

$ rsync -avz --delete /var/opt/lx/ /root/temp/
sending incremental file list
./
deleting c.c
b.c

sent 101 bytes  received 34 bytes  270.00 bytes/sec
total size is 101  speedup is 0.75

以上目的地相比源目录多了c.c文件,同步时 –delete 将该文件删除。 

6.在同步时不在目的地创建新文件

有时我们只想对目的地已经有的文件进行同步,而不理会源目录新增的文件,此时可以使用 –existing 选项:

$ rsync -avz --existing /var/opt/lx/ /root/temp/

7.显示执行进度

使用 –progress 选项可以显示同步的进度,包括文件传输完成进度、传输速率信息:

$ rsync -avz --progress /var/opt/lx/ /root/temp/
sending incremental file list
./
a.c
          93 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1/3)
b.c
           8 100%    7.81kB/s    0:00:00 (xfer#2, to-check=0/3)

sent 220 bytes  received 53 bytes  546.00 bytes/sec
total size is 101  speedup is 0.37

8.查看 source 和 destination 间的区别

rsync完成源目录到目的地的拷贝,若能查看到源目录与目的地间的差异,这对同步十分有帮助,-i 选项可以显示源目录与目的地间的差异,示例如下。

source:

$ ls -l /var/opt/lx/
总计 8
-rw-r--r-- 1 root root 145 04-06 23:11 a.c
-rw-r--r-- 1 root root   8 04-06 21:06 b.c

destination:

$ ls -l /root/temp/
总计 8
-rw-r--r-- 1 root root 93 04-06 22:20 a.c
-rw-r--r-- 1 lx   root  8 04-06 21:06 b.c

-rw-r–r– 1 lx   root  8 0406 21:06 b.c

可以看到 source 与 destination 有两处不同,一处为 a.c 的文件大小,第二处为 b.c 的属主,此时添加 -i 选项进行数据同步,有以下输出:

$ rsync -avzi /var/opt/lx/ /root/temp/
sending incremental file list
.d..t...... ./
>f.st...... a.c
.f....o.... b.c

sent 175 bytes  received 37 bytes  424.00 bytes/sec
total size is 153  speedup is 0.72

对于同步的每个文件,均对应有一条输出,有11个标志位指示源文件与目的地文件的区别,在以上例子中,各标志位意义如下:

  • > 指示传输到本地
  • f  指示所传为文件
  • s  指示文件大小不一致
  • t  指示时间戳不一致
  • o  指示属主不一致

 9.按指定模式进行同步

使用 –include 和 –exclude 选项,可以帮助我们完成只同步特定文件的目的,例如以下只同步以 ‘a’ 开头的文件:

$ rsync -avz --include 'a*' --exclude '*' /var/opt/lx/ /root/temp/
sending incremental file list
./
a.c
aa.c

sent 220 bytes  received 53 bytes  546.00 bytes/sec
total size is 148  speedup is 0.54

10.限制传输文件的大小

使用 –max-size 选项,我们可以限制传输文件的最大大小:

$rsync -avz --max-size='100K' /var/opt/lx/ /root/temp/

以上命令限制传输的文件大小只能小于或等于100K,另可以使用 M 和 G 作为大小单位。

11.全拷贝

默认情况下 rsync 采用增量拷贝,这样能节省带宽,在所同步文件不大的情况下,我们可以通过 -W 选项实现全拷贝:

$ rsync -avzW /var/opt/lx/ /root/temp/

linux下which、whereis、locate、find 命令的区别

 我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索。
1、which
语法:
[root@redhat ~]# which 可执行文件名称

which是通过 PATH环境变量到该路径内查找可执行文件,每个用户的环境变量可能不同,所以搜索出来的结果也可能不同。可能用echo $PATH查看当前环境变量。-a可以列出所有PATH目录下存在的文件,而不仅仅是找到的第一个文件。默认只显示找到的第一个文件。注意:which只会搜寻可执行文件,普通文件即使在$PATH变量路径中,也是查找不到的。

例如:
[root@redhat ~]# which passwd
/usr/bin/passwd

2、whereis
语法:
[root@redhat ~]# whereis [-bmsu] 文件名

查找名中含有查找串的文件

参数说 明:
-b : 只找二进制文件
-m: 只找在说明文件manual路径下的文件
-s : 只找source源文件
-u : 没有说明文档的文件
例如:
[root@redhat ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
将和passwd文件相关的文件都查找出来

[root@redhat ~]# whereis -b passwd
passwd: /usr/bin/passwd /etc/passwd
只将二进制文件 查找出来

和find相比,whereis查找的速度非常快,这是因为linux系统会将 系统内的所有文件都记录在一个数据库文件中,当使用whereis和下面即将介绍的locate时,会从数据库中查找数据,而不是像find命令那样,通 过遍历硬盘来查找,效率自然会很高。
但是该数据库文件并不是实时更新,默认情况下RHDL和centos一天更新一次,因此,我们在用whereis和locate 查找文件时,有时会找到已经被删除的数据,或者刚刚建立文件,却无法查找到,原因就是因为数据库文件没有被更新。

3、 locate
语法:
[root@redhat ~]# locate 文件或者目录名称

查找含有查找字串的文件和目录,如果是目录,就会将目录下的所有文件列举一遍分别作为一个查找结果。

例 如:
[root@redhat ~]# locate passwd
/home/weblogic/bea/user_projects/domains/zhanggongzhe112/myserver/stage/_appsdir_DB_war/DB.war/jsp/as/user/passwd.jsp
/home/weblogic/bea/user_projects/domains/zhanggongzhe112/myserver/stage/_appsdir_admin_war/admin.war/jsp/platform/passwd.jsp
/lib/security/pam_unix_passwd.so
/lib/security/pam_passwdqc.so
/usr/include/rpcsvc/yppasswd.x
/usr/include/rpcsvc/yppasswd.h
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/rpcsvc/yppasswd.ph
/usr/lib/kde3/kded_kpasswdserver.la
/usr/lib/kde3/kded_kpasswdserver.so
/usr/lib/ruby/1.8/webrick/httpauth/htpasswd.rb
/usr/bin/vncpasswd
/usr/bin/userpasswd
/usr/bin/yppasswd
…………

4、 find
语法:
[root@redhat ~]# find 路径 参数
参数说明:
时间查找参数:
-atime n :将n*24小时内存取过的的文件列出来
-ctime n :将n*24小时内改变、新增的文件或者目录列出来
-mtime n :将n*24小时内修改过的文件或者目录列出来
-newer file :把比file还要新的文件列出来
名称查找参数:
-gid n :寻找群组ID为n的文件
-group name :寻找群组名称为name的文件
-uid n :寻找拥有者ID为n的文件
-user name :寻找用户者名称为name的文件
-name file :寻找文件名为file的文件(可以使用通配符)
例 如:
[root@redhat ~]# find / -name zgz
/home/zgz
/home/zgz/zgz
/home/weblogic/bea/user_projects/domains/zgz
/home/oracle/product/10g/cfgtoollogs/dbca/zgz
/home/oracle/product/10g/cfgtoollogs/emca/zgz
/home/oracle/oradata/zgz

[root@redhat ~]# find / -name '*zgz*'
/home/zgz
/home/zgz/zgz1
/home/zgz/zgzdirzgz
/home/zgz/zgz
/home/zgz/zgzdir
/home/weblogic/bea/user_projects/domains/zgz
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00006
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00002
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00004
/home/weblogic/bea/user_projects/domains/zgz/zgz.log
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00008
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00005

当我们用whereis和locate无法查找到我们需要的文件时,可以使用find,但是find是在硬盘上遍历查 找,因此非常消耗硬盘的资源,而且效率也非常低,因此建议大家优先使用whereis和locate。

 

locate 是在数据库里查找,可以查找含有字符串的文件和目录
whereis 在数据库中查找,可以查找含有字符串的文件,可以找到可执行命令和man page
find 就是根据条件查找文件
which 根据环境变量PATH查找,一般只查找可执行文件,可以找到可执行文件和别名(alias)

Lee补充:用locate命令的话,如果磁盘上文件有更改,需要执行updatedb命令来更新数据库,否则结果可能会与实际不符合。

历尽艰辛的putty免密码SSH登陆服务器的配置

  前段时间在虚拟机上装了个CentOS,然后用puttyl连接上去操作,为了方便,不用每次登陆输入密码,我就想配置用密钥免密码直接登陆,下面是配置过程:

  1、在服务器的用户目录下建立一个文件夹.ssh,注意有一个句点,用来存储密钥用。

  2、生成密钥,然后用如下命令:

ssh-keygen -t rsa

  生成的过程中先会问你要存成什么文件,直接回车用默认的,就是储存在上一步建立的.ssh目录里。

  然后会让你输入passphrase(即口令,如果设置了,登陆时要输入这个口令),可以为空。最后会生成两个文件id_rsa和id_rsa.pub。

  3、公钥文件名authorized_keys。进入.ssh目录,用如下命令生成:

cp id_rsa.pub authorized_keys

  如果你不想保留id_rsa.pub,也可以直接用mv命令。

  4、更改文件权限,以用户root为例:
chmod 700 /root
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys

  用户目录root的权限设置一般会被忽略掉,导致登陆时日志文件/var/log/secure里会有这样的信息:
Authentication refused: bad ownership or modes for directory /root

  我就是在这里吃了亏,到处找解决方案,不断地尝试各种权限设置,有人说是Selinux造成的,于是我也去关闭,同样不行,最后还是设置了用户目录的权限才成功。

  5、SSH服务的配置。更改配置文件/etc/ssh/sshd_config,找到以下三行:

XML/HTML代码
  1. #RSAAuthentication yes  
  2. #PubkeyAuthentication yes  
  3. #AuthorizedKeysFile      .ssh/authorized_keys  

将前面的#删除,其中第三行的authorized_keys一定要确认与第3步里生成的文件名一致。保存后重启SSH服务:
service sshd restart

  6、PuTTY上的私钥配置

  由于CentOS是OpenSSH,生成的私钥与putty和格式不同,所以不能直接拿来使用,先把第2步中在服务器上生成的私钥文件id_rsa下载到本地,然后用PuTTYgen转换一下:用菜单File->Load private key导入私钥文件id_rsa,然后点击Save private key,保存好的新私钥文件就能用来给PuTTY登陆使用了。PuTTY的具体设置我就不说了,不过有个方法可以方便使用,建立一个PuTTY快捷方式,然后更改快捷方式的属性里的目标一栏加上如下参数:
-i "私钥文件路径" root@192.168.10.60

保存后就能直接双击这个快捷方式登陆了。

phpstorm 快捷键

phpstorm是个很好用的PHP开发工具,工欲善其事必先利其器,熟悉下软件的操作快捷键能提高工作效率。

ctrl+shift+n 查找文件
ctrl+j 插入活动代码提示
ctrl+alt+t 当前位置插入环绕代码
alt+insert 生成代码菜单

ctrl+q 查看代码注释
ctrl+d 复制当前行
ctrl+y 删除当前行
shift+F6 重命名
ctrl+shift+u 字母大小写转换
ctrl+f 查找
ctrl+r 替换
F4 查看源码
ctrl+shift+i 查看变量或方法定义源
ctrl+g 跳转行
ctrl+alt+F12 跳转至当前文件在磁盘上的位置
alt+down 查看下一个方法
alt+up 查看上一个方法
ctrl+alt+l 重新格式化代码
ctrl+shift+down statement向下移动
ctrl+shift+up statement向上移动
alt+shift+down line向下移动
alt+shift+up line向上移动
ctrl+/ 行注释
ctrl+shift+/ 块注释

ctrl+shift+n 打开工程中的文件
ctrl+b 跳到变量申明处
ctrl+[] 匹配 {}[]
ctrl+shift+]/[ 选中块代码

ctrl+x 剪切行
ctrl+shift+v 复制多个文本
alt+left/right 标签切换
ctrl+p 显示默认参数
ctrl+F12 在当前类文件里快速查找方法

Teach Yourself Programming in Ten Years

Why is everyone in such a rush?

Walk into any bookstore, and you'll see how to Teach Yourself Java in 7 Days alongside endless variations offering to teach Visual Basic, Windows, the Internet, and so on in a few days or hours. I did the following power search at Amazon.com:

     pubdate: after 1992 and title: days and
      (title: learn or title: teach yourself)

and got back 248 hits. The first 78 were computer books (number 79 was Learn Bengali in 30 days). I replaced "days" with "hours" and got remarkably similar results: 253 more books, with 77 computer books followed by Teach Yourself Grammar and Style in 24 Hours at number 78. Out of the top 200 total, 96% were computer books.

The conclusion is that either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days. Felleisen et al. give a nod to this trend in their book How to Design Programs, when they say "Bad programming is easy. Idiots can learn it in 21 days, even if they are dummies.

Let's analyze what a title like Learn C++ in Three Days could mean:

  • Learn: In 3 days you won't have time to write several significant programs, and learn from your successes and failures with them. You won't have time to work with an experienced programmer and understand what it is like to live in a C++ environment. In short, you won't have time to learn much. So the book can only be talking about a superficial familiarity, not a deep understanding. As Alexander Pope said, a little learning is a dangerous thing.

     

  • C++: In 3 days you might be able to learn some of the syntax of C++ (if you already know another language), but you couldn't learn much about how to use the language. In short, if you were, say, a Basic programmer, you could learn to write programs in the style of Basic using C++ syntax, but you couldn't learn what C++ is actually good (and bad) for. So what's the point? Alan Perlis once said: "A language that doesn't affect the way you think about programming, is not worth knowing". One possible point is that you have to learn a tiny bit of C++ (or more likely, something like Javascript or Flash's Flex) because you need to interface with an existing tool to accomplish a specific task. But then you're not learning how to program; you're learning to accomplish that task.

     

  • in Three Days: Unfortunately, this is not enough, as the next section shows.

Teach Yourself Programming in Ten Years

Researchers (Bloom (1985)Bryan & Harter (1899)Hayes (1989)Simmon & Chase (1973)) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, telegraph operation, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. The key is deliberative practice: not just doing it again and again, but challenging yourself with a task that is just beyond your current ability, trying it, analyzing your performance while and after doing it, and correcting any mistakes. Then repeat. And repeat again. There appear to be no real shortcuts: even Mozart, who was a musical prodigy at age 4, took 13 more years before he began to produce world-class music. In another genre, the Beatles seemed to burst onto the scene with a string of #1 hits and an appearance on the Ed Sullivan show in 1964. But they had been playing small clubs in Liverpool and Hamburg since 1957, and while they had mass appeal early on, their first great critical success, Sgt. Peppers, was released in 1967. Malcolm Gladwell reports that a study of students at the Berlin Academy of Music compared the top, middle, and bottom third of the class and asked them how much they had practiced:

Everyone, from all three groups, started playing at roughly the same time – around the age of five. In those first few years, everyone practised roughly the same amount – about two or three hours a week. But around the age of eight real differences started to emerge. The students who would end up as the best in their class began to practise more than everyone else: six hours a week by age nine, eight by age 12, 16 a week by age 14, and up and up, until by the age of 20 they were practising well over 30 hours a week. By the age of 20, the elite performers had all totalled 10,000 hours of practice over the course of their lives. The merely good students had totalled, by contrast, 8,000 hours, and the future music teachers just over 4,000 hours.

So it may be that 10,000 hours, not 10 years, is the magic number. (Henri Cartier-Bresson (1908-2004) said "Your first 10,000 photographs are your worst," but he shot more than one an hour.) Samuel Johnson (1709-1784) thought it took even longer: "Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price." And Chaucer (1340-1400) complained "the lyf so short, the craft so long to lerne." Hippocrates (c. 400BC) is known for the excerpt "ars longa, vita brevis", which is part of the longer quotation "Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile", which in English renders as "Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgment difficult." Although in Latin, ars can mean either art or craft, in the original Greek the word "techne" can only mean "skill", not "art".

So You Want to be a Programmer

Here's my recipe for programming success:

  • Get interested in programming, and do some because it is fun. Make sure that it keeps being enough fun so that you will be willing to put in your ten years/10,000 hours.

     

  • Program. The best kind of learning is learning by doing. To put it more technically, "the maximal level of performance for individuals in a given domain is not attained automatically as a function of extended experience, but the level of performance can be increased even by highly experienced individuals as a result of deliberate efforts to improve." (p. 366) and "the most effective learning requires a well-defined task with an appropriate difficulty level for the particular individual, informative feedback, and opportunities for repetition and corrections of errors." (p. 20-21) The book Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life is an interesting reference for this viewpoint.

     

  • Talk with other programmers; read other programs. This is more important than any book or training course.

     

  • If you want, put in four years at a college (or more at a graduate school). This will give you access to some jobs that require credentials, and it will give you a deeper understanding of the field, but if you don't enjoy school, you can (with some dedication) get similar experience on your own or on the job. In any case, book learning alone won't be enough. "Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter" says Eric Raymond, author ofThe New Hacker's Dictionary. One of the best programmers I ever hired had only a High School degree; he's produced a lot of greatsoftware, has his own news group, and made enough in stock options to buy his own nightclub.

     

  • Work on projects with other programmers. Be the best programmer on some projects; be the worst on some others. When you're the best, you get to test your abilities to lead a project, and to inspire others with your vision. When you're the worst, you learn what the masters do, and you learn what they don't like to do (because they make you do it for them).

     

  • Work on projects after other programmers. Understand a program written by someone else. See what it takes to understand and fix it when the original programmers are not around. Think about how to design your programs to make it easier for those who will maintain them after you.

     

  • Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).

     

  • Remember that there is a "computer" in "computer science". Know how long it takes your computer to execute an instruction, fetch a word from memory (with and without a cache miss), read consecutive words from disk, and seek to a new location on disk. (Answers here.)

     

  • Get involved in a language standardization effort. It could be the ANSI C++ committee, or it could be deciding if your local coding style will have 2 or 4 space indentation levels. Either way, you learn about what other people like in a language, how deeply they feel so, and perhaps even a little about why they feel so.

     

  • Have the good sense to get off the language standardization effort as quickly as possible.

With all that in mind, its questionable how far you can get just by book learning. Before my first child was born, I read all the How Tobooks, and still felt like a clueless novice. 30 Months later, when my second child was due, did I go back to the books for a refresher? No. Instead, I relied on my personal experience, which turned out to be far more useful and reassuring to me than the thousands of pages written by experts.

Fred Brooks, in his essay No Silver Bullet identified a three-part plan for finding great software designers:

  1. Systematically identify top designers as early as possible.

     

  2. Assign a career mentor to be responsible for the development of the prospect and carefully keep a career file.

     

  3. Provide opportunities for growing designers to interact and stimulate each other.

     

This assumes that some people already have the qualities necessary for being a great designer; the job is to properly coax them along. Alan Perlis put it more succinctly: "Everyone can be taught to sculpt: Michelangelo would have had to be taught how not to. So it is with the great programmers". Perlis is saying that the greats have some internal quality that transcends their training. But where does the quality come from? Is it innate? or do they develop it through diligence? As Auguste Gusteau (the fictional chef in Ratatouille) puts it, "anyone can cook, but only the fearless can be great." I think of it more as willingness to de

直接下载的CHM文件打开无法显示内容的解决办法

今天下载了个CHM文档,打开后一片空白,原以为下载的文件有问题,去下载页面重新时发现上面附有一个解决方案的链接,摘抄整理如下,以供参考。

 下载的CHM文档,在NTFS分区打开无法显示其内容,点开任何一个页面都是一片空白。解决办法:

1、上传文件时将chm打包为rar、zip或7z等压缩文件格式

2、修改直接下载后的CHM文件属性:鼠标右键菜单打开文件属性,你会发现下面有这样的安全提示:“此文件来自其他计算机 可能被阻止以帮助保护该计算机”,右边有个解除锁定的按钮,点击一下,再点确定按钮,再次打开这个CHM文档,就一切正常了。

PXE网络启动PE维护工具:小小强Pe工具箱PXE版

如果电脑出问题了,手上没光盘也没U盘,怎么办?

现在大部分网卡都支持网络启动,在BIOS里开启网卡的网络启动,并设为第一启动项。然后就可以用PXE来启动PE进行维护操作了。

自己折腾比较麻烦,有好多现成的可以使用,如:

小小强Pe工具箱PXE版V4.0,度娘上找了好久没找到,最后在GG上找到下载地址:http://dl.dbank.com/c09nr3vubg

 测试了下,用自带的haneWINDHCP客户机无法启动,改用TFTPd32,根据使用说明设置引导文件,能启动。功能挺丰富的。

VirtualBox 网络设置详解

VirtualBox 有6种网络模式,下面将逐一讲解。

1、NAT〈网络地址转换模式〉

  VirtualBox 中虚拟的主机(以下简称:虚拟主机)并不真实存在于网络中,宿主机和宿主机网络中的任何主机都不能直接访问虚拟主机,各虚拟主机也互不相通。虚拟主机能访 问宿主机,以及宿主机能访问的任何主机。虚拟主机访问网络是先通过 VirtualBox 转换后再发送出去的,数据接收也是先由 VirtualBox 接收后再转换转发到虚拟主机。

  为了解决其它主机不能访问虚拟主机的问题,VirtualBox 提供了端口转发功能,使得我们可以设置特定的端口供实体网络访问。

  虚拟主机网络参数默认从 VirtualBox 的虚拟 DHCP 服务器 获取。

2、Bridged Adapter〈桥接模式〉

  虚拟主机通过 VirtualBox 桥接到宿主机的一个网卡中,就像真实存在于宿主机网络中的一台主机一样。虚拟主机能与宿主机和宿主机网络中的主机完美互通。被桥接的网卡会开启混杂模式。

  虚拟主机网络参数 : 手动配置成桥接的宿主机网卡的同一网段,或通过宿主机网络中的 DHCP Ser 获取。

  注意:1.需要加载模块vboxnetflt;2.如果宿主机在一个受限制的网络虚拟主机是不能访问互联网的,如:宿主机使用ADSL、使用使用代理或VPN、宿主机网关做了MAC地址限制……

3、Internal〈内部模式〉

  虚拟机与外界完全分开,虚拟机与宿主机网络不能互通,只有 同一名称(如:intnet)的内部网络模式的虚拟机之间才能互相访问 ,还有一个条件是在同一网段。

  虚拟主机网络参数 : 默认不分配IP,需要自已手动设置。

4、Host-only Adapter〈宿主机模式〉

  VirtualBox 在宿主机中虚拟一个 host-only 网卡,然后把虚拟主机桥接到 host-only 网卡上,我们可以通过设置 host-only 网卡(共享、桥接)来实现网络连接。

  虚拟主机网络参数 :默认从 VirtualBox 的虚拟 DHCP 服务器 获取,IP段为192.168.56.0/24

5、未指定

  如果你选择“未指定”,你将不能和任何主机通信,只能够自已 ping 自已

6、通用驱动

  这个不知道具体怎么用,有空再研究研究。