Lab 6 - Software Management

Alexandru Calcatinge bio photo By Alexandru Calcatinge

In this laboratory you will exercise with backup and software management.

Contents:

Lab 6.1 Package Management systems

Lab objective 1: Version control with git
Lab objective 2: using RPM
Lab objective 3: using DPKG
Lab objective 4: yum (Red Hat)
Lab objective 5: zypper (SUSE)
Lab objective 6: apt (Debian)

Lab 6.2 Backup and recovery methods

Lab objective 7: using tar for backup
Lab objective 8: using cpio for backup
Lab objective 9: using rsync for backup

 


Laboratory objective 1: Version control with git

If you never heard of git, you should start looking it up and learn about it, as it is the future of code sharing and is mostly used in open-source projects world wide. Now, if you don’t have git installed, you should install it with your system package manager. We will use openSUSE as our base distribution, thus here is the result of a search into the repositories:

alexandru@linux-c4rz:~> sudo zypper search git*
Loading repository data...
Reading installed packages...

S | Name | Summary | Type 
--+------------------------------+---------------------------------+------------
 | git | Fast, scalable, distributed r-> | package 
 | git | Fast, scalable, distributed r-> | srcpackage 
 | git-annex | Manage files with git, withou-> | package 
 | git-annex | Manage files with git, withou-> | srcpackage 
 | git-annex-bash-completion | Bash completion for git-annex | package 
 | git-arch | Git tools for importing Arch -> | package 
 | git-bz | Command line integration of g-> | package 
 | git-cola | Sleek and powerful git GUI | package 
 | git-core | Core git tools | package 
 | git-credential-gnome-keyring | Git credential backend using -> | package 
 | git-cvs | Git tools for importing CVS r-> | package 
 | git-daemon | Simple Server for Git Reposit-> | package 
 | git-doc | Documentation for the Git ver-> | package 
 | git-email | Git tools for sending email | package 
 | git-gui | Grapical tool for common git -> | package 
 | git-merge-changelog | Git merge driver for ChangeLo-> | package 
 | git-review | Tool to submit code to Gerrit | package 
 | git-svn | Git tools for importing Subve-> | package 
 | git-test | Git extension to conveniently-> | package 
 | git-web | Git Web Interface | package 
 | gitg | Git repository viewer | package 
 | gitg | Git repository browser | application
 | gitg-lang | Languages for package gitg | package 
 | gitk | Git revision tree visualiser | package 
 | gitolite | Highly flexible server for gi-> | package 
 | gitslave | Creates a group of related re-> | package 
 | gitslave-doc | Documentation for gitslave | package

We will install git using the following command:

alexandru@linux-c4rz:~> sudo zypper in git
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 19 NEW packages are going to be installed:
 cvs cvsps git git-core git-cvs git-email git-gui gitk git-svn libapr1
 libapr-util1 libserf-1-1 libsvn_auth_gnome_keyring-1-0 perl-Authen-SASL
 perl-Error perl-Net-SMTP-SSL subversion subversion-bash-completion
 subversion-perl

The following 8 recommended packages were automatically selected:
 git-cvs git-email git-gui gitk git-svn perl-Authen-SASL perl-Net-SMTP-SSL
 subversion-bash-completion

The following 2 packages are suggested, but will not be installed:
 git-daemon git-web

19 new packages to install.
Overall download size: 9.5 MiB. Already cached: 0 B. After the operation,
additional 40.9 MiB will be used.
Continue? [y/n/...? shows all options] (y):

1 we will create a new working directory and after that initiate git to work with it:

alexandru@linux-inva:~> mkdir git-test
alexandru@linux-inva:~> cd git-test/
alexandru@linux-inva:~/git-test> 
alexandru@linux-inva:~/git-test> git init
Initialized empty Git repository in /home/alexandru/git-test/.git/
alexandru@linux-inva:~/git-test>

2 By initializing the project in the new directory will be created a .git directory which will contain all the version control information. Here is how the initial content of the new directory looks like:

alexandru@linux-inva:~/git-test> ls -l .git
total 12
drwxr-xr-x 1 alexandru users 0 Sep 19 13:19 branches
-rw-r--r-- 1 alexandru users 92 Sep 19 13:19 config
-rw-r--r-- 1 alexandru users 73 Sep 19 13:19 description
-rw-r--r-- 1 alexandru users 23 Sep 19 13:19 HEAD
drwxr-xr-x 1 alexandru users 364 Sep 19 13:19 hooks
drwxr-xr-x 1 alexandru users 14 Sep 19 13:19 info
drwxr-xr-x 1 alexandru users 16 Sep 19 13:19 objects
drwxr-xr-x 1 alexandru users 18 Sep 19 13:19 refs

