Showing posts with label rpm. Show all posts
Showing posts with label rpm. Show all posts

Saturday, August 10, 2019

rpm useful commands

list files installed by an INSTALLED rpm (for an UNINSTALLED rpm, add -p and provide full path to .rpm file):

rpm -ql nginx.x86_64

or also (if the rpm is not installed yet) repoquery --list nginx.x86_64

verify that rpm installed files have not been tampered

rpm -V nginx.x86_64

display the postinstall and postuninstall scripts

rpm -q --scripts nginx.x86_64

which rpm provides a given file:

rpm -q --whatprovides /usr/sbin/nginx
or also
rpm -qf /usr/sbin/nginx

for a REALLY verbose verification output:

rpm -Vvv nginx.x86_64



Ref:

http://ftp.rpm.org/max-rpm/s1-rpm-verify-what-to-verify.html


https://www.cyberciti.biz/howto/question/linux/linux-rpm-cheat-sheet.php fantastic all-in-one rpm cheat sheet

Tuesday, January 2, 2018

Linux misc (iptables, dig, rpm)

echo $LANG
en_US.UTF-8

CTRL-SHIFT-U allows you to enter the 4 letters for a Unicode character (eg 03bb is greek lambda)

localectl

System Locale: LANG=en_US.UTF-8
VC Keymap: it
X11 Layout: it,us
X11 Variant: ,

to change locale:
localectl set-locale LANG=fr_FR.utf8

cat /etc/locale.conf
LANG="en_US.UTF-8"

list all available language packs:
yum langavailable

list installed language packs:
yum langlist


iptables tutorial instructions: https://www.howtogeek.com/177621/the-beginners-guide-to-iptables-the-linux-firewall/

sudo iptables -L -v
sudo iptables -F
sudo cat /etc/sysconfig/iptables


network:
dig
systemctl status firewalld
systemctl status NetworkManager



history: remove line numbers by adding to .bash_profile
HISTTIMEFORMAT="$(echo -e '\r\e[K')"

#rpm list all packages
rpm -qa | grep ansible
#this installs 1.1 without removing 1.0 if exists
rpm -ivh some-package-1.1
#this updates (if existing) 1.0 to 1.1
rpm -Uvh some-package-1.1



Thursday, January 14, 2016

rpm tutorial


https://rpm-packaging-guide.github.io/#preparing-software-for-packaging

https://rpm-guide.readthedocs.io/en/latest/rpm-guide.html


sudo yum install gcc rpm-build rpm-devel rpmlint make python bash coreutils diffutils patch rpmdevtools

cd /home/centos
mkdir rpmtest
cd rpmtest/
vi hello-world.spec

Name:       hello-world
Version:    1
Release:    1
Summary:    Most simple RPM package
License:    FIXME

%description
This is my first RPM package, which does nothing.

%prep
# we have no source, so nothing here

%build
cat > hello-world.sh <<EOF
#!/usr/bin/bash
echo Hello world
EOF

%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh

%files
/usr/bin/hello-world.sh

%changelog
# let's skip this for now



rpmdev-setuptree
rpmbuild -ba hello-world.spec
cd /home/centos/rpmbuild/
find .
#install
sudo rpm -i -f ./RPMS/x86_64/hello-world-1-1.x86_64.rpm
hello-world.sh
which hello-world.sh
cat /usr/bin/hello-world.sh
#find package
rpm -qa | grep hello
#delete
sudo rpm -e hello-world-1-1.x86_64
#
cd /home/centos/rpmbuild/
sudo rpm -qpi ./RPMS/x86_64/hello-world-1-1.x86_64.rpm


Name        : hello-world
Version     : 1
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : Unspecified
Size        : 33
License     : FIXME
Signature   : (none)
Source RPM  : hello-world-1-1.src.rpm
Build Date  : Mon 03 Jun 2019 09:19:39 PM CEST
Build Host  : localhost
Relocations : (not relocatable)
Summary     : Most simple RPM package
Description :
This is my first RPM package, which does nothing.



This is to list the content of a rpm file without installing it:
rpm -q -filesbypkg -p filename.rpm
or also simply:
sudo rpm -ql hello-world-1-1.x86_64


To extract:

rpm2cpio ./RPMS/x86_64/hello-world-1-1.x86_64.rpm > /tmp/hello.cpio

and then

cpio -i --make-directories < /tmp/hello.cpio this will create under the current folder the file usr/bin/hello-world.sh See this nice presentation