Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tar, cpio package decompression. Shell script for,while,until loop. Rpm package Management, select Loop menu, function function,yum

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Tar

Tar-cf path + file name followed by .tar + path to create archive compression

Tar cf / testdir/etc.tar / etc/

Tar cvf can view the decompression process.

Tar tvf Preview function

Tar xvf decompresses the file

Tar zcvf / testdir/etc2.tar.gz / etc/ decompress and then compress to the specified path, file format

Tar jcvf

Cpio

Copy from or to a file

The cpio command is a tool to package and backup files and restore them through redirection. it can be unzipped with ".cpio" or ".tar".

The file at the end.

Cpio [options] > file name or device name

Cpio [options]

< 文件名或者设备名 -o 将文件拷贝打包成文件或者将文件输出到设备上 -i 解包,将打包文件解压或将设备上的备份还原到系统 -t 预览,查看文件内容或者输出到设备上的文件内容 -v 显示打包过程中的文件名称。 -d 解包生成目录,在cpio还原时,自动的建立目录 -c 一种较新的存储方式 cpio -ivd < /root/etc.cpio shell 脚本 循环执行 将某代码段重复运行多次 重复运行多少次: 循环次数事先已知 循环次数事先未知 有进入条件和退出条件 for, while, until for for 变量名 in 列表;do 循环体 ;done for NAME [in WORDS ... ] : do COMMANDS :done 循环列表 for id in "$@" do echo "the number is $id" done 列表生成方式: (1) 直接给出列表 (2) 整数列表: (a) {start..end} (b) $(seq[start [step]] end) (3) 返回列表的命令 $(COMMAND) (4) 使用glob,如:*.sh (5) 变量引用; $@, $* while循环 while CONDITION; do 循环体 done CONDITION:循环控制条件;进入循环之前,先做一次判断;每一次循环之后会再次做判断;条件为"true",则执行一次循环;直到条件测试状态为"false"终止循环 因此:CONDTION一般应该有循环控制变量;而此变量的值会在循环体不断地被修正 进入条件:CONDITION为true 退出条件:CONDITION为false until循环 until CONDITION; do 循环体 done 进入条件:CONDITION 为false 退出条件:CONDITION 为true 循环控制语句continue continue(中断当次循环) break (打断之后的循环) exit(直接退出脚本) while CONDTIITON1; do CMD1 ... if CONDITION2; then continue(break) fi CMDn ... done 创建无限循环 while true; do 循环体 done until false; do 循环体 Done 软件包管理 程序源代码-->

Preprocessing-- > compile-- > Assembly-- > Link

Windows is not compatible with Linux

(all binaries have different formats)

Java

The binary file format is .class

Binaries can be run on a variety of platforms through recompilation.

Package Manager

Components of a binary application:

Binaries, library files, configuration files, help files

Package Manager:

Debian:deb file, dpkg package manager

Redhat: rpm file, rpm package manager

Rpm: RedhatPackage Manager

RPM Package Manager

Source code: name-VERSION.tar.gz | bz2 | xz

How the rpm package is named:

Name-VERSION-release.arch.rpm

Example: bash-4.2.46-19.el7.x86_64.rpm

Common arch:

X86: i386, i486, i586, i686

X86_64: x64, x86_64, amd64powerpc: ppc

Platform independent: noarch

Noarch is a compatible version, 32-bit files can run on 64-bit systems, but 64-bit files cannot run on 32-bit systems.

Packet classification and unpacking

Application-VERSION-ARCH.rpm: main package

Application-devel-VERSION-ARCH.rpm development subpackage

Other subpackages of Application-utils-VERSION-ARHC.rpm

Other subpackages of Application-libs-VERSION-ARHC.rpm

Between packages: there may be dependencies, even circular dependencies

Resolve dependency package management tools:

Yum (main usage tool): the front-end tool for the rpm package manager

Apt-get:deb package Manager front-end tools

Zypper: rpm front-end management tool on suse

Dnf (a new tool in the testing phase): Fedora 18 + rpm package Manager front-end management tool

