RSS
 

Archive for 07月, 2009

CentOS 5.3 配置SVN

31 Jul

1.安装subversion

$ yum --disablerepo=\* --enablerepo=c5-media install mod_dav_svn subversion

2.创建svn库

$ cd /var/www/svn
$ svnadmin create repos
$ sudo chown apache.apache repos

3.配置subversion.conf

$ vi /etc/httpd/conf.d/subversion.conf

修改内容如下

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, “/var/www/svn”.  Each repository
# must be readable and writable by the ‘apache’ user.  Note that if
# SELinux is enabled, the repositories must be labelled with a context
# which httpd can write to; this will happen by default for
# directories created in /var/www.  Use “restorecon -R /var/www/svn”
# to label the repositories if upgrading from a previous release.
#

#
# To create a new repository “http://localhost/repos/stuff” using
# this configuration, run as root:
#
#   # cd /var/www/svn
#   # svnadmin create stuff
#   # chown -R apache.apache stuff
#

<Location /svn>
DAV svn
SVNParentPath /var/www/svn
#  SVNPath /var/www/svn/repos
#
#   # Limit write permission to list of valid users.
<LimitExcept GET PROPFIND OPTIONS REPORT>
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
AuthType Basic
AuthName “Authorization Realm”
AuthUserFile /etc/svn-auth-conf
Require valid-user
</LimitExcept>
</Location>

4.创建svn用户和密码

$ htpasswd -cm /etc/svn-auth-conf yourusername

5.重启apache服务

$ sudo /sbin/service httpd restart

6.浏览器访问地址

http://localhost/svn/repos

 

CentOS 5.3 配置VNC

30 Jul

服务端配置

1.安装VNC Server

$ sudo yum --disablerepo=\* --enablerepo=c5-media vnc-server

2.为用户vangie设置vnc password

$ su - vangie
$ vncpasswd

3.编辑VNC Server配置文件

$ vi /etc/sysconfig/vncservers

修改内容如下:

# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own).  You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-nohttpd” to prevent web-based VNC clients connecting.

# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the “-via” option in the
# `man vncviewer’ manual page.

# VNCSERVERS=”2:myusername”
# VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -nohttpd -localhost”

VNCSERVERS=”1:vangie”
VNCSERVERARGS[2]=”-geometry 800×600″

4.创建并编辑xstartup脚本

xstartup脚本会在vncserver第一次启动时创建。

$ sudo /sbin/service vncserver start
$ sudo /sbin/service vncserver stop

编辑xstartup

$ vi .vnc/xstartup

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
#twm &
exec gnome-session &

5.启动VNC Server

$ sudo /sbin/service vncserver start

Ubuntu客户端连接

1.安装VNC客户端

$ sudo apt-get install vncviewer

2.连接服务端

$ vncviewer -bgr233 192.168.18.211:1
 

CentOS 5.3 安装中文字体

30 Jul

$sudo yum –disablerepo=\* –enablerepo=c5-media install fonts-chinese
$sudo yum –disablerepo=\* –enablerepo=c5-media install fonts-ISO8859-2

对应的rpm包为

fonts-chinese-3.02-12.el5.noarch.rpm
fonts-ISO8859-2-75dpi-1.0-17.1.noarch.rpm

 
 

CentOS 5.3 安装好以后,普通用户无法登录

30 Jul

CentOS5.3 安装完毕后只有root用户可以登录,普通用户无论是在本地还是在远程都无法登录。

在本地GDM中输入用户名密码后,提示

authentication failed

用户root几次重置密码以后仍然提示认证失败,可以确定不是密码错误。

尝试SSH远程登录,root用户没用问题,而普通用户会提示

Connection closed by 192.168.18.211

如果有意输入错误的密码,则会提示

Permission denied, please try again.

再一次验证不是密码问题。

采用更极端的方法,先用root用户登录,然后在终端

$ su - vangie

长时间没有响应。

开始怀疑是不是ldap的问题,使用authconfig关闭ldap验证

$ authconfig --disableldapauth --update

在winbind 服务重启后,GDM和SSH仍然没法登陆,使用su命令已经可以切换进普通用户了。

更加开始欢迎是网络验证服务的问题,于是

$ authconfig --disablewinbind --update

关停整个winbind服务。

终于GDM和SSH都可以登陆了。

回想起来,安装的时候,好像在新建用户的时候多勾了几个自己也不知道的选项,盲目配置带来了很多的麻烦。

 
 

period-Linux Command

29 Jul

. (source or dot operator)

SYNTAX
      . filename [arguments]

      source filename [arguments]

Read and execute commands from the filename argument in the current shell context.

If filename does not contain a slash, the PATH variable is used to find filename. The current directory is searched if filename is not found in $PATH.