3 we will create a file and add it to the project

alexandru@linux-inva:~/git-test> echo something > somefile
alexandru@linux-inva:~/git-test> git add somefile

4 now we will see the current status of our project with the command:

alexandru@linux-inva:~/git-test> git status
On branch master

Initial commit

Changes to be committed:
 (use "git rm --cached <file>..." to unstage)

new file: somefile

Untracked files:
 (use "git add <file>..." to include in what will be committed)

ls

alexandru@linux-inva:~/git-test>

5 Now let us modify the file and see the history of differences:

alexandru@linux-inva:~/git-test> echo another line >> somefile
alexandru@linux-inva:~/git-test> git diff

diff --git a/somefile b/somefile
index deba01f..e0a0123 100644
--- a/somefile
+++ b/somefile
@@ -1 +1,2 @@
 something
+another line

6 to commit the changes to the repository we do:

alexandru@linux-inva:~/git-test> git config user.name "alexandru calcatinge"
alexandru@linux-inva:~/git-test> git config user.email "openlark@gmail.com"
alexandru@linux-inva:~/git-test> git commit -m "my initial commit" --author="alexandru <openlark@gmail.com>"
[master (root-commit) 37a9788] my initial commit
 Author: alexandru <openlark@gmail.com>
 1 file changed, 1 insertion(+)
 create mode 100644 somefile
alexandru@linux-inva:~/git-test>

7 see the history with:

alexandru@linux-inva:~/git-test> git log

commit 37a9788694043071534a062fa9ac8ac55fe8d562 (HEAD -> master)
Author: alexandru <openlark@gmail.com>
Date: Tue Sep 19 13:31:43 2017 +0300

my initial commit
lines 1-5/5 (END)

You can add more lines to the git file, or add more files to your git directory. After you do that, you will have to commit them. This is how software additions are done these days. The long hexadecimal string is the commit number. It is a 160bit 40digit unique identifier, and git works with them instead of file names. This is only a small example on how to work with git commits, if you want to learn more, please refer to other resources on the internet.

 

↑Top


Laboratory objective 2: using RPM

RPM is use on Red Hat and SUSE distributions, and others that are based on those. The exercise will be done on openSUSE.

1 find out what package the file /etc/logrotate.conf belongs to:

alexandru@linux-inva:~/git-test> rpm -qf /etc/logrotate.conf
logrotate-3.11.0-10.3.x86_64

2 list information about the package including all the files it contains:

alexandru@linux-inva:~/git-test> rpm -qil logrotate
Name : logrotate
Version : 3.11.0
Release : 10.3
Architecture: x86_64
Install Date: Tue 19 Sep 2017 12:00:27 PM EEST
Group : System/Base
Size : 120855
License : GPL-2.0+
Signature : RSA/SHA256, Wed 10 May 2017 02:42:38 AM EEST, Key ID b88b2fd43dbdc284
Source RPM : logrotate-3.11.0-10.3.src.rpm
Build Date : Wed 10 May 2017 02:42:30 AM EEST
Build Host : wildcard2
Relocations : (not relocatable)
Packager : http://bugs.opensuse.org
Vendor : openSUSE
URL : https://github.com/logrotate/logrotate
Summary : Rotate, compress, remove, and mail system log files
Description :
The logrotate utility is designed to simplify the administration of log
files on a system that generates a lot of log files. Logrotate allows
the automatic rotation, compression, removal, and mailing of log files.
Logrotate can be set to handle a log file daily, weekly, monthly, or
when the log file reaches a certain size. Normally, logrotate runs as a
daily cron job.
Distribution: openSUSE Leap 42.3
/etc/logrotate.conf
/etc/logrotate.d/wtmp
/usr/lib/systemd/system/logrotate.service
/usr/lib/systemd/system/logrotate.timer
/usr/sbin/logrotate
/usr/sbin/rclogrotate
/usr/share/doc/packages/logrotate
/usr/share/doc/packages/logrotate/COPYING
/usr/share/doc/packages/logrotate/ChangeLog.md
/usr/share/doc/packages/logrotate/README.md
/usr/share/man/man5/logrotate.conf.5.gz
/usr/share/man/man8/logrotate.8.gz

There is also a way to combine those two requests, with the following command:

