In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how the CentOS system to get the command source code, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
To get the source code of the ls command under 32-bit CentOS6.6, you can download the source code using the following methods:
1) configure the source of the source code
In CentOS, the configuration file for the source is: / etc/yum.repos.d/CentOS-Base.repo, and root permission is required to modify this file.
Open the file and view the contents of the file. On my computer, the contents of the file are as follows:
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever-Base mirrorlist= http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os # baseurl= http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 # released updates [updates] name=CentOS-$releasever-Updates mirrorlist= http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates # baseurl= http://mirror.centos.org/centos/$releasever / updates/$basearch/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 # additional packages that may be useful [extras] name=CentOS-$releasever-Extras mirrorlist= http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras # baseurl= http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 # additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever-Plus mirrorlist= http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus # baseurl= http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 # contrib-packages by Centos Users [contrib] name=CentOS-$releasever-Contrib mirrorlist= http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib # baseurl= http://mirror.centos.org/centos/$releasever / contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
There are two variables in this file: releasever and basearch, which represent the release version and branch, respectively. On my computer, these two values are 6 and i386, respectively. Note that releasever is not subdivided into minor versions, that is, 6.6 or something like that.
From the contents of the file, we can know that there are five sections in the file, that is to say, there are five sources of software for my machine, namely, base, updates, extras, centosplus and contrib. So you only need to specify the source of their source code for the following 5 software sources. Add the following at the end of the file:
[base-src] name=CentOS-$releasever-Base src baseurl= http://vault.centos.org/6.6/os/Source/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [updates-src] name=CentOS-$releasever-Updates src-centos baseurl= http://vault.centos.org/6.6/updates/Source/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [extras-src] Name=CentOS-$releasever-Extras src-centos baseurl= http://vault.centos.org/6.6/extras/Source/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [centosplus-src] name=CentOS-$releasever-Plus src-centos baseurl= http://vault.centos.org/6.6/centosplus/Source/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [contrib-src] name=CentOS-$releasever -Contrib src-centos baseurl= http://vault.centos.org/6.6/contrib/Soruce/ gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Because the settings vary from version to version, the settings will be different. The method can be summarized as follows:
(1) the gpgkey is the same as the gpgkey of the existing sections in the file
(2) in order to confirm the existence and situation of the document, you can open the website http://vault.centos.org/ to check the specific situation, and then fill in it according to the specific situation.
(3) when setting baseurl, you need to set it according to the version of your system. If your machine is CentOS-6.6, the relevant parameters will be set to 6.6, that is, the subpath followed by http://vault.centos.org/ will be set to 6.6.
The purpose of this file is to provide a source for downloading yum and its related work. For example, when downloading source code using yumdownloader (described below), the following actions occur:
(1) download the $baseurl/repodata/repomd.xml file. If the repomd.xml file is newer than the one in the system, update the corresponding repomd.xml in the system.
(2) download the corresponding source code rpm package in $baseurl/SPackages/.
2) use the which command to view the location of the ls command, as follows:
Which ls
# output: / bin/ls
3) use the rpm command to query the package to which the ls command belongs, as follows:
Rpm-qf / bin/ls
# output: coreutils-8.4-37.el6.i686
4) yumdownloader is a program that downloads RPM from a RPM source. You can use the yumdownloader command to install the source code, as follows:
Yumdownloader-- source coreutils-8.4-37.el6.i686
Note:
(1) if the yumdownloader command is not installed, use this command to install: yum install yum-utils.
(2) the downloaded file is in the current directory. You can use the parameter-- destdir to specify which directory to download to.
5) what you download using yumdownloader is an installation package file rpm. You can query the tar file in rpm using the following command:
Rpm-qpl coreutils-8.4-37.el6.src.rpm | grep tar
# output: coreutils-8.4.tar.xz
6) use the rpm2cpio command to convert the rpm package file into a cpio archive file, and then use the cpio command to copy and extract an archive file from the cpio archive file, as follows:
Rpm2cpio coreutils-8.4-37.el6.src.rpm | cpio-idv coreutils-8.4.tar.xz
# output:
# coreutils-8.4.tar.xz
# 9561 blocks
The man of cpio is interpreted as: cpio copies files into an archive
-I: equivalent to-- extract, meaning of extraction
-d: equivalent to-- make-directories, create a load directory when necessary
-v: list the process of the file
7) use the tar command to extract the coreutils-8.4.tar.xz package, as follows:
Tar-xvf. / coreutils-8.4.tar.xz
At this point, the source code of the command is obtained.
The above is all the contents of the article "how to get the source code of commands in CentOS system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.