If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged.

The return status is the exit status of the last command executed, or zero if no commands are executed. If filename is not found, or cannot be read, the return status is non-zero.

A period `.’ is a synonym for `source’

source is a bourne shell builtin and a POSIX `special’ builtin

一直没有弄明白为什么”.”命令可以导入其他bash的变量,ubuntu下的man没有该项,原来“.”是source的同义词,并且都是bash的内部命令。

 
No Comments

Posted in bash, linux

 

烦人的easy-share

27 Jul

国内的IP登录easy-share总是要等待500秒,漫长的等待后如果不及时下载又要重新等待,崩溃。

于是在ubuntu下写了一个脚本来提醒自己

首先安装send-notify

sudo apt-get install libnotify-bin

将下面脚本保存为”notifyme”,

#!/bin/bash
sec=$1
msg=$2
if [ -z "$sec" ]
then
sec="500s";
fi

if [ -z "$msg" ]
then
msg="时间到了,赶紧下载吧!";
fi
(sleep $sec && notify-send $msg >/dev/null 2>&1 &)

然后赋予执行权限

chmod 755 notifyme

该命令的执行格式为

notifyme [等时间]  [提醒消息]

 
No Comments

Posted in bash, ubuntu

 

理解shadow和gshadow

26 Jul

如下几个文件和linux中的用户和组相关

/etc/passwd
/etc/shadow
/etc/group
/etc/gshadow

/etc/passwd中的内容形如

root:x:0:0:root:/root:/bin/bash
daemon:x:2:2:daemon:/sbin:/sbin/nologin

其格式如下:

username:password:UID:GID:GECOS:Home Directory:Shell

/etc/shadow中的内容形如

root:$1$RwETwzjv$ifht7L/HiLCPR8Zc935fd0:13675:0:99999:7:::

对比passwd文件和shadow文件,有两个疑问

1.为什么passwd中的存在password字段却存放密码?

2.为什么需要设计一个 shadow文件来存放密码,passwd文件不行吗?

参阅了一些资料,才知道,passwd中的password字段是历史遗留,现在的linux只用一个x来标识是否存在密码,由于passwd文件中存放了除了密码以外还有一些需要被所有用户都需要访问的信息,所有passwd文件对所有用户都是可读的,如果在passwd文件中存放密码,无论是明文还是密文,都是不安全的。任何用户都可以获得passwd文件的拷贝,并对其他用户的密码进行暴力破解(brute-force cracking ).于是设计了shadow文件,以hash的方式来存放用户密码,该文件只有root用户才有读写权限。

用户使用密码进入认证还好理解,group和gshadow有什么作用?难道说用户组也需要认证?

linux下有一个newgrp命令,可以让某个用户临时性的获得默个用户组的权限,此事需要使用用户组密码

$ newgrp finance

可以使用gpasswd密码来设置用户组密码

$ gpasswd finance

参考:

http://meinit.nl/a-group-password-in-linux

http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlshadow.html

 
No Comments

Posted in linux

 

列出系统中所有支持的Shell

26 Jul

Redhat:

$ chsh -l

或者

$ cat /etc/shells

Ubuntu:

$ cat /etc/shells
 

useradd在RedHat和Ubuntu中的差异

26 Jul

linux下使用useradd命令创建一个新用户。

useradd

[-c comment] [-d home_dir]
[-e expire_date] [-f inactive_time]
[-g initial_group] [-G group[,...]]
[-m [-k skeleton_dir] | -M] [-s shell]
[-u uid [ -o]] [-n] [-r] login

该命令在RedHat(CentOS)和Ubuntu中有些小小的差异。

在RedHat下

即使不不使用-m参数,默认也会创建用户主目录,如果想不创建用户主目录,可以使用-M

在Ubuntu下

默认不会创建用户主目录,如果需要创建主目录需要使用-m参数。

也就是说Redhat中默认是-m,而Ubuntu下默认是-M

 

linux用户登陆过程

25 Jul

当我们在命令行提示符或者GUI界面前键入用户名和密码后发生了什么呢?虽然这个过程会随着linux发行版的不同有所差异,但通常一个叫作Login的程序会被调用,并执行以下过程:

1.检查该用户或组是否存在以及该用户是否允许登陆

2.检查该用户是否允许从该位置登录(有些用户只允许从命令行或者本地界面登陆)

3.验证密码是否正确,如果错误,允许有限次的尝试(一般是3次)

4.验证密码是否有限,如果过期了提示用户设定新密码

5.设置用户目录、PATH之类的环境变量

6.启动Shell进程

7.呈现命令行提示符或者GUI界面

 
No Comments

Posted in linux