alexandru@linux-inva:~/git-test> rpm -qil $(rpm -qf /etc/logrotate.conf)
Name : logrotate
Version : 3.11.0
Release : 10.3
Architecture: x86_64
Install Date: Tue 19 Sep 2017 12:00:27 PM EEST
Group : System/Base
Size : 120855
License : GPL-2.0+
Signature : RSA/SHA256, Wed 10 May 2017 02:42:38 AM EEST, Key ID b88b2fd43dbdc284
Source RPM : logrotate-3.11.0-10.3.src.rpm
Build Date : Wed 10 May 2017 02:42:30 AM EEST
Build Host : wildcard2
Relocations : (not relocatable)
Packager : http://bugs.opensuse.org
Vendor : openSUSE
URL : https://github.com/logrotate/logrotate
Summary : Rotate, compress, remove, and mail system log files
Description :
The logrotate utility is designed to simplify the administration of log
files on a system that generates a lot of log files. Logrotate allows
the automatic rotation, compression, removal, and mailing of log files.
Logrotate can be set to handle a log file daily, weekly, monthly, or
when the log file reaches a certain size. Normally, logrotate runs as a
daily cron job.
Distribution: openSUSE Leap 42.3
/etc/logrotate.conf
/etc/logrotate.d/wtmp
/usr/lib/systemd/system/logrotate.service
/usr/lib/systemd/system/logrotate.timer
/usr/sbin/logrotate
/usr/sbin/rclogrotate
/usr/share/doc/packages/logrotate
/usr/share/doc/packages/logrotate/COPYING
/usr/share/doc/packages/logrotate/ChangeLog.md
/usr/share/doc/packages/logrotate/README.md
/usr/share/man/man5/logrotate.conf.5.gz
/usr/share/man/man8/logrotate.8.gz

3 verify the package installation with the command:

alexandru@linux-inva:~/git-test> rpm -V logrotate

4 try to remove the package with rpm:

alexandru@linux-inva:~/git-test> sudo rpm -e logrotate

 

Rebuild the RPM Database

There are situations when your rpm database stored under /var/lib/rpm could be corrupted. In this exercise we will construct a new one and verify its integrity.

1 backup the contents of /var/lib/rpm

alexandru@linux-inva:~/git-test> cd /var/lib/rpm/
alexandru@linux-inva:/var/lib/rpm> ls -l
total 52052
drwxr-xr-x 1 root root 392 Sep 19 12:07 alternatives
-rw-r--r-- 1 root root 2002944 Sep 19 13:19 Basenames
-rw-r--r-- 1 root root 8192 Sep 19 13:19 Conflictname
-rw-r--r-- 1 root root 737280 Sep 19 13:19 Dirnames
-rw-r--r-- 1 root root 20480 Sep 19 13:19 Group
-rw-r--r-- 1 root root 24576 Sep 19 13:19 Installtid
-rw-r--r-- 1 root root 49152 Sep 19 13:19 Name
-rw-r--r-- 1 root root 28672 Sep 19 13:19 Obsoletename
-rw-r--r-- 1 root root 46534656 Sep 19 13:19 Packages
-rw-r--r-- 1 root root 3350528 Sep 19 13:19 Providename
-rw-r--r-- 1 root root 417792 Sep 19 13:19 Requirename
-rw-r--r-- 1 root root 81920 Sep 19 13:19 Sha1header
-rw-r--r-- 1 root root 40960 Sep 19 13:19 Sigmd5
-rw-r--r-- 1 root root 8192 Sep 19 11:59 Triggername
alexandru@linux-inva:/var/lib/rpm> cd ..
alexandru@linux-inva:/var/lib> sudo cp -a rpm rpm_backup
alexandru@linux-inva:/var/lib> ls -l
total 0
drwxr-xr-x 1 root root 16 Sep 8 19:10 autoinstall
drwxr-xr-x 1 root root 98 Sep 19 13:30 btrfs
drwxr-xr-x 1 root root 70 Sep 19 11:59 ca-certificates
drwxr-xr-x 1 root root 20 Sep 19 11:59 dbus
drwxr-xr-x 1 root root 0 Sep 19 12:03 dhcpcd
drwxr-xr-x 1 root root 22 Sep 19 11:59 dirmngr
drwxr-xr-x 1 root root 0 May 10 02:26 empty
drwxr-xr-x 1 root root 36 Sep 19 11:56 hardware
drwxr-xr-x 1 root root 12 Sep 19 11:58 libvirt
drwxr-xr-x 1 root root 0 May 17 20:46 lifecycle
drwx------ 1 root root 0 Sep 19 11:58 machines
drwxr-xr-x 1 root root 0 Sep 19 11:58 mailman
drwxr-xr-x 1 root root 0 Sep 19 11:58 mariadb
drwxr-xr-x 1 root root 38 Sep 19 12:04 misc
drwxr-xr-x 1 root root 0 Sep 19 11:58 mysql
drwxr-xr-x 1 root root 0 Sep 19 11:58 named
drwxr-xr-x 1 news news 0 May 10 02:26 news
drwx--x--x 1 statd nogroup 56 Sep 19 12:01 nfs
drwxr-xr-x 1 nobody root 0 May 10 02:26 nobody
drwxr-xr-x 1 root root 34 Sep 19 12:00 ntp
drwxr-xr-x 1 root root 0 May 23 18:52 os-prober
drwxr-xr-x 1 root root 30 Sep 19 12:01 PackageKit
drwxr-xr-x 1 root root 0 Sep 19 11:58 pgsql
drwxr-xr-x 1 root root 0 Jun 26 10:05 polkit
drwx------ 1 postfix root 22 Sep 19 12:04 postfix
drwxr-xr-x 1 rpc root 0 May 19 20:02 rpcbind
drwxr-xr-x 1 root root 276 Jul 7 18:08 rpm
drwxr-xr-x 1 root root 276 Jul 7 18:08 rpm_backup
drwxr-xr-x 1 root root 22 Aug 22 19:31 samba
drwxr-xr-x 1 root root 0 Jul 13 19:40 sshd
drwx--x--x 1 root root 20 Sep 19 12:05 sudo
drwxr-xr-x 1 root root 104 Sep 3 13:23 systemd
drwxrwx--- 1 root root 0 May 18 01:38 udisks2
drwxr-x--- 1 root root 64 Sep 19 13:17 wicked
drwxr-xr-x 1 wwwrun root 0 May 10 02:26 wwwrun
drwxr-xr-x 1 root root 388 Sep 19 12:03 YaST2
drwxr-xr-x 1 root root 136 Sep 19 13:19 zypp

