LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: weixiao

RH7.3最终汉化实例与RedHat软件设置

[复制链接]
发表于 2006-7-22 15:11:34 | 显示全部楼层

sign 文件验证软件包(实例)

-------------------------
[  注:升级 gnupg 软件后,操作时出现警告信息:
gpg: WARNING: --honor-http-proxy is a deprecated option.
gpg: please use "--keyserver-options honor-http-proxy" instead
处理方法:  修改 ~/.gnupg/options 内容,‘honor-http-proxy’ 改成: keyserver-options honor-http-proxy   ]

  安装java时从 ftp://ftp.tux.org/pub/java/JDK-1.4.2/i386/03/
下载 j2re-1.4.2-03-linux-i586.bin.sign 和 j2re-1.4.2-03-linux-i586.bin 放置在 /tmp 目录下

前提:正在连接网络,GnuPg 配置正确,可以执行pgp命令
# cd /tmp
# file j2re-1.4.2-03-linux-i586.bin.sign
j2re-1.4.2-03-linux-i586.bin.sign: PGP armored data

# strings j2re-1.4.2-03-linux-i586.bin.sign
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: See http://www.blackdown.org/java-linux/java2-status/signature.html for info
iD8DBQBDi2Dju15FmlKbi9oRAv++AJ9DRGbcPHJOyWIWVsFGdRpGYd9nrgCfS+jX
deX+oEegdvR3g4GiX0PhgDI=
=auid
-----END PGP SIGNATURE-----

  应该浏览网站找到线索(http://www.blackdown.org/java-linux/java2-status/signature.html
  按线索操作:
# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign
gpg: Signature made 2005年11月29日 星期二 03时56分19秒 CST using DSA key ID 529B8BDA
gpg: Can't check signature: public key not found

  导入软体公匙
# gpg --keyserver wwwkeys.pgp.net --recv-keys 0x529B8BDA
gpg: requesting key 529B8BDA from HKP keyserver wwwkeys.pgp.net
gpg: key 529B8BDA: public key imported
gpg: Total number processed: 1
gpg:               imported: 1

# gpg --list-keys 529B8BDA
pub  1024D/529B8BDA 2003-12-18 Blackdown Java-Linux Package Signing Key <package@blackdown.org>
sub  2048g/2C2BB3B9 2003-12-18

# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign
gpg: Signature made 2005年11月29日 星期二 03时56分19秒 CST using DSA key ID 529B8BDA
gpg: BAD signature from "Blackdown Java-Linux Package Signing Key <package@blackdown.org>"

重新下载 j2re-1.4.2-03-linux-i586.bin.sign
# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign
gpg: Signature made 2005年11月29日 星期二 03时56分19秒 CST using DSA key ID 529B8BDA
gpg: Good signature from "Blackdown Java-Linux Package Signing Key <package@blackdown.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Fingerprint: 2409 D2BE 7B62 D250 F691  E827 BB5E 459A 529B 8BDA

# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign j2re-1.4.2-03-linux-i586.bin
gpg: Signature made 2005年11月29日 星期二 03时56分19秒 CST using DSA key ID 529B8BDA
gpg: Good signature from "Blackdown Java-Linux Package Signing Key <package@blackdown.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Fingerprint: 2409 D2BE 7B62 D250 F691  E827 BB5E 459A 529B 8BDA

测试:假如现在有其它 .bin 软件,如 jre-1_5_0_06-linux-i586-rpm.bin
# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign jre-1_5_0_06-linux-i586-rpm.bin
gpg: Signature made 2005年11月29日 星期二 03时56分19秒 CST using DSA key ID 529B8BDA
gpg: BAD signature from "Blackdown Java-Linux Package Signing Key <package@blackdown.org>"

注意:以上是实例过程,一般情况都要参照软件开发指示操作(如:http://www.blackdown.org/java-linux/java2-status/signature.html),常用操作:
> 连接网络,下载软件(如j2re)
> gpg --keyserver wwwkeys.pgp.net --recv-keys 0x529B8BDA [ID]
> gpg --list-keys
> gpg --verify j2re-1.4.2-03-linux-i586.bin.sign
> gpg --verify j2re-1.4.2-03-linux-i586.bin.sign j2re-1.4.2-03-linux-i586.bin
> 显示“gpg: Good signature”,验证顺利

[ 注:下载软件和sign文件验证在当天或同一时段进行最合适,预防加密参数是‘日期’的情况 。]
-------------------------------------

    GnuPg 对‘软件开发团体’信任保证问题

  正如 http://www.blackdown.org/java-linux/java2-status/signature.html 上讲,以下警告出现在“gpg: Good signature”之后不必惊怕。
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.

  紧接以上操作,解决信任保证问题
  # gpg --list-sig Blackdown
[ Blackdown 可以用 529B8BDA 代替]
pub  1024D/529B8BDA 2003-12-18 Blackdown Java-Linux Package Signing Key <package@blackdown.org>
sig 3       730A28A5 2003-12-18   [User id not found]
sig 3       ECC52C06 2003-12-19   [User id not found]
sig 3       529B8BDA 2003-12-18   Blackdown Java-Linux Package Signing Key <package@blackdown.org>
sub  2048g/2C2BB3B9 2003-12-18
sig         529B8BDA 2003-12-18   Blackdown Java-Linux Package Signing Key <package@blackdown.org>

本机 GnuPg 注册人(如weiroot)对 Blackdown 签下信任保证
[ 注:pgp 其它选项显示信息界面 ‘trust: -/- ’,‘/’后的‘-’代表还没有进行签证,有签证是‘f’]

# gpg --sign-key 529B8BDA
gpg: checking the trustdb
gpg: checking at depth 0 signed=0 ot(-/q/n/m/f/u)=0/0/0/0/0/1
pub  1024D/529B8BDA  created: 2003-12-18 expires: never      trust: -/-
sub  2048g/2C2BB3B9  created: 2003-12-18 expires: never     
(1). Blackdown Java-Linux Package Signing Key <package@blackdown.org>
pub  1024D/529B8BDA  created: 2003-12-18 expires: never      trust: -/-
............Fingerprint: 2409 D2BE 7B62 D250 F691  E827 BB5E 459A 529B 8BDA
.....Blackdown Java-Linux Package Signing Key <package@blackdown.org>
How carefully have you verified the key you are about to sign actually belongs
to the person named above?  If you don't know what to answer, enter "0".
.....(0) I will not answer. (default)
.....(1) I have not checked at all.
.....(2) I have done casual checking.
.....(3) I have done very careful checking.

Your selection? 0
Are you really sure that you want to sign this key
with your key: "weiroot (no) <weiroot@163.com>"
Really sign? y
You need a passphrase to unlock the secret key for
passphrase : xxxxxxxxxx 输入 weiroot 生成钥匙对时的密码
user: "weiroot (no) <weiroot@163.com>"
1024-bit DSA key, ID 6997B8A9, created 2006-07-17

# gpg --list-sig Blackdown
pub  1024D/529B8BDA 2003-12-18 Blackdown Java-Linux Package Signing Key <package@blackdown.org>
sig 3       730A28A5 2003-12-18   [User id not found]
sig 3       ECC52C06 2003-12-19   [User id not found]
sig 3       529B8BDA 2003-12-18   Blackdown Java-Linux Package Signing Key <package@blackdown.org>
sig         6997B8A9 2006-07-22   weiroot (no) <weiroot@163.com>
sub  2048g/2C2BB3B9 2003-12-18
sig         529B8BDA 2003-12-18   Blackdown Java-Linux Package Signing Key <package@blackdown.org>

#  gpg --edit-key Blackdown
gpg (GnuPG) 1.0.7; Copyright (C) 2002 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
pub  1024D/529B8BDA  created: 2003-12-18 expires: never      trust: -/f
sub  2048g/2C2BB3B9  created: 2003-12-18 expires: never     
(1). Blackdown Java-Linux Package Signing Key <package@blackdown.org>

Command> trust
pub  1024D/529B8BDA  created: 2003-12-18 expires: never      trust: -/f
sub  2048g/2C2BB3B9  created: 2003-12-18 expires: never     
(1). Blackdown Java-Linux Package Signing Key <package@blackdown.org>
Please decide how far you trust this user to correctly
verify other users' keys (by looking at passports,
checking fingerprints from different sources...)?
1 = Don't know
2 = I do NOT trust
3 = I trust marginally(信任开始)
4 = I trust fully(完全信任)
5 = I trust ultimately(最终信任)
i = please show me more information
m = back to the main menu

Your decision? 3
               
pub  1024D/529B8BDA  created: 2003-12-18 expires: never      trust: m/f
sub  2048g/2C2BB3B9  created: 2003-12-18 expires: never     
(1). Blackdown Java-Linux Package Signing Key <package@blackdown.org>
Please note that the shown key validity is not necessary correct
unless you restart the program.
Command> quit

查看设置后的信息
# gpg --sign-key 529B8BDA

查看验证效果
# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign
# gpg --verify j2re-1.4.2-03-linux-i586.bin.sign j2re-1.4.2-03-linux-i586.bin
gpg: Signature made 2005年11月29日 星期二 03时56分19秒 CST using DSA key ID 529B8BDA
gpg: Good signature from "Blackdown Java-Linux Package Signing Key <package@blackdown.org>"
[ 没有警告信息 ]

[ 注:直接使用软件,是可以不需要sign文件验证或信任保证的步骤 ]
[
   注: 如果操作‘晕’头!可以重新导入公匙,重新试验
# gpg --armor --export  Blackdown > Blackdown.ex
# gpg --list-keys Blackdown
# gpg --delete-keys Blackdown
# gpg --import Blackdown.ex              
# gpg --sign-key 529B8BDA
]

=======
=====
---
回复 支持 反对

使用道具 举报

发表于 2006-7-31 18:04:34 | 显示全部楼层

高手入门考试:

1. 编译安装 banner-1.3.1.tar.gz

http://www.cedar-solutions.com/software.html 下载 banner-1.3.1.tar.gz

#  tar -tzvf banner-1.3.1.tar.gz
# tar -xzvf banner-1.3.1.tar.gz
# cd banner-1.3.1
# more INSTALL
............
............

安装后运行 banner
$ banner morning?

#.....#..#######..######...#.....#..###..#.....#...#####....#####..
##...##..#.....#..#.....#..##....#...#...##....#..#.....#..#.....#.
#.#.#.#..#.....#..#.....#..#.#...#...#...#.#...#..#..............#.
#..#..#..#.....#..######...#..#..#...#...#..#..#..#..####.....###..
#.....#..#.....#..#...#....#...#.#...#...#...#.#..#.....#.....#....
#.....#..#.....#..#....#...#....##...#...#....##..#.....#..........
#.....#..#######..#.....#..#.....#..###..#.....#...#####......#....


2. 修复错误的例子(下面操作是犯错的):

   Gnome桌面打开 gnome-terminal终端机

‘选项’设置字体 -> 浏览‘选取字体’-> 字体:zysong18030 、字体式样:ascii-0 、大小:14 -> 确定 ,选项界面 按‘应用’->‘确定’。

《 开始测试高手之路 ............................》

==========
-------------
-------
回复 支持 反对

使用道具 举报

发表于 2006-7-31 18:15:04 | 显示全部楼层

--------------------- 试玩 linux_logo 软件 &lt;一&gt; ----------------

一 。 安装软件
http://rpmfind.net/linux/rpm2html/)网络搜索并下载 RH7.3 版本的 linux_logo 程序

可选择验证 (rpm -K linux_logo-4.12-1.rh7.rf.i386.rpm)

安装程序
# rpm -ivh linux_logo-4.12-1.rh7.rf.i386.rpm --test
Preparing...                ########################################### [100%]

# rpm -ivh linux_logo-4.12-1.rh7.rf.i386.rpm      
Preparing...                ########################################### [100%]
   1:linux_logo             ########################################### [100%]

# rpm -ql linux_logo
[ linux_logo 资料存放在 /usr/share/doc/linux_logo-4.12/ ]

二 。 试玩软件

1. 显示设置
  普通账户登录 X-Windows(Gnome),打开虚拟终端机,鼠标验证或调整虚拟终端机的窗体(80 X 25),点击左上角方块,下拉列表 -> 历史 -> 选取‘记住尺寸’。gnome-terminal 选项,‘色彩’的前景/背景色:设置成‘黑底白字’。

2. 虚拟终端机,linux_logo 一般操作
$ linux_logo -v
$ linux_logo -h

$ /usr/bin/linux_logo
$ linux_logo -b
[ ‘banner mode’‘标语’模式,显示分成两部分,上部分显示带颜色的字符画,下部分显示固定的系统信息。]

$ linux_logo -a
[ ‘ASCII’模式显示,不带颜色 。]

$ linux_logo -c
[ ‘经典’模式显示,官方提供字符画。]

$ linux_logo -f
[ 清屏后显示 ]

$ linux_logo -g
[ ‘banner mode’‘标语’模式,非‘经典’模式下显示系统固定信息。 ]

$ linux_logo -l
[ 非‘经典’模式下显示字符画。]

$ linux_logo -k
$ linux_logo -g -k
[ 改变显示系统信息的格式,‘文本’向左对齐。]

$ linux_logo -p(光标提示符出现在 linux_logo 显示图案上面。)
$ clear

$ linux_logo -t "hello! sir"
[ 字符画 跟 信息文本 之间插入文本 。]

$ linux_logo -y
$ linux_logo -g -y
[ 添加显示‘平均负载值’。1秒、5秒、15秒的负载值,uptime 命令显示的数据。]

$ linux_logo -g
$ linux_logo -g -d
[ -d 选项是添加 CPU 信息。 ]

$ linux_logo -g -y -d -u

=== [ 注:‘linux_logo -h’后随意愉快地输入命令操作,不要死记选项或步骤。]
=======

3.显示各大发行版的字符画
linux_logo [-L num | list | random_xy]

》显示内置各Linux‘标语’图标的信息

$ linux_logo -L list
Available Built-in Logos:
Num Type Ascii Description
1 Banner Yes The Default Banner Logos
2 Classic Yes The Classic Logos
3 Banner Yes Simplified Banner Logo
4 Banner Yes The Default Banner Logos
.............................................
.............................................

》分别显示各‘标语’图标,如:
$ linux_logo -L 18
$ linux_logo -L 18 -l
$ linux_logo -L 2
$ linux_logo -L 3
$ linux_logo -L 3 -l

》随机显示各‘标语’图标,(以下每条命令选择执行多次)
$ linux_logo -L random

$ linux_logo -L random_ba

$ linux_logo -L random_ee

$ linux_logo -L random_bn

$ linux_logo -f -L random_bn

$ linux_logo -f -l -L random_bn

》命令行设置随机显示10次
$ wn=10;until [ $wn -eq 0 ]; do /usr/bin/linux_logo -f -L random_bn ; sleep 3 ; ((wn=wn-1)) ; done ; unset wn


--------------------- 试玩 linux_logo 软件 <二> --------------
-----------------------------------------------------------------

linux_logo 实用设置操作

  linux_logo 软件原意是把显示信息放在账户登录界面,或者被访问的登录界面,RH 设置如下:

$ su -
# cp -a /etc/issue /etc/issue.w
# cp -a /etc/issue.net /etc/issue.net.w

# vi /etc/rc.d/rc.local
添加以下内容
---------------------
# Add
wei_R=$(date "+%m-%d %T %Z %Y ")
if [ -f /usr/bin/linux_logo ]; then
                echo "" > /etc/issue
                /usr/bin/linux_logo -t "Good morning ! $wei_R " >> /etc/issue
                /usr/bin/linux_logo -a -t "Welcome !!" > /etc/issue.net
                echo >> /etc/issue
             fi
unset wei_R
--------------------

虚拟终端机测试伪装系统信息

查看系统真实信息
$ linux_logo -g
$ linux_logo -g -F "#O Version #V, Compiled #C\n#N #M#X#T #P, #R RAM, #B Bogomips Total\n#H\n"

$ linux_logo -g -k -F "_Bogomips : #B______Compled Date : #C\n_Hostname : #H__________Load average : #L\n_Megahertr : #M_____Number of CPU's : #N\n_Operating System Name : #O___Singular or plural : #P\n_Ram : #R________Type of CPU : #T______CPU Vendor : #X\n_Uptime : #U__________Version of OS : #V\n" > /tmp/System.messages

$ cat /tmp/System.messages

伪装信息
$ linux_logo -g -F "Red Hat Linux release 7.3 , Kernel 2.4.18-3 (smp)\n Server : Proliant DL740 , CPU : Intel Xeon MP\n"

实用伪装系统信息:
$ su -

# vi /etc/rc.d/rc.local
修改添加内容
---------------------
# Add
wei_R=$(date "+%m-%d %T %Z %Y ")
if [ -f /usr/bin/linux_logo ]; then
                echo "" > /etc/issue
                /usr/bin/linux_logo -L 3 -F "Good morning! Boot Time : $wei_R\n Red Hat Linux release 7.3 , Kernel 2.4.18-3 (smp)\n Server : Proliant DL740 , CPU : Intel Xeon MP" >> /etc/issue
         /usr/bin/linux_logo -a -F "Welcome ! Boot Time : Thu Apr 18 07:37:53 EDT 2002\n Red Hat Linux release 7.3 , Kernel 2.4.18-3 (smp)\n Server : HP Proliant DL740 , CPU : Intel Xeon MP\n" > /etc/issue.net
         echo >> /etc/issue
      fi
unset wei_R
--------------------

确定设置了文本登录(/etc/inittab:id:3:initdefault:)。重新启动,测试登录界面。

===========
-----------
-----
回复 支持 反对

使用道具 举报

发表于 2006-7-31 18:30:35 | 显示全部楼层

--------------------- 试玩 linux_logo 软件 &lt;三&gt; ----------------

Linux 系统有一捆 服务/客户 软件,按telnet 功能来分,就有telnet-*.rpm 和 telnet-server-*.rpm软件,RH系统默认安装 telnet-*.rpm客户程式,意思是可以 telnet 开放‘telnet服务’的主机。telnet-server-*.rpm服务软件是可以让外来途径访问本身主机。

测试:
$ rpm -q telnet-server
package telnet-server is not installed

$ ping -c 2 127.0.0.1
PING 127.0.0.1 (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.098 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.063 ms
--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% loss, time 999ms
rtt min/avg/max/mdev = 0.063/0.080/0.098/0.019 ms

$ telnet 127.0.0.1
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

安装 telnet-server 软件
$ su - -c "rpm -ivh /mnt/cdrom/RedHat/RPMS/telnet-server-0.17-20.i386.rpm"
Password:
Preparing...                ########################################### [100%]
   1:telnet-server          ########################################### [100%]

$  rpm -q telnet-server
telnet-server-0.17-20

开启 telnet 服务
$ su -
# setup
System services ->
  • telnet -> [tab]确定

    Panl -> 主菜单 -> 退出, 选择‘重新启动’

    [ 注:安装 telnet-server 服务软件,你有选择是否开启telnet服务。对系统安全没有构成问题。]

    重新登录X-windows,打开虚拟终端机(或者在控制台操作)

    $ cat /etc/issue.net

    $ telnet 127.0.0.1
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    ---------------------------------
    ----------- 字符画 --------------
    ---------------------------------
    --------显示设置的信息-----------
    ---------------------------------

    [假如你没有操作指令,几分钟后自动退出登录界面(login: Connection closed by foreign host.)]

    这时或者选择输入‘root’、‘账户’登录,更或者以下操作:
    '^]' -----> Ctrl + ']'
    login :
    telnet >
    telnet > h
    telnet> close
    Connection closed.

    --------------------- 试玩 linux_logo 软件 <四> --------------
    -----------------------------------------------------------------


    虚拟终端机或控制台界面上小部分显示字符图案,余下部分是工作区:

    $ linux_logo -l -L <num>
    [ 选择喜好的图案并数数单列最大行数 ]

      $ linux_logo -l -L 18 -a

    ...............................................##..............................
    .......###:*###................................###..##.........................
    .....:#:####:###...............................###..##....................##...
    ...._####:###:##:..............................###..##....................##...
    .,###:###########....###.:##..,######.....:###.###..##.####.....######..######.
    .####:::#########....#######..##'..`##..,##:..####..###'.`##...#'....##...##...
    .`#####:::*####:*##..###:'...##:....:##.###....###..##'...`##........##...##...
    ..`########:::*#####.###'....##########.##|....###..##.....##...#######...##...
    ....`###############.###.....##:........##|....###..##.....##..##....##...##...
    ......`############'.###.....###........##|....###..##.....##..##....##...##...
    .........`########'..###.....:##:..,###.###...,###..##.....##..##....##...##...
    ..................(c)###......:#######'.`:#####.##:.##.....##...#####.##..:##..



    选取最大占用行数(12),默认图案:
    $ clear;linux_logo -l; /bin/echo -e '\033[012;25r'

    选取图案:
    $ clear;linux_logo -l -L 18 ; /bin/echo -e '\033[012;25r'
    $ clear;linux_logo -l -L 18 -a; /bin/echo -e '\033[012;25r'

    还原工作区:
    $ /bin/echo -e '\033[0;25r';clear

    [ 或者重新启动虚拟终端机 ]

    ----------------
    ------------
    -------
  • 回复 支持 反对

    使用道具 举报

    发表于 2006-8-14 16:07:07 | 显示全部楼层

    分割文件工具:split

    找大Size 测试文件。/var/log目录下文件Size是随使用时间递增,测试文件例子:/var/log/lastlog(18M)

    $ mkdir /tmp/test
    $ cp  /var/log/lastlog /tmp//test/lastlog-test

    $ cd /tmp/test

    $ ls -l lastlog-test
    -rw-r--r--    1 wei      wei      19136220  x  x xx:xx /tmp/lastlog-test


    大概认识 split 选项:
    -l <行数> : 指定每多少行切割成一个小文件。
    -b <字节> : 指定每多少字节切割成一个小文件。
    -C <字节> : 与 -b 选项类似,但切割时尽量维持每行的完整性。


    切割文件测试:
    $ split -b 1395k lastlog-test lastlog-split-file-
    $ ls -l lastlog-split-file-*
    -rw-rw-r--    1 wei      wei       1428480  x  x xx:xx lastlog-split-file-aa
    -rw-rw-r--    1 wei      wei       1428480  x  x xx:xx lastlog-split-file-ab
    .......................................................
    .......................................................
    -rw-rw-r--    1 wei      wei       1428480  x  x xx:xx lastlog-split-file-am
    -rw-rw-r--    1 wei      wei        565980  x  x xx:xx lastlog-split-file-an


    合并文件:
    $ cat lastlog-split-file-?? > lastlog-split-test

    验证文件:
    $ ls -l
    $ ls -l lastlog-test lastlog-split-test
    -rw-rw-r--    1 wei      wei      19136220  x  x xx:xx lastlog-split-test
    -rw-r--r--    1 wei      wei      19136220  x  x xx:xx lastlog-test

    $ diff lastlog-test lastlog-split-test

    ------------
    ----------
    -------
    回复 支持 反对

    使用道具 举报

    发表于 2006-8-14 16:12:32 | 显示全部楼层

    以下脚本是显示终端机颜色代码表

    -------------------------------------
    #!/bin/bash
    # ANSI colors list
    pfm="%-15s%-15s%-15b\t%-15s%-15b\n"
    printf "%-15s%-10s%-15s%-10s%-15s\n" Colors Code foreground Code background
    printf "%s\n" "------------------------------------------------------------"
    printf "$pfm" "black" "\e[30m" "\e[30mYES\e[0m" "\e[40m" "\e[40m____\e[0m"
    printf "$pfm" "red" "\e[31m" "\e[31mYES\e[0m" "\e[41m" "\e[41m____\e[0m"
    printf "$pfm" "green" "\e[32m" "\e[32mYES\e[0m" "\e[42m" "\e[42m____\e[0m"
    printf "$pfm" "yellow" "\e[33m" "\e[33mYES\e[0m" "\e[43m" "\e[43m____\e[0m"
    printf "$pfm" "blue" "\e[34m" "\e[34mYES\e[0m" "\e[44m" "\e[44m____\e[0m"
    printf "$pfm" "purple" "\e[35m" "\e[35mYES\e[0m" "\e[45m" "\e[45m____\e[0m"
    printf "$pfm" "cyan" "\e[36m" "\e[36mYES\e[0m" "\e[46m" "\e[46m____\e[0m"
    printf "$pfm" "white" "\e[37m" "\e[37mYES\e[0m" "\e[47m" "\e[47m____\e[0m"
    printf "%s\n" "------------------------------------------------------------"
    cat << EOF
    Other:  clear: "\e[2J" ; resettings: "\e[0m" ; brightness: "\e[3m"
    bold: "\e[1m" ; boldoff: "\e[22m" ; blink: "\e[5m" ; blinkoff: "\e[25m"
    ulon: "\e[4m" ; uloff: "\e[24m" ; invon: "\e[7m" ; invoff: "\e[27m"
    EOF

    echo -e "\e[1mExample : \e[0m"
    echo -n "Code: echo -e \"\e[35;1m1\e[0m\e[7m2\e[27m3\e[0m -- 123\" : "
    echo -e "\e[35;1m1\e[0m\e[7m2\e[27m3\e[0m -- 123"
    echo "Code: echo -e \"\033[33m\033[41m Strings 1 \033[43m\033[31m Strings 2 \033[0m\""
    echo "Code: echo -e \"\e[33;41m Strings 1 \e[43;31m Strings 2 \e[0m\""
    echo -e "\033[33m\033[41m Strings 1 \033[43m\033[31m Strings 2 \033[0m"
    echo -e "\e[1mCommand Example :\e[0m"
    cat << EOF
    $ bash
    $ export PS1="\[\e[36;1m\]\u\e[35m@\[\e[32;1m\]\H> \[\e[0m\]"
    $ exit
    EOF
    ----------------------------------

    练习例子:
    $ "运行脚本"
    $ echo -e "\e[33mHello"
    $ echo -e "\e[33;46;1mHello"
    $ echo -e "\e[0m"
    $ echo -e "\e[2J"
    $ echo -e "\e[33;46;1mHello\e[0m"

    [ -----脚本注释:
    ------------------------------------
    ‘echo -e ’中‘-e’选项是激活特殊字符的解析器。
    ‘\e[0m’:‘\e’或‘\033’是引导非常规字符的序列,‘\e[’转义方括号是开启解析序列中的数字编码,‘0’数字编码意味着 重新设置属性到缺省设置,‘m’是设置属性后结束非常规字符序列。
    ------------------------------------
    原文....编码.......颜色/动作.....编码...颜色/动作
    black....30......设置黑色前景.....40..设置黑色背景
    red......31......设置红色前景.....41..设置红色背景
    green....32......设置绿色前景.....42..设置绿色背景
    yellow...33......设置黄色前景.....43..设置黄色背景
    blue.....34......设置蓝色前景.....44..设置蓝色背景
    purple...35......设置紫色前景.....45..设置紫色背景
    cyan.....36......设置青色前景.....46..设置青色背景
    white....37......设置白色前景.....47..设置白色背景
    ------------------------------------
    Other:
    原文.........编码....颜色/动作
    clear.........2J......清屏
    resettings.....0......重新设置属性到缺省设置
    brightness.....2......设置一半亮度(模拟彩色显示器的颜色)
    bold...........1......设置粗体
    boldoff.......22......设置一般密度(关闭粗体)  
    blink..........5......设置闪烁
    blinkoff......25......关闭闪烁
    ulon...........4......设置下划线(模拟彩色显示器的颜色)
    uloff.........24......关闭下划线
    invon..........7......设置反色显示图案
    invoff........27......关闭反色显示图案

    ------------------------------------ < 详细:man console_codes > ---- ]

    [ 注:blink 、blinkoff 编码选项的显示闪烁效果只在控制台(黑屏)有效。假如控制台是操作在虚拟机软件(如:VMware < 5.5.1),也没有闪烁效果。]

    -----------
    --------
    ---
    回复 支持 反对

    使用道具 举报

    发表于 2006-8-14 16:27:36 | 显示全部楼层

    抓取RPM或tar 、tar.gz等软件包里的文件

    编写脚本
    $ [ -d ~/bin ] || mkdir ~/bin
    $ cd ~/bin

    $ vi wglom_rpm
    ----------------------------
    #!/bin/bash
    # Scriptname : wglom_rpm
    # Script to fetch rpm|tar|tgz|tar.gz file
    # Help : wglom_rpm -h
    ###-------------------------------------###
    if [ $# -eq 1 -a "$1" = "-h" ];then
    echo "---------------------------------"
    cat << EOF
    Usage : wglom_rpm Package_name.rpm [-i] [ filename | full ]
    Example:
    1. list rpm file:     wglom_rpm Package_name.rpm
    2... seach file :     wglom_rpm Package_name.rpm | grep *.jpg
    3... fetch file :     wglom_rpm Package_name.rpm -i [full-path]/filename
    4. fetch full file : wglom_rpm Package_name.rpm -i full
    EOF
    echo  "---------------------------------"
    exit
    fi
    ## ----------------------------------
    if [[ $# -ne 0 && -f $1 ]] ;then
    if [[ $# -gt 1 && "$2" != "-i" ]] ;then
    echo "wglom_rpm : invalid parameter."
    exit;fi
    if [ ! -r $1 ] ;then
    echo "wglom_rpm : open of $1 failed: Permission denied"
    exit
    fi;fi
    if [[ $# -ne 0 && -f $1 ]] ;then
    if /usr/bin/file $1 | grep -q RPM ;then
    bag=rpm
    else
    bag=n
    fi
    else
    echo "wglom_rpm : No Packages ";exit
    fi
    if [ $bag = n ] ;then
    if /usr/bin/file $1 | grep -q "GNU tar archive" ;then
    bag=tar
    fi;fi
    if [ $bag = n ] ;then
    if /usr/bin/file $1 | grep -q "gzip compressed data" ;then
    tar -tzf $1 > /tmp/wei_wglom.test.yes 2> /tmp/wei_wglom_tgz.test.wei
    if [[ ! -s /tmp/wei_wglom_tgz.test.wei && -s /tmp/wei_wglom.test.yes ]]
    then
    bag=tgz
    fi;fi;fi
    [ -f /tmp/wei_wglom_tgz.test.wei ] && rm -f /tmp/wei_wglom_tgz.test.wei
    [ -f /tmp/wei_wglom.test.yes ] && rm -f /tmp/wei_wglom.test.yes
    echo "bag: $bag"
    if [ $bag = n ] ;then
    echo "wglom_rpm : argument is not an ( rpm|tar|tgz|tar.gz ) package"
    exit
    fi
    ##-------------------------------
    wEX=0
    if [ $(id -gn) = root ];then echo  "wglom_rpm : NO need for Root Permission";wEX=1;fi
    if [ -x /bin/cpio -a -x /usr/bin/rpm2cpio ]
    then
    :
    else
    echo "cpio or rpm2cpio is not installed";wEX=1
    fi
    if [ $wEX -eq 1 ];then echo "Make haste, police come up."; exit;fi
    ##------------------------------
    rpmname=$(basename "$1")
    workdir=$(echo $rpmname | awk -F '.' '{print $1}')
    [ -d /tmp/sharddir ] || mkdir /tmp/sharddir
    [ -d /tmp/sharddir/"$workdir" ] || mkdir /tmp/sharddir/"$workdir"
    ban=" OK , enjoy --- > file Save in /tmp/sharddir/$workdir"
    ##---- fetch tar ---------------
    if [ $bag = tar ] ;then
    if [ -s /tmp/sharddir/"$workdir"/"$worddir".tarlist ] ;then
    :
    else
    tar -tf "$1" > /tmp/sharddir/"$workdir"/"$workdir".tarlist
    fi
    [ $# -eq 1 ] && cat /tmp/sharddir/"$workdir"/"$workdir".tarlist
    if [ $# -eq 3 -a "$2" = "-i" ] ;then
    if [ -f /tmp/sharddir/"$workdir"/"$rpmname" ]
    then
    :
    else
    cp $1 /tmp/sharddir/"$workdir"/
    fi
    cd /tmp/sharddir/"$workdir"
    if [ "$3" = "full" ] ;then
    tar -xf /tmp/sharddir/"$workdir"/"$rpmname"
    echo $ban
    exit
    fi
    if grep -q -x "$3" /tmp/sharddir/"$workdir"/"$workdir".tarlist
    then
    tar -xf /tmp/sharddir/"$workdir"/"$rpmname" $3
    echo $ban;exit
    else
    if grep -q "$3" /tmp/sharddir/"$workdir"/"$workdir".tarlist
    then
    echo " fetch files  no found > $3 "
    echo -n "Tips files forms > "
    grep "$3$" /tmp/sharddir/"$workdir"/"$workdir".tarlist
    echo;exit
    else
    echo " look at lists -- > please check parameters."
    fi;fi
    else
    [ $# -ne 1 ] && echo "----- > please check parameters."
    fi;fi

    ##---- fetch tgz ---------------
    if [ $bag = tgz ] ;then
    if [ -s /tmp/sharddir/"$workdir"/"$worddir".tgzlist ] ;then
    :
    else
    tar -tzf "$1" > /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    fi
    [ $# -eq 1 ] && cat /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    if [ $# -eq 3 -a "$2" = "-i" ] ;then
    if [ -f /tmp/sharddir/"$workdir"/"$rpmname" ]
    then
    :
    else
    cp $1 /tmp/sharddir/"$workdir"/
    fi
    cd /tmp/sharddir/"$workdir"
    if [ "$3" = "full" ] ;then
    tar -xzf /tmp/sharddir/"$workdir"/"$rpmname"
    echo $ban
    exit
    fi
    if grep -q -x "$3" /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    then
    tar -xzf /tmp/sharddir/"$workdir"/"$rpmname" $3
    echo $ban;exit
    else
    if grep -q "$3" /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    then
    echo " fetch files  no found > $3 "
    echo -n "Tips files forms > "
    grep "$3$" /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    echo;exit
    else
    echo " look at lists -- > please check parameters."
    fi;fi
    else
    [ $# -ne 1 ] && echo "----- > please check parameters."
    fi;fi

    ##---- fetch RPM ---------------
    if [ $bag = rpm ] ;then
    if [ -s /tmp/sharddir/"$workdir"/"$workdir".list ] ;then
    :
    else
    rpm2cpio $1 | cpio -t --quiet > /tmp/sharddir/"$workdir"/"$workdir".list
    fi
    [ $# -eq 1 ] && cat /tmp/sharddir/"$workdir"/"$workdir".list
    if [ $# -eq 3 -a "$2" = "-i" ];then
    if [ -f /tmp/sharddir/"$workdir"/"$workdir".cpio ];then
    :
    else
    rpm2cpio $1 > /tmp/sharddir/"$workdir"/"$workdir".cpio
    fi
    cd /tmp/sharddir/"$workdir"
    if [ "$3" = "full" ] ;then
    cpio -d --quiet -i < /tmp/sharddir/"$workdir"/"$workdir".cpio
    echo "---- >"
    echo $ban
    exit
    fi
    if grep -q -x "$3" /tmp/sharddir/"$workdir"/"$workdir".list
    then
    cpio -d --quiet -i $3 < /tmp/sharddir/"$workdir"/"$workdir".cpio
    echo "---- >"
    echo $ban
    exit
    else
    if grep -q "$3" /tmp/sharddir/"$workdir"/"$workdir".list
    then
    echo " fetch files  no found > $3 "
    echo -n "Tips files forms > "
    grep "$3$" /tmp/sharddir/"$workdir"/"$workdir".list
    echo;exit
    else
    echo " look at lists -- > please check parameters."
    fi;fi
    else
    [ $# -ne 1 ] && echo "----- > please check parameters."
    fi
    fi
    ----------------------------

    附加执行权限:
    $ chmod +x wglom_rpm

    例子:
    1)
    $ wglom_rpm -h

    $ wglom_rpm /tmp/banner-1.3.1.tar.gz
    bag: tgz
    banner-1.3.1/
    banner-1.3.1/README
    ....................
    banner-1.3.1/INSTALL
    ....................
    ....................

    抓取 INSTALL
    $ wglom_rpm /tmp/banner-1.3.1.tar.gz -i banner-1.3.1/INSTALL
    bag: tgz
    OK , enjoy --- > file Save in /tmp/sharddir/banner-1

    $ ls -R /tmp/sharddir/banner-1

    2)
    $ wglom_rpm /tmp/xdesktopwaves-1.3-1.0.rh7.rf.i386.rpm
    ./usr/bin/xdesktopwaves
    ./usr/share/doc/xdesktopwaves-1.3
    ./usr/share/doc/xdesktopwaves-1.3/COPYING
    ./usr/share/doc/xdesktopwaves-1.3/README
    ./usr/share/man/man1/xdesktopwaves.1.gz

    抓取README文档:
    $ wglom_rpm /tmp/xdesktopwaves-1.3-1.0.rh7.rf.i386.rpm -i ./usr/share/doc/xdesktopwaves-1.3/README
    bag: rpm
    OK , enjoy --- > file Save in /tmp/sharddir/xdesktopwaves-1

    ------
    提示:
    ------
    应该考虑 保存抓取后的文件并删除 /tmp/sharddir 内的文件
    $ rm -rf /tmp/sharddir

    或者:
    /etc/cron.daily/tmpwatch 添加以下内容:
    ##--------------- Add ---##
    [ -d /tmp/sharddir ] && /usr/sbin/tmpwatch 24 -f -q /tmp/sharddir
    ##---------------##

    注:程序特点能判断假如文件名后缀不是 tar.gz,是否是tar.gz格式情况的文件。我最近整理文档时发现似乎‘脚本’实用,帖了上来。

    附件:wglom_rpm.gz(‘脚本’打包)

    --------------
    --------

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?注册

    x
    回复 支持 反对

    使用道具 举报

    发表于 2006-8-14 16:55:36 | 显示全部楼层

    RH“虚拟桌面”的应用

    ----------------
    试玩‘动态桌面’软件:

    下载并安装 :xdesktopwaves-1.3-1.0.rh7.rf.i386.rpm

    Gnome桌面系统提供四个‘虚拟桌面’,Panl面板设置成‘田’字型的四个按钮选择器,分别点击选择转换按钮,快捷键:Alt+F1、Alt+F2、Alt+F3和Alt+F4 。

    选择其中一个桌面操作:
    打开虚拟终端机
    $ rpm -q  xdesktopwaves
    xdesktopwaves-1.3-1.0.rh7.rf

    $ rpm -ql xdesktopwaves

    运行软件:
    $ xdesktopwaves

      分别点击‘田’字型的按钮选择器或者使用快捷键,转换桌面查看xdesktopwaves软件显示效果。返回原桌面的虚拟终端机按‘Ctrl+C’停止程序。

    分别输入命令重复以上的操作,挑选合适的显示效果
    $ xdesktopwaves -colortheme 9 -verbose
    $ xdesktopwaves -quality 3 -colortheme 1 -root -stippled
    $ xdesktopwaves -quality 6 -colortheme 5 -window -opaque -rain 7
    $ xdesktopwaves -quality 4 -colortheme 3 -storm 8
    $ xdesktopwaves -quality 8 -colortheme 5

    添加菜单入口,启动xdesktopwaves程序
      Panl面板 -> 程序 -> Settings -> Menu editor
      菜单编辑程序界面:选择子菜单 -> 建新选项 -> 名称:动态桌面 | 命令:xdesktopwaves  -> 保存
      建新选项 -> 名称:关闭动态桌面 | 命令:xdesktopwaves -end  -> 保存
      退出菜单编辑程序

    现在可以随便在某一‘虚拟桌面’启动或关闭 xdesktopwaves 程序。软件显示的视觉效果好像是‘水上飘’。

    ------
    RH有自带动态桌面程序(xsnow-1.42-3),安装系统时有选择软件包,会在 程序 -> Game -> xsnow 。或者命令行输入:

    $ man xsnow
    $ xsnow
    $ xsnow -snowflakes 1000 -delay 0

    停止程序有点麻烦:
    1. 命令行启动,按‘ctrl+c’
    2. 菜单启动或后台作业(&), ‘ ps -ef|grep xsnow ’ -> 找出 PID ,然后‘ kill <ID> ’

    -------------
    注:RH7.3 操作的经验:
       我使用的 RH7.3 操作系统是正版的拷贝版,平时用普通帐号操作默认Gnome桌面。一段时间后,Panl面板上视觉或功能自动欠缺,按照Panl单独程序来修复行不通的。假如你不明白是什么情况,你可以在Gnome桌面Panl面板右击‘田’字型的四个按钮选择器,选择‘从面板上去掉’,然后试试修复,你会知道是什么回事。

    解决办法:
    假如操作帐号是‘wei’,root权限重新登录控制台(黑屏)
    # userdel wei
    # mv /home/wei /home/wei-backup
    # useradd wei
    # passwd wei
    # exit

    ‘wei’操作帐号(startx)重新登录 X-Windows(Gnome桌面),查看Panl修复情况 。

    ---------------
    ---------:cool:
    回复 支持 反对

    使用道具 举报

    发表于 2006-8-18 15:10:15 | 显示全部楼层

    测试:一个脚本对‘管道’,‘信号’疑问 1

    --------------------------
    准备:Bash环境,测试文件内容行数( > 25 )。

    制作测试文件
    $ cd /tmp
    $ dmesg | wc -l


    $ dmesg > /tmp/sig_test
    $ cat /tmp/sig_test | more
    $ cat /tmp/sig_test | wc -l
    [ 应该超过25行数 ]


    编写脚本
    $ vi ./script_test
    -------------------
    #!/bin/bash
    cat /tmp/sig_test
    -------------------


    执行脚本
    $ chmod +x ./script_test
    $ ./script_test


    发现疑问
    $ ./script_test | more
    [ 分页浏览时按Enter‘RETURN’(行浏览)或按‘SPACE’(页浏览) ]
    [ 未翻完全部页面时按‘q’退出浏览,出现以下错误 ]
    .....................
    .....................[Error:]
    ./script_test: line 2:  1695 Broken pipe             cat /tmp/sig_test


      注:发送一个SIGPIPE信号。Broken pipe行为是指“如果管道中的某个命令产生了一个异常,并中途失败,那么这个管道将过早的终止”。

    应该属于‘No arguments error’,相对编写脚本来看,这样错误信息碍眼且不观赏。

    试验修改脚本
    $ vi ./script_test
    -------------------
    #!/bin/bash
    trap 'echo current trap set : `trap`' 0
    cat /tmp/sig_test
    -------------------

    [ 注:''是一对单引号。`trap`中 `` 是 ~ 键下的 ` 执行符,`trap`命令是显示当前信号设置。0 代表 EXIT 信号,是脚本正常退出信号 ]

    $ ./script_test | more
    [不按‘q’翻完页面,显示预设信息]
    ...................
    ...................
    current trap set : trap -- 'echo current trap: `trap`' EXIT


    按原意修饰错误信息,修改脚本
    1)
    $ vi ./script_test
    -------------------
    #!/bin/bash
    trap 'echo' 13
    cat /tmp/sig_test
    -------------------


    $ ./script_test | more
    中途按‘q’退出页面,察看修饰信息
    ..................
    ..................
    Broken pipe

    [ 美观多了 ]


    2)
    $ vi ./script_test
    -------------------
    #!/bin/bash
    {
    cat /tmp/sig_test
    } 2> /dev/null
    -------------------


    $ ./script_test | more
    进行测试


    [更有专业风格!]

    -----------------
    ----------
    回复 支持 反对

    使用道具 举报

    发表于 2006-8-18 15:13:41 | 显示全部楼层

    测试:一个脚本对‘管道’,‘信号’疑问 2

    ----------------------------------
       原本是操作wglom_rpm脚本发觉‘一个脚本对‘管道’,‘信号’疑问 1’的‘No arguments error’问题(wglom_rpm Package_name.rpm | more )。实用操作没太大障碍,贴到网上就要说明,挑剔。

       按原意修饰错误信息,修改脚本‘1)’:进程间有相互通信的动机才有信号,信号是由内核的信号机制处理。对于例子中简单的测试脚本,可以果断添加信号操作指令,对于复杂的脚本或带扩展性,添加信号操作指令对影响略带未知数。

    wglom_rpm 脚本可以选择按以下修改(附件已经更新,抱歉!)
    1. ##---- fetch tar ---------------
    2. [ $# -eq 1 ] && cat /tmp/sharddir/"$workdir"/"$workdir".tarlist
    3. 修改成:
    4. if [ $# -eq 1 ];then
    5. {
    6. cat /tmp/sharddir/"$workdir"/"$workdir".tarlist
    7. } 2> /dev/null
    8. fi
    9. ##---- fetch tgz ---------------
    10. [ $# -eq 1 ] && cat /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    11. 修改成:
    12. if [ $# -eq 1 ];then
    13. {
    14. cat /tmp/sharddir/"$workdir"/"$workdir".tgzlist
    15. } 2> /dev/null
    16. fi
    17. ##---- fetch RPM ---------------
    18. [ $# -eq 1 ] && cat /tmp/sharddir/"$workdir"/"$workdir".list
    19. 修改成:
    20. if [ $# -eq 1 ];then
    21. {
    22. cat /tmp/sharddir/"$workdir"/"$workdir".list
    23. } 2> /dev/null
    24. fi
    复制代码
    ------------
    --------
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表