显示标签为“linux”的博文。显示所有博文
显示标签为“linux”的博文。显示所有博文

2015-08-06

X-Session security

从一台windows机器上ssh到一台RHEL上,以root用户能正常启动带X windows界面的程序,可是以普通用户esbadmin却无法启动,报错:

Xlib: connection to "localhost:10.0" refused by server
Xlib: MobaXterm X11 proxy: Unsupported authorisation protocol

Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.

执行xhost的结果:
Xlib: connection to "localhost:10.0" refused by server
Xlib: MobaXterm X11 proxy: Unsupported authorisation protocol

xhost:  unable to open display "localhost:10.0"

以为是DISPLAY环境变量设置不对,可是与root用户同样的DISPLAY变量还是会得到同样的错误。

原来是和 X-Session security有关。以root用户执行xauth list得到一个列表:

besb01/unix:15  MIT-MAGIC-COOKIE-1  83aa78de1155733b1cefe4fc63839d1a
besb01/unix:16  MIT-MAGIC-COOKIE-1  5f6da97c370785b55288c31bc29f7b27
besb01/unix:10  MIT-MAGIC-COOKIE-1  e91f2af3747fb0095e085dcd7dd49423
besb01/unix:11  MIT-MAGIC-COOKIE-1  8037d90b9d1bf3503aaaf61c0affe4b5
besb01/unix:12  MIT-MAGIC-COOKIE-1  86667f99f925914907f12d25a6f51bc1
besb01/unix:13  MIT-MAGIC-COOKIE-1  1714acffefffd2988c4c4f1be618d9b4
besb01/unix:14  MIT-MAGIC-COOKIE-1  b16eea1237d2823f3dc9e400f123063e


复制unix:14那一行,然后以esbadmin用户执行下面的命令即可。

xauth add besb01/unix:14  MIT-MAGIC-COOKIE-1  b16eea1237d2823f3dc9e400f123063e

2015-07-26

创建tibco BW domain

创建tibco bw domain本是一件简单的事,运行domainutility程序,图形化界面,向导式的一步步照着做就好了,可是有些坑被我踩到了。

目标机器是远程的一台Red Hat Enterprise Linux Server 5.6,经过一台jump server ssh过去的。本来是要用另外一个用户去运行domainutility来创建domain,可是remote display设置好像不对,X server启动了,可是就是无法启动domainutility,总是报错:

可是以root身份却能启动 domainutility的图形化界面,把root用户的DISPLAY变量复制到另外一个用户仍然报错,不能启动图形化界面。不想在这儿折腾太久了,心想先以root身份创建然后再用chown更改文件所有者好了。创建完毕,文件所有者也更改了,然后以另一个用户的身份去运行,直接报错内存访问错误Speicherzugriffsfehler。换作root用户与运行报告同样的错误。用strace一看:
open("/root/bin", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = -1 EACCES (Permission denied)
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

看样子还真是和以root用户运行domainutility有关。

2009-02-10

shell脚本中的行尾空格引起的错误

如果执行脚本时出现syntax错误,如 line 9: syntax error: unexpected end of file 并且提示出错的行比脚本中最后一行的数字还大时,检查脚本中的行尾是否有空格,删除行尾空格就应该能解决这类错误。在vim中使用 :% s/\s*$//即可删除行尾的空白字符,包括<Space> 和 <Tab>。

2007-07-03

关掉Ubuntu 7.04下apache2的默认网页编码

当前使用apt-get install apache2 安装的apache版本为2.2.3。安装后apache为网页编码默认设置为UTF-8。不知道为什么一定要设置这个默认编码为UTF-8,让用户编写的网页自己来决定网页的编码不是更好吗。看了一眼/etc/apache2/apache2.conf文件,发现里面的语句:
#AddDefaultCharset ISO-8859-1

已经关掉了默认编码设置了。可是发现网页的编码设置仍然默认为UTF-8。后来才发现原来在/etc/apache2/conf.d文件夹下还有一个名为charset的文件,里面包含:
AddDefaultCharset UTF-8

就是它在捣乱了!注释掉这句再重启apache2,就关掉服务器端设置的默认网页编码了。

2007-06-29

Ubuntu 7.04下的know_hosts

Ubuntu 7.04下的位于~/.ssh/的文件know_hosts与原来的版本和其他的GNU/Linux发行版本有所不同了。以前的版本能够看出一台远程主机对应的钥值。每一行为一个主机的标识值,分别是:
主机名 IP地址 钥匙类型 钥值
如:
urts96,136.199.199.96 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAwZMisKXEF2poSc WEujP+YLWKl53p80SpOVyp/h3UVxeAVHkLP0s1NkiW5mRlN4prUpxK5UuZ7yd5u9uc/2qMvK 38S2hC4P/aYki7rM8L+fHQPnjiLe+J0j/UfSvUjjPyOeXuSokWWHN8aatvlJQavvZOC36Hd8 In/NtwpzganJc=
当一台server重新装操作系统有新的钥匙值之后,从原来保存有旧的钥匙值的主机上登录这台server时,就会得到警告提示:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
dd:c4:44:74:80:f7:6b:99:4d:f1:c4:cd:df:65:3a:73.
Please contact your system administrator.
Add correct host key in /home/jiad4701/.ssh/known_hosts to get rid of this message.
Offending key in /home/jiad4701/.ssh/known_hosts:9
RSA host key for germa93 has changed and you have requested strict checking.
Host key verification failed.
lost connection
以前我的解决办法是在客户端的know_hosts文件中删除server对应的钥值。可是如果你的客户端是Ubuntu 7.04,你不能从这个文件中分辨出你要登录的server的钥值在第几行,只能全部删除文件里面的内容。

为Ubuntu添加ACL

apt-get install acl安装完之后,修改/etc/fstab文件,在需要acl支持的分区上添加acl,如:

原来的一行为:
UUID=e6d069bc-4bcd-4e4d-9730-f66473118a7f / ext3 defaults,errors=remount-ro 0 1

添加acl支持后变为:
UUID=e6d069bc-4bcd-4e4d-9730-f66473118a7f / ext3 defaults,acl,errors=remount-ro 0 1

要使acl生效还必须重新加载文件系统:
jia@germa93:~$sudo mount -o remount /

2007-02-19

试用openldap

今天在ubuntu下安装(apt-get install slapd)了openldap服务器,因为openldap server在ubuntu下的包名为slapd。

root@gepc188:/etc/ldap# dpkg -s slapd
Package: slapd
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 2432
Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
Architecture: i386
Source: openldap2.2
Version: 2.2.26-5ubuntu3
Replaces: libldap2, ldap-utils (<< 2.2.23-3)
Provides: ldap-server

安装完成后要使用slappasswd命令来生成加密后的密码,然后在/etc/ldap/slapd.conf文件中添加两行:
rootdn "cn=root,dc=uni-trier,dc=de"
rootpw {SSHA}X5vL372YCCfHW7KJlVzGpwc+iQ6shuEX

这样才能登入数据库。

在创建User Account之前,需创建一个Posix Group组,否则会得到错误提示:
LDAP said: Object class violation
Error number: 0x41 (LDAP_OBJECT_CLASS_VIOLATION)
Description: You tried to perform an operation that would cause an undefined attribute to exist or that would remove a required attribute, given the current list of ObjectClasses. This can also occur if you do not specify a structural objectClass when creating an entry, or if you specify more than one structural objectClass.

这是因为shema定义的缘故,一个用户要求有一个gidNumber值。phpLDAPadmin是一个与phpmyadmin类似的图像化工具,可以简化管理ldap的工作。

2007-02-16

dpkg的常用选项

查询软件包: dpkg -l zope2.9
不知道软件包的具体名称,也可使用通配符来查询: dpkg -l zope*
查看软件包的详细信息: dpkg -s zope2.9
查看已安装软件包所安装的文件列表: dpkg -L zope2.9
显示.deb包的内容: dpkg -I scalix-swa_11.0.0.653_all.deb
显示.deb包中的文件列表: dpkg -c scalix-swa_11.0.0.653_all.deb
安装.deb软件包: dpkg -i scalix-swa_11.0.0.653_all.deb
删除软件包: dpkg -r scalix-swa_11.0.0.653_all.deb
(使用该命令安装.deb包并不能自动解决软件包的依赖问题,需用dpkg -I查出该软件包的依赖要求手动解决。所以该方法一般用来安装第三方的.deb软件包。如果需系统自动解决软件包的依赖关系,则要使用apt、 tasksel、dselect、aptitude或图形化的syanptic、KPackage等前端工具来安装软件包。)

重新配置软件包: dpkg-reconfigure

此外涉及debian源码包的管理工具还包括:dpkg-source, dpkg-gencontrol, dpkg-shlibdeps, dpkg-genchanges, dpkg-buildpackage, dpkg-dista ddfile,dpkg-parsechangelog

2006-12-22

在linux下安装cost

在ubuntu 6.10下安装tcl的一个工具包cost,在configure时报错:

checking for tclConfig.sh... Not found.

找遍整个电脑都没有这个文件。后来google了一下才知道,原来要安装了tcl8.4-dev这个包才能有这个文件
/usr/lib/tcl8.4/tclConfig.sh
执行 apt-get install tcl8.4-dev 之后再安装就没有问题了。

2006-09-30

认识wget的另外几个选项

控制下载文件的总量。当流量有限制时,这是一个很好的选项。
-Q quota
--quota=quota

Specify download quota for automatic retrievals. The value can be specified in bytes (default), kilobytes (with k suffix), or megabytes (with m suffix).

Note that quota will never affect downloading a single file. So if you specify
wget -Q10k ftp://wuarchive.wustl.edu/ls-lR.gz
all of the ls-lR.gz will be downloaded.
The same goes even when several URLs are specified on the command-line. However, quota is respected when retrieving either recursively, or from an input file. Thus you may safely type wget -Q2m -i sites---download will be aborted when the quota is exceeded.

Setting quota to 0 or to inf unlimits the download quota.

控制文件下载类型和文件所属域名
-A acclist --accept acclist
-R rejlist --reject rejlist
Specify comma-separated lists of file name suffixes or patterns to accept or reject.
You want to download all the GIFs from a directory on an HTTP server.  You tried wget http://www.server.com/dir/*.gif, but that didn't work because HTTP retrieval does not support globbing.  In that case, use:
wget -r -l1 --no-parent -A.gif http://www.server.com/dir/

-A.gif means to download only the GIF files, -A "*.gif" would have worked too.
-D domain-list
--domains=domain-list
Set domains to be followed. domain-list is a comma-separated list of domains. Note that it does not turn on -H.

--exclude-domains domain-list
Specify the domains that are not to be followed.

指定文件下载后保存的目录
-P

2006-09-24

Evolution启动出错

今天启动Evolution 2.6时发现启动出错,无法读取配置文件,错误提示为:
Error: An error ocurred while loading or saving configuration information for Nautilus. Some of your configuration settings may not work properly。

点击OK之后,又出现提示:
Adding client to server's list failed, CORBA error: IDL:omg.org/CORBA/COMM_FAILURE:1.0

察看/var/log/messages日志文档,发现纪录:
Sep 24 18:48:33 localhost gconfd (jiad4701-24732): Failed to get lock for daemon, exiting: Failed to lock '/tmp/gconfd-jiad4701/lock/ior': probably another process has the lock, or your operating system has NFS file locking misconfigured (Resource temporarily unavailable)
于是把ior文件改名后再启动evolution就没有问题了。
jiad4701@gepc188:/tmp/gconfd-jiad4701/lock$ mv ior ior.bak
不知道这个问题的症结在哪儿。

2006-09-23

删除HTML标记

删除HTML文件里的标记,看似一个简单的文本替换,但是关键是如何写匹配的正则表达式。


像下面这样的命令是不能完成的。
$ sed -e 's/< .*>//g' myfile.html


因为当 sed 试图在行中匹配规则表达式时,它要在行中查找最长的匹配


解决办法是,不输入“'< ' 字符后面跟有一些字符并以 '>' 字符结束”的规则表达式,而只需输入一个“'< ' 字符后面跟有任意数量非 '>' 字符并以 '>' 字符结束”的规则表达式。这将与最短、而不是最长的可能性匹配。新命令应该是:


$ sed -e 's/< [^>]*>//g' myfile.html

2006-09-19

Evolution的一个小问题

在使用Evolution 2.6.1时有时会得探出对话框,提示一个错误:
"Error while Expunging folder.
Error storing `~/.evolution/mail/local/Inbox (mbox)': Summary and folder mismatch,even after a sync."

解决办法是删除“~/.evolution/mail/local/Inbox.ev-summary”文件。

这应该是Evolution的一个Bug, http://bugzilla.gnome.org/show_bug.cgi?id=213072 。

在Ubuntu下安装zope 2.9.2

安装很简单,执行命令:

sudo apt-get install zope2.9

zope会被安装在/usr/lib/zope2.9/目录下。

执行/usr/lib/zope2.9/bin/mkzopeinstance.py可以创建一个zope instance。启动如果使用/ets/init.d/zope2.9脚本,总会报告找不到zope instance,无法启动。不过使用$instance/bin/zopectl脚本启动没有问题,只不过默认得端口不再是8080,而是9673。不知道在Ubuntu下安装这个版本,为什么默认端口会被改掉,8080端口保留给什么程序用呢。

2006-08-23

在Ubuntu下安装常用程序

安装apache2:
apt-get install apache2

安装MySQL:
apt-get install mysql-server, mysql-admin

安装php5:
apt-get install php5
apt-get install libapache2-mod-php5
apt-get install php5-gd,php5-mysql, php5-mysqli, php5-xsl, php5-xmlrpc
apt-get install imagemagick
这样LAMP就架设好了!

Ubuntu默认安装不带ssh server

收到Ubuntu寄来的光盘很久了,只是放在光驱里看了看Live CD。今天腾出些空在gepc188上安装了Ubuntu 6.06。安装过程很简单。用光盘启动后会自动运行光盘上的Live系统,桌面上会有一个install的链接,便于用户安装。整个过程除了开始选择语言,键盘布局和分区外,其他都不用用户参与。安装完配置好网络后发现竟然没有ssh server,这可是其他版本默认的配置。不过要安装open ssh server也非常的简单,只需执行:

sudo apt-get install ssh

如果网络连接好,安装很快。安装完毕后ssh服务自动启动。以前一直用suse,接下来的几天用这台机器熟悉一下debian的风格,尤其是早闻大名的apt。

2006-08-11

Unix下的另一个下载工具 curl

At first blush, wget and curl seem similar: Both download files non-interactively. They each have one large difference distinguishing them, however, among many smaller ones: curl supports sequences and sets in specifying what to download, which wget does not, while wget supports recursion, a feature missing from curl.

The programs have plenty of other differences. The full list of curl's features can be seen at "FeaturesWhat Can curl Do" (http://curl.haxx.se/docs/features.html), while some of wget's are listed at "Overview" (www.gnu.org/software/wget/manual/html_node/Overview.html#Overview). The cURL site has a chart comparing curl to other, similar programs at "Compare cURL Features with Other FTP+HTTP Tools" (http://curl.haxx.se/docs/comparison-table.html); while informative, the chart is (unsurprisingly) a bit biased toward curl.

Here's an example that uses curl's capability to support sequences in specifying what to download. The excellent National Public Radio show This American Life makes archives of all of its shows available for download on its parent website in Real Audio format (why they chose Real and not a more open format is a mystery). If you want to download 10 of these Real Audio files, just use the following:
$ curl -O http://www.wbez.org/ta/[1-10].rm
[1/10]: http://www.wbez.org/ta/1.rm --> 1.rm
--_curl_--http://www.wbez.org/ta/1.rm
Notice how you used [1-10].rm to specify that you wanted to download 1.rm, 2.rm, 3.rm, and so on. If WBEZ had instead named the files one.rm, two.rm, and three.rm, for example, you could have used a part set instead:
$ curl -O http://www.wbez.org/ta/{one,two,three}.rm
The -O (or --remote-name) option is absolutely required. If you don't use it, curl writes the output of the download to STDOUT, which means that your terminal will quickly fill with unusable goobledygook. The -O asks curl to write out what it downloads to a file, and to use the name of the file being downloaded as the local filename as well.

wget的几个选项

以前在使用wget时用得比较多的选项包括 -c(续传),-r(递归),-np(不下载父目录),-i(读取一个文件来获得下载地址),-l(下载深度)。今天又学习了几个很有用的选项: -E,-k,-p:

与ssh有关的一个小命令:ssh-copy-id

以前看过不少类似的文章写如何使用ssh不输入密码登录到远程主机。其中中间总会有一步将在本地生成的秘钥对中的公钥拷贝到远程主机,通常的做法都是使用scp命令来拷贝,其实ssh的开发者已经为广大用户想到了这一点,并且提供一个命令 ssh-copy-id 来完成私钥的复制。
NAME
ssh-copy-id - install your identity.pub in a remote machine's authorized_keys
SYNOPSIS
ssh-copy-id [-i [identity_file]] [user@]machine
例如:ssh-copy-id -i .ssh/id_dsa.pub jia@gepc188

2006-08-06

认识grep的几个不常用选项

grep的功能很强大,我用得比较多的选项是 -rsl,列出包含关键字的文件。最近发现grep还有几个选项在查找时虽不常用,但在处理文本时在某些情况下还是很实用的:

-A NUM, --after-context=NUM
打印匹配行后的NUM行

-B NUM, --before-context=NUM
打印匹配行前的NUM行
-C NUM, --context=NUM
打印匹配行前NUM行和后NUM行

-w, --word-regexp
精确匹配