2 rebuild the database with the command:

alexandru@linux-inva:/var/lib> sudo rpm --rebuilddb

3 compare the two contents of the directory with the contents you backed up previously. Note the number and names of the files, not the actual file contents as they are binary data:

alexandru@linux-inva:/var/lib> ls -l rpm rpm_backup/
rpm:
total 51988
drwxr-xr-x 1 root root 392 Sep 19 12:07 alternatives
-rw-r--r-- 1 root root 1998848 Sep 19 13:46 Basenames
-rw-r--r-- 1 root root 8192 Sep 19 13:46 Conflictname
-rw-r--r-- 1 root root 716800 Sep 19 13:46 Dirnames
-rw-r--r-- 1 root root 24576 Sep 19 13:46 Group
-rw-r--r-- 1 root root 24576 Sep 19 13:46 Installtid
-rw-r--r-- 1 root root 40960 Sep 19 13:46 Name
-rw-r--r-- 1 root root 28672 Sep 19 13:46 Obsoletename
-rw-r--r-- 1 root root 46534656 Sep 19 13:46 Packages
-rw-r--r-- 1 root root 3325952 Sep 19 13:46 Providename
-rw-r--r-- 1 root root 397312 Sep 19 13:46 Requirename
-rw-r--r-- 1 root root 81920 Sep 19 13:46 Sha1header
-rw-r--r-- 1 root root 49152 Sep 19 13:46 Sigmd5
-rw-r--r-- 1 root root 8192 Sep 19 13:46 Triggername

rpm_backup/:
total 52052
drwxr-xr-x 1 root root 392 Sep 19 12:07 alternatives
-rw-r--r-- 1 root root 2002944 Sep 19 13:19 Basenames
-rw-r--r-- 1 root root 8192 Sep 19 13:19 Conflictname
-rw-r--r-- 1 root root 737280 Sep 19 13:19 Dirnames
-rw-r--r-- 1 root root 20480 Sep 19 13:19 Group
-rw-r--r-- 1 root root 24576 Sep 19 13:19 Installtid
-rw-r--r-- 1 root root 49152 Sep 19 13:19 Name
-rw-r--r-- 1 root root 28672 Sep 19 13:19 Obsoletename
-rw-r--r-- 1 root root 46534656 Sep 19 13:19 Packages
-rw-r--r-- 1 root root 3350528 Sep 19 13:19 Providename
-rw-r--r-- 1 root root 417792 Sep 19 13:19 Requirename
-rw-r--r-- 1 root root 81920 Sep 19 13:19 Sha1header
-rw-r--r-- 1 root root 40960 Sep 19 13:19 Sigmd5
-rw-r--r-- 1 root root 8192 Sep 19 11:59 Triggername

4 get a listing of all rpms on the system

alexandru@linux-inva:/var/lib> rpm -qa | tee /tmp/rpm_qa.output

5 compare against the two directory contents and see if they have the same files now:

alexandru@linux-inva:/var/lib> ls -l rpm rpm_backup/
rpm:
total 51988
drwxr-xr-x 1 root root 392 Sep 19 12:07 alternatives
-rw-r--r-- 1 root root 1998848 Sep 19 13:46 Basenames
-rw-r--r-- 1 root root 8192 Sep 19 13:46 Conflictname
-rw-r--r-- 1 root root 716800 Sep 19 13:46 Dirnames
-rw-r--r-- 1 root root 24576 Sep 19 13:46 Group
-rw-r--r-- 1 root root 24576 Sep 19 13:46 Installtid
-rw-r--r-- 1 root root 40960 Sep 19 13:46 Name
-rw-r--r-- 1 root root 28672 Sep 19 13:46 Obsoletename
-rw-r--r-- 1 root root 46534656 Sep 19 13:46 Packages
-rw-r--r-- 1 root root 3325952 Sep 19 13:46 Providename
-rw-r--r-- 1 root root 397312 Sep 19 13:46 Requirename
-rw-r--r-- 1 root root 81920 Sep 19 13:46 Sha1header
-rw-r--r-- 1 root root 49152 Sep 19 13:46 Sigmd5
-rw-r--r-- 1 root root 8192 Sep 19 13:46 Triggername

rpm_backup/:
total 52052
drwxr-xr-x 1 root root 392 Sep 19 12:07 alternatives
-rw-r--r-- 1 root root 2002944 Sep 19 13:19 Basenames
-rw-r--r-- 1 root root 8192 Sep 19 13:19 Conflictname
-rw-r--r-- 1 root root 737280 Sep 19 13:19 Dirnames
-rw-r--r-- 1 root root 20480 Sep 19 13:19 Group
-rw-r--r-- 1 root root 24576 Sep 19 13:19 Installtid
-rw-r--r-- 1 root root 49152 Sep 19 13:19 Name
-rw-r--r-- 1 root root 28672 Sep 19 13:19 Obsoletename
-rw-r--r-- 1 root root 46534656 Sep 19 13:19 Packages
-rw-r--r-- 1 root root 3350528 Sep 19 13:19 Providename
-rw-r--r-- 1 root root 417792 Sep 19 13:19 Requirename
-rw-r--r-- 1 root root 81920 Sep 19 13:19 Sha1header
-rw-r--r-- 1 root root 40960 Sep 19 13:19 Sigmd5
-rw-r--r-- 1 root root 8192 Sep 19 11:59 Triggername

6 don’t erase your backup just now, as you should keep it for a wile, just until you see that your system is running with now problems. But when you will erase it, use the command:

sudo rm -rf rpm_backup

 

↑Top


Laboratory objective 3:using DPKG

DPKG is used by Debian based operating systems. In this laboratory we will use Debian 9.1 as a base system.

1 Find out what package the /etc/logrotate.conf belongs to:

dpkg -S /etc/logrotate.conf

2 List information about the package including all the files it contains:

dpkg -L logrotate

3 Verify the package installation

dpkg -V logrotate

4 Try to remove the package:

sudo dpkg -r logrotate

 

↑Top


Laboratory objective 4: yum (Red Hat)

For the moment, we will focus on Debian and openSUSE, but we’ll get back to Red Hat/CentOS sometime soon.

↑Top


Laboratory objective 5: zypper (SUSE)

Basic zypper commands:

1 Check to see if there are any available updates:

alexandru@linux-inva:~> sudo zypper list-updates
[sudo] password for root: 
Loading repository data...
Reading installed packages...
No updates found.

2 update a particular package

alexandru@linux-inva:~> sudo zypper update bash
Loading repository data...
Reading installed packages...
No update candidate for 'bash-4.3-82.6.x86_64'. The highest available version is already installed.
Resolving package dependencies...

3 list all repositories the system is aware of, enabled or not:

alexandru@linux-inva:~> sudo zypper repos
Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias | Name | Enabled | GPG Check | Refresh
---+---------------------------+-----------------------------------------+---------+-----------+--------
 1 | openSUSE-Leap-42.3-0 | openSUSE-Leap-42.3-0 | No | ---- | ---- 
 2 | repo-debug | openSUSE-Leap-42.3-Debug | No | ---- | ---- 
 3 | repo-debug-non-oss | openSUSE-Leap-42.3-Debug-Non-Oss | No | ---- | ---- 
 4 | repo-debug-update | openSUSE-Leap-42.3-Update-Debug | No | ---- | ---- 
 5 | repo-debug-update-non-oss | openSUSE-Leap-42.3-Update-Debug-Non-Oss | No | ---- | ---- 
 6 | repo-non-oss | openSUSE-Leap-42.3-Non-Oss | Yes | (r ) Yes | Yes 
 7 | repo-oss | openSUSE-Leap-42.3-Oss | Yes | (r ) Yes | Yes 
 8 | repo-source | openSUSE-Leap-42.3-Source | No | ---- | ---- 
 9 | repo-source-non-oss | openSUSE-Leap-42.3-Source-Non-Oss | No | ---- | ---- 
