Linux 打入补丁、 脚本安装程序

目录

打入补丁、 脚本安装程序

打入补丁

补丁的生成

打入补丁

脚本安装程序

脚本程序简介

案例:Webmin 安装


打入补丁、 脚本安装程序

打入补丁

补丁的生成

[root@localhost ~]# diff 选项 old new
  • 比较 old 和 new 文件的不同
  • 选项
    • -a 将任何文档当做文本文档处理
    • -b 忽略空格造成的不同
    • -B 忽略空白行造成的不同
    • -I 忽略大小写造成的不同
    • -N 当比较两个目录时,如果某个文件只在一个目录中,则在另一个目录中视作空文件
    • -r 当比较目录时,递归比较子目录
    • -u 使用同一的输出格式
  • 举例
[root@localhost ~]# mkdir test
#建立测试目录
[root@localhost ~]# cd test
#进入测试目录
[root@localhost test]# vi old.txt
our 
school 
is 
atguigu
#文件 old.txt,为了一会输出便于比较,每行分开
[root@localhost test]# vi new.txt 
our 
school 
is 
atguigu
in
Beijing
#文件 new.txt
  • 比较下两个文件的不同,并生成补丁文件“txt.patch”,命令如下:
[root@localhost test]# diff -Naur /root/test/old.txt /root/test/new.txt > txt.patch
#比较两个文件的不同,同时生成 txt.patch 补丁文件
[root@localhost test]# vi txt.patch
#查看下这个文件
--- /root/test/old.txt 2012-11-23 05:51:14.347954373 +0800
#前一个文件
+++ /root/test/new.txt 2012-11-23 05:50:05.772988210 +0800
#后一个文件
@@ -2,3 +2,5 @@
school
is
atguigu
+in
+beijing
#后一个文件比前一个文件多两行(+表示)

打入补丁

[root@localhost test]# patch –pn < 补丁文件
#按照补丁文件进行更新
  • 选项:
    • -pn n 为数字。代表按照补丁文件中的路径,指定更新文件的位置。
  • “-pn”不好理解,我们说明下。补丁文件是要打入旧文件的,但是你当前所在的目录和补丁文件中的记录的目录是不一定匹配的,所以就需要“-pn”来同步两个目录。
  • 比如我当前是在“/root/test”目录中(我要打补丁的旧文件就在当前目录下),补丁文件中记录的文件目录为“/root/test/old.txt”,这时如果写入“-p1”(在补丁文件目录中取消一级目录)那么补丁文件就会打入“/root/test/root/test/old.txt”文件中,这显然是不对的。那如果写入的是“-p2”(在补丁文件目录中取消二级目录)那么补丁文件打入的就是“/root/test/test/old.txt”,这显然也不对。如果写入的是“-p3”(在补丁文件目录中取消三级目录)那么补丁文件就是打入的“/root/test/old.txt”,我们的 old.txt 文件就在这个目录下,所以就应该是“-p3”。那么我们更新下“old.txt”文件,命令如下:
[root@localhost test]# patch -p3 < txt.patch 
patching file old.txt
#给 old.txt 文件打补丁
[root@localhost test]# cat old.txt 
#查看下 old.txt 的内容吧。
our 
school 
is 
atguigu
in
Beijing
#多出来了 in Beijing 两行

脚本安装程序

脚本程序简介

  • 脚本程序包并不多见,所以在软件包分类中并没有把它列为一类。它更加类似于 Windows 下的程序安装,有一个可执行的安装程序,只要运行安装程序,然后进行简单的功能定制选择(比如指定安装目录等),就可以安装成功,只不过是在字符界面下完成的。
  • 目前常见的脚本程序以各类硬件的驱动居多。

案例:Webmin 安装

  • 简介
    • 我们来看看脚本程序如何安装和使用。安装一个叫作 Webmin 的工具软件,Webmin 是一个基于Web 的系统管理界面。借助任何支持表格和表单的浏览器(和 File Manager 模块所需要的 Java),你就可以设置用户账号、apache、DNS、文件共享等。Webmin 包括一个简单的 Web 服务器和许多 CGI程序,这些程序可以直接修改系统文件,比如/etc/inetd.conf 和 /etc/passwd。
    • Web 服务器和所有的 CGI程序都是用 Perl 5 编写的,没有使用任何非标准 Perl 模块。也就是说,Webmin 是一个用 Perl 语言写的、可以通过浏览器管理 Linux 的软件。
  • 安装步骤
[root@localhost ~]# tar -zxvf webmin-1.610.tar.gz
  • 进入解压目录,命令如下:
[root@localhost ~]# cd webmin-1.610
  • 执行安装程序 setup.sh,并指定功能选项,命令如下:
[root@localhost webmin-1.610]# ./setup.sh
***********************************************************************
* Welcome to the Webmin setup script, version 1.610 *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.
Installing Webmin in /root/webmin-1.610 ...
***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.
Config file directory [/etc/webmin]:
#选择安装位置,默认安装在/etc/webmin 目录下。如果安装到默认位置,则直接回车
Log file directory [/var/webmin]:
#日志文件保存位置,直接回车,选择默认位置
***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.
Full path to perl (default /usr/bin/perl):
#指定 Perl 语言的安装位置,直接回车,选择默认位置,Perl 默认就安装在这里
Testing Perl ...
Perl seems to be installed ok
***********************************************************************
Operating system name: CentOS Linux
Operating system version: 6.3
***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
- What port to run the web server on. There must not be another
 web server already using this port.
- The login name required to access the web server.
- The password required to access the web server.
- If the webserver should use SSL (if your system supports it).
- Whether to start webmin at boot time.
Web server port (default 10000):
#指定 Webmin 监听的端口,直接回车,默认选定 10000
Login name (default admin):admin
#输入登录 Webmin 的用户名
Login password: 
Password again: 
#输入登录密码
The Perl SSLeay library is not installed. SSL not available.
#apache 默认没有启动 SSL 功能,所以 SSL 没有被激活
Start Webmin at boot time (y/n):y
#是否在开机的同时启动 Webmin
…安装过程省略…
Webmin has been installed and started successfully. Use your web
browser to go to
 http://localhost:10000/
and login with the name and password you entered previously.
#安装完成
  • 注: xshell中windows与linux文件传输工具安装

【注】:参考尚硅谷沈超老师教程

猜你喜欢

转载自blog.csdn.net/baidu_41388533/article/details/107765679