星期五, 十一月 30, 2007

通过bash脚本批量创建用户并设置密码

Create Users And Change Passwords With A Bash Script
通过脚本批量创建用户并设置密码

First create a file which contains all the user name.
首先创建一个包还所有用户名的文件,格式如下:
------------------------
nurealam
nayeem
mrahman
farid
rubi
sankar
------------------------
Save the file as userlist.txt. Now create the following bash file:
把该文件保存为userlist.txt。现在创建如下的bash文件:
------------------------
#!/bin/sh
for i in `more userlist.txt `
do
echo $i
adduser $i
done
---------------------------
保存文件为useradd.sh。
运行该脚本文件:
--------------------
[lax@liulantao-com ~]# sh useradd.sh
---------------------
This will add all the users to the system. Now we have to change the
passwords. Let's say we want username123 as password. So for user
nayeem the password will be nayeem123, rubi123 for user rubi and so
on.----www.liulantao.com-----
结果是添加了所有用户名到系统中。现在必须修改密码了。假设我们用使用username123为密码。比如rubi的密码将是rubi123,依此类推。
Create another bash file as follows:
创建下面的脚本文件:
-------------------
#!/bin/sh
for i in `more userlist.txt `
do
echo $i
echo $i"123" | passwd –-stdin "$i"
echo; echo "User $username's password changed!"
done
--------------------
保存为userpasswd.sh。
-------------
[lax@liulantao-com ~]# sh userpasswd.sh
------------
Run the file. All the passwords are changed.
运行该文件。所有的密码被修改


--
Liu Lantao
College of Information Science and Technology, Beijing Normal University
EMAIL: liulantao ( at ) gmail ( dot ) com ;
WEBSITE: http://www.liulantao.com/ .
------
转载本网站文章请保留这一行和以上所有文字,谢谢。

星期日, 十一月 25, 2007

国立北京师范大学校歌

前年社团文化节开幕式的时候合唱了这首歌,歌词和配的曲子,让人感觉很有历史责任感。
闲话不多说,歌词奉上:

------------------------------
国立北京师范大学校歌
范源廉 作歌
冯孝思 作曲
------------------------------

往者文化世所荣
将来事业更无穷
开来继往 师道贯其中
师道 师道 谁兴立
责无旁贷在藐躬

皇皇兮首都
巍巍兮学府
一堂相聚志相同
朝研夕讨乐融融
宏我教化
昌我民治
共矢此愿务成功

------------------------------------------------------------
Liu Lantao
College of Information Science and Technology, Beijing Normal University
EMAIL: liulantao ( at ) gmail ( dot ) com ;
WEBSITE: http://www.liulantao.com/ .

---------- 转载本网站所有文章,请注明出处 ---------

星期二, 十一月 13, 2007

fedora 8 声音问题解决方案

fedora 8 声音问题解决方案

症状:
1、通过system-config-soundcard测试,可以正确识别声卡。
2、普通用户无法调节音量,无法播放声音文件。

解决方法:

[lax@liulantao ~]$ sudo less /etc/security/console.perms.d/50-default.perms
Password:

添加以下内容

#lax defined
#lax defined
<laxaudio>=/dev/dsp* /dev/snd/*
<console> 0666 <laxaudio> 0600 root

重启系统,ok。

参考文章:http://home.nyc.rr.com/computertaijutsu/rhsound.html


--
Liu Lantao
College of Information Science and Technology, Beijing Normal University
EMAIL: liulantao ( at ) gmail ( dot ) com ;
WEBSITE: http://www.liulantao.com/ .
------

fluxbox标题栏、任务栏、菜单中文字体显示问题的解决方案

关于如何设置菜单,请参考网络上其他朋友的文档。
本文主要介绍设置fluxbox中菜单、任务栏、标题栏中显示中文字体的方法。实现平台:fedora 8。

一、请确认你安装了中文的字体。
方法1、
首先在终端运行fc-list命令:

[lax@liulantao .fluxbox]$ fc-list

从中找到支持中文的字体,记下字体名字:

AR PL ZenKai Uni,文鼎PL中楷Uni:style=Medium
AR PL ShanHeiSun Uni,文鼎PL細上海宋Uni,文鼎PL细上海宋Uni:style=Regular

本文使用的就是AR PL ZenKai Uni,即文鼎PL中楷Uni。
如果要使用其它字体,替换成相应的名称。
方法2、
打开firefox,点击View - &gt; Preferences -&gt; Content ,看Default font一项,里面也有字体名称(可能不如方法一中的直观),名字中包含Kai、Sun的大多是中文字体。

二、修改所使用风格的配置文件。如果是自定义风格,修改定义文件;如果风格的名称为Operation(默认风格之一),则修改fluxbox目录下styles文件夹里的Operation:
[lax@liulantao .fluxbox]$ sudo vi /usr/share/fluxbox/styles/Operation
Password: ******


找到:

window.font: lucidasans-10
window.justify: right


注释掉window.font行,修改为:

#window.font: lucidasans-10
window.font: AR PL ZenKai Uni-10
window.justify: right


保存退出,reload config就可以看到窗口的标题栏能够用设置的字体(AR PL ZenKai Uni,10号)显示中文了。

设置其它位置的字体,可以修改相应的font。



Technorati Tags:

Powered by ScribeFire.

星期二, 十一月 06, 2007

计算两个整数最大公约数和最小公倍数的算法:C++语言实现

计算两个整数最大公约数和最小公倍数的算法:C++语言实现

#include <iostream>
using namespace std;
int gcd(int a, int b) //最大公约数
{
while(a!=b)
{ a>b ? a -= a/b * b : b -= b/a * a; }
return a;
}
int lcm(int a, int b) //最小公倍数
{
return a * b / gcd(a,b);
}
int main()
{
int x, y;
cout << "请输入两个正整数:" <<endl;
cin >> x >> y;
cout << "最大公约数: " << gcd(x,y) << " ; 最小公倍数: " << lcm(x,y) << endl;
return 0;
}


--
Liu Lantao
College of Information Science and Technology, Beijing Normal University
EMAIL: liulantao ( at ) liulantao ( dot ) com ;
WEBSITE: http://www.liulantao.com/ .
------