10 | repo-update | openSUSE-Leap-42.3-Update | Yes | (r ) Yes | Yes 
11 | repo-update-non-oss | openSUSE-Leap-42.3-Update-Non-Oss | Yes | (r ) Yes | Yes 
alexandru@linux-inva:~>

4 list all installed kernel-related packages, and list all installed and available ones:

alexandru@linux-inva:~> sudo zypper search -i kernel
Loading repository data...
Reading installed packages...

S | Name | Summary | Type 
---+-----------------+-----------------------------+--------
i+ | kernel-default | The Standard Kernel | package
i | kernel-firmware | Linux kernel firmware files | package
alexandru@linux-inva:~>
alexandru@linux-inva:~> sudo zypper search kernel
Loading repository data...
Reading installed packages...

S | Name | Summary | Type 
---+--------------------------------+-------------------------------+-----------
 | devel_kernel | Linux Kernel Development | pattern 
 | kernel-coverage | Kernel Coverage Imageing, G-> | package 
 | kernel-debug | A Debug Version of the Kernel | package 
 | kernel-debug | A Debug Version of the Kernel | srcpackage
 | kernel-debug-base | A Debug Version of the Kern-> | package 
 | kernel-debug-devel | Development files necessary-> | package 
i+ | kernel-default | The Standard Kernel | package 
 | kernel-default | The Standard Kernel | srcpackage
 | kernel-default-base | The Standard Kernel - base -> | package 
 | kernel-default-devel | Development files necessary-> | package 
 | kernel-devel | Development files needed fo-> | package 
 | kernel-docs | Kernel Documentation (man p-> | package 
 | kernel-docs | Kernel Documentation (man p-> | srcpackage
 | kernel-docs-html | Kernel Documentation (HTML) | package 
 | kernel-docs-pdf | Kernel Documentation (PDF) | package 
i | kernel-firmware | Linux kernel firmware files | package 
 | kernel-macros | RPM macros for building Ker-> | package 
 | kernel-obs-build | package kernel and initrd f-> | package 
 | kernel-obs-build | package kernel and initrd f-> | srcpackage
 | kernel-obs-qa | Basic QA tests for the kernel | package 
 | kernel-obs-qa | Basic QA tests for the kernel | srcpackage
 | kernel-source | The Linux Kernel Sources | package 
 | kernel-source | The Linux Kernel Sources | srcpackage
 | kernel-source-vanilla | Vanilla Linux kernel source-> | package 
 | kernel-syms | Kernel Symbol Versions (mod-> | package 
 | kernel-syms | Kernel Symbol Versions (mod-> | srcpackage
 | kernel-vanilla | The Standard Kernel - witho-> | package 
 | kernel-vanilla | The Standard Kernel - witho-> | srcpackage
 | kernel-vanilla-base | The Standard Kernel - witho-> | package 
 | kernel-vanilla-devel | Development files necessary-> | package 
 | kernelshark | GUI for trace-cmd | package 
 | lirc-disable-kernel-rc | Disable kernel ir device ha-> | package 
 | nfs-kernel-server | Support Utilities for Kerne-> | package 
 | patterns-openSUSE-devel_kernel | Linux Kernel Development | package 
 | texlive-l3kernel | LaTeX3 programming conventi-> | package 
 | texlive-l3kernel-doc | Documentation for texlive-l-> | package 
alexandru@linux-inva:~>

5 install the apache2-devel package, or anything else you might not have installed (note that httpd is apache2 on SUSE). You could try with another package, like dropbox for example:

alexandru@linux-inva:~> sudo zypper search dropbox
Loading repository data...
Reading installed packages...

S | Name | Summary | Type 
--+----------------------------+---------------------------------------+--------
 | caja-extension-dropbox | Dropbox client integrated into Caja | package
 | dropbox | Dropbox client for Linux | package
 | nautilus-extension-dropbox | Dropbox client integrated into Naut-> | package
 | nemo-extension-dropbox | DropBox support for the Nemo Filema-> | package
alexandru@linux-inva:~> sudo zypper in dropbox
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 29 NEW packages are going to be installed:
 at-spi2-atk-common at-spi2-atk-gtk2 dropbox gnome-icon-theme
 gnome-icon-theme-extras gnome-icon-theme-symbolic gtk2-branding-openSUSE
 gtk2-data gtk2-immodule-amharic gtk2-immodule-inuktitut gtk2-immodule-thai
 gtk2-immodule-vietnamese gtk2-lang gtk2-metatheme-adwaita
 gtk2-theming-engine-adwaita gtk2-tools libblas3 libgfortran3 libglade-2_0-0
 libgpgme11 libgthread-2_0-0 libgtk-2_0-0 liblapack3 libquadmath0 python-cairo
 python-gobject2 python-gpgme python-gtk python-numpy

The following 7 recommended packages were automatically selected:
 gtk2-branding-openSUSE gtk2-data gtk2-immodule-amharic gtk2-immodule-inuktitut
 gtk2-immodule-thai gtk2-immodule-vietnamese gtk2-lang

29 new packages to install.
Overall download size: 21.1 MiB. Already cached: 0 B. After the operation,
additional 58.0 MiB will be used.
Continue? [y/n/...? shows all options] (y):

 

Use zypper to find information about a package:

1 all packages that contain a refrence to bash in their name or description

alexandru@linux-inva:~> sudo zypper search -d bash

2 find installed and available bash packages

alexandru@linux-inva:~> sudo zypper search bash

3 find package information for bash

alexandru@linux-inva:~> sudo zypper info bash
Loading repository data...
Reading installed packages...



Information for package bash:
-----------------------------
Repository : openSUSE-Leap-42.3-Oss 
Name : bash 
Version : 4.3-82.6 
Arch : x86_64 
Vendor : openSUSE 
Installed Size : 746.5 KiB 
Installed : Yes (automatically) 
Status : up-to-date 
Source package : bash-4.3-82.6.src 
Summary : The GNU Bourne-Again Shell
Description : 
 Bash is an sh-compatible command interpreter that executes commands
 read from standard input or from a file. Bash incorporates useful
 features from the Korn and C shells (ksh and csh). Bash is intended to
 be a conformant implementation of the IEEE Posix Shell and Tools
 specification (IEEE Working Group 1003.2).

4 find the dependencies for the bash package

alexandru@linux-inva:~> sudo zypper info --requires bash
Loading repository data...
Reading installed packages...



Information for package bash:
-----------------------------
Repository : openSUSE-Leap-42.3-Oss 
Name : bash 
Version : 4.3-82.6 
Arch : x86_64 
Vendor : openSUSE 
Installed Size : 746.5 KiB 
Installed : Yes (automatically) 
Status : up-to-date 
Source package : bash-4.3-82.6.src 
Summary : The GNU Bourne-Again Shell
Description : 
 Bash is an sh-compatible command interpreter that executes commands
 read from standard input or from a file. Bash incorporates useful
 features from the Korn and C shells (ksh and csh). Bash is intended to
 be a conformant implementation of the IEEE Posix Shell and Tools
 specification (IEEE Working Group 1003.2).
Requires : [19] 
 libc.so.6()(64bit)
 libc.so.6(GLIBC_2.2.5)(64bit)
 libc.so.6(GLIBC_2.4)(64bit)
 libc.so.6(GLIBC_2.14)(64bit)
 libc.so.6(GLIBC_2.3.4)(64bit)
 libc.so.6(GLIBC_2.3)(64bit)
 libdl.so.2()(64bit)
 libc.so.6(GLIBC_2.15)(64bit)
 libdl.so.2(GLIBC_2.2.5)(64bit)
 libc.so.6(GLIBC_2.11)(64bit)
 /bin/bash
 libc.so.6(GLIBC_2.8)(64bit)
 libtinfo.so.5()(64bit)
 libreadline.so.6()(64bit)
 libreadline.so.6(READLINE_6.3)(64bit)
 rpmlib(CompressedFileNames) <= 3.0.4-1
 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
 rpmlib(PayloadIsLzma) <= 4.4.6-1
 config(bash) = 4.3-82.6

 

↑Top


Laboratory objective 6: apt (Debian)

For this example we will use a Debian 9.1 system. Here are the exercises.

1 check to see if there are any available updates for your system:

sudo apt update

to upgrade the available updates, use:

sudo apt upgrade

2 update a particular package

sudo apt upgrade bash

3 list all installed kernel-related packages and list all installed or available ones:

sudo apt-cache search "kernel"
sudo apt-cache search -n "kernel"sudo apt-cache pkgnames "kernel"

the second and third commands will output the packages that have kernel in their names. To get only installed packages, use:

dpkg --get-selections "*kernel*"

If you won’t find anything, you should use “linux” as a string for search, not “kernel”, as usually Debian based operating systems don’t use kernel in their names.

4 install a new package:

sudo apt install hplip

 

Using APT to find information about a package

1 find all packages that contain a reference to bash in their name or description

sudo apt-cache search bash

2 find installed and available bash packages

sudo apt-cache search -n bash

3 find the package information for bash

sudo apt-cache show bash

4 find the dependencies for the bash package

sudo apt-cache depends bashsudo apt-cache rdepends bash

 

↑Top


Laboratory objective 7: using tar for backup

For examples of using tar, please refer to the appropriate laboratory which emphasizes on archives and compression utilities.

 

↑Top


Laboratory objective 8: using cpio for backup

For this exercise we will use openSUSE as a base system.

1 create a directory called backup and inside it place a compressed cpio archive of all the files under /usr/include:

alexandru@linux-inva:~> mkdir backup
alexandru@linux-inva:~> (cd /usr ; find include | cpio -c -o > /home/alexandru/backup/include.cpio)
134 blocks
alexandru@linux-inva:~> (cd /usr ; find include | cpio -c -o | gzip -c > /home/alexandru/backup/include.cpio.gz)
134 blocks
alexandru@linux-inva:~> ls -lh include*
ls: cannot access 'include*': No such file or directory
alexandru@linux-inva:~> cd backup/
alexandru@linux-inva:~/backup> ls -lh include*
-rw-r--r-- 1 alexandru users 67K Sep 19 17:10 include.cpio
-rw-r--r-- 1 alexandru users 18K Sep 19 17:11 include.cpio.gz
alexandru@linux-inva:~/backup>

2 list the files in the archive:

alexandru@linux-inva:~/backup> cpio -ivt < include.cpio
drwxr-xr-x 1 root root 0 Sep 19 11:59 include
drwxr-xr-x 1 root root 0 May 10 02:26 include/X11
drwxr-xr-x 1 root root 0 Sep 19 11:59 include/python2.7
-rw-r--r-- 1 root root 36911 Jul 7 18:18 include/python2.7/pyconfig.h
-rw-r--r-- 1 root root 30929 Jul 7 18:03 include/gawkapi.h
134 blocks

the same output could be done with the commands:

alexandru@linux-inva:~/backup> cd ..
alexandru@linux-inva:~> ls -l
total 0
drwxr-xr-x 1 alexandru users 54 Sep 19 17:11 backup
drwxr-xr-x 1 alexandru users 0 Sep 19 12:03 bin
drwxr-xr-x 1 alexandru users 28 Sep 19 13:23 git-test
alexandru@linux-inva:~> mkdir restore
alexandru@linux-inva:~> cd restore/
alexandru@linux-inva:~/restore> cat ../backup/include.cpio | cpio -ivt
drwxr-xr-x 1 root root 0 Sep 19 11:59 include
drwxr-xr-x 1 root root 0 May 10 02:26 include/X11
drwxr-xr-x 1 root root 0 Sep 19 11:59 include/python2.7
-rw-r--r-- 1 root root 36911 Jul 7 18:18 include/python2.7/pyconfig.h
-rw-r--r-- 1 root root 30929 Jul 7 18:03 include/gawkapi.h
134 blocks
alexandru@linux-inva:~/restore> gunzip -c ../backup/include.cpio.gz | cpio -ivt
drwxr-xr-x 1 root root 0 Sep 19 11:59 include
drwxr-xr-x 1 root root 0 May 10 02:26 include/X11
drwxr-xr-x 1 root root 0 Sep 19 11:59 include/python2.7
-rw-r--r-- 1 root root 36911 Jul 7 18:18 include/python2.7/pyconfig.h
-rw-r--r-- 1 root root 30929 Jul 7 18:03 include/gawkapi.h
134 blocks
alexandru@linux-inva:~/restore>

3 compare the contents with the original directory the archive was made from:

alexandru@linux-inva:~/backup> cpio -id < include.cpio
134 blocks
alexandru@linux-inva:~/backup> ls -lR include
include:
total 32
-rw-r--r-- 1 alexandru users 30929 Sep 19 17:17 gawkapi.h
drwxr-xr-x 1 alexandru users 20 Sep 19 17:17 python2.7
drwxr-xr-x 1 alexandru users 0 Sep 19 17:17 X11

include/python2.7:
total 40
-rw-r--r-- 1 alexandru users 36911 Sep 19 17:17 pyconfig.h

include/X11:
total 0
alexandru@linux-inva:~/backup>

 

↑Top


Laboratory objective 9: using rsync for backup

 

↑Top