View the library files that the binary depends on:

Ldd/PATH/TO/BINARY_FILE

Manage and view the library files loaded on this machine:

Ldconfig

/ sbin/ldconfig-p: displays all available library files that have been cached on this machine

Mapping relationship between name and file path

Configuration file: / etc/ld.so.conf, / etc/ld.so.conf.d/*.conf

Cache file: / etc/ld.so.cache

Third-party software, write the path to the library folder after installation

To get it into memory.

Package Manager

Rpm

Package Manager:

Function: package one or more package files from each component file of the compiled application, so as to easily and quickly realize the management operations such as installation, uninstallation, query, upgrade and verification of the package.

1. Composition of package files (unique to each package)

Files in the RPM package

RPM metadata, such as name, version, dependency, description, etc.

Scripts that run when installing or uninstalling

Check the contents of the package before installing it to prevent malicious scripts from running. )

2. Database (public)

Package name and version

Dependencies (package dependencies are all in)

Function description

File path and check code information generated after package installation

(you can compare whether the program has changed)

How to manage packages:

Use the package manager: rpm

Use the front-end tool: yum

The way to get the package:

(1) the CD-ROM of the system version or the official server

CentOS image:

Https://www.centos.org/download/

Http://mirrors.aliyun.com

Http://mirrors.sohu.com

Http://mirrors.163.com

(2) official site of the project

(3) third-party organizations:

Fedora-EPEL:

Extra Packages for Enterprise Linux

Recommended by Rpmforge:RHEL, the package is very complete

Search engine:

Http://pkgs.org

Http://rpmfind.net

Http://rpm.pbone.net

Https://sourceforge.net/

(4) make it yourself.

Note: check its legitimacy: source legitimacy, package integrity

Management of rpm package

Rpm-I installation

Use the rpm command to manage the package on a CentOS system:

Installation, uninstallation, upgrade, query, verification, database maintenance

Installation:

Rpm {- I |-- install} [install-options] PACKAGE_FILE...

-v: verbose

-vv: display the content in more detail

-h: displays the progress of package management execution in #

Rpm-ivh PACKAGE_FILE...

Rpm-ivh

-e uninstall

-- test: test the installation, but do not actually perform the installation; dry run mode

-- nodeps: ignore dependencies

-- replacepkgs | replacefiles

(same bag, same version. Overwrite installation | version number, file name is different, but there are duplicate files, overwrite installation. )

-- nosignature: do not check the validity of the source

-- nodigest: do not check package integrity

-- noscipts: do not execute package script fragments

% pre: pre-installation script;-- nopre

% post: post-installation script;-- nopost

% preun: pre-uninstall script;-- nopreun

% postun: script after uninstallation;-- nopostun

Upgrade:

Rpm-U

Rpm-F

Upgrade: upgrade if an old package is installed

If there is no legacy package, install

Freshen: upgrade if an old package is installed

If there is no legacy package, no upgrade operation is performed

-- oldpackage: downgrade

-- force: force upgrade (mandatory command). Can be mixed with other instructions)

Note:

Ls kernel-* View Kernel package

The kernel is installed, rpm-ivh kernel-*. Keep the old kernel and install the new kernel. You can choose which kernel version to run by rebooting.

(1) do not upgrade the kernel; Linux supports the coexistence of multiple kernel versions, so install a new version of the kernel directly

(the upgrade removes the old kernel version)

(2) if the configuration file of the original package has been modified after installation, the same configuration file provided by the new version will not directly overwrite the configuration file of the old version, but the new version of the file will be renamed (FILENAME.rpmnew) and retained.

While

Special usage

While read line: do

(input without input variables is true $? = 0)

While read-p "good morning" hello;do echo $hello; done (will always loop through you)

Pass one line to deal with one line

(())

The (()) usage of C language style

Let iTunes 10; iTunes 10; echo $I

ITunes 10; (iTunes +); echo $I

Special format of for Loop

For ((exp1;exp2;exp3))

Do

Cmd

Done

For ((iTun1)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report