GNU/Linux


Make an external folder available into a chroot environment

Recently, we were playing with a chrooted environment using mock.

We wanted  to give access to the chrooted environment to a folder that was part of the host machine but not part of its virtual environment.

To do so, we mounted the host machine folder on a new folder inside the chrooted area by executing the following on the host machine


#/var/lib/mock/fedora-25-x86_64/root/ is the root of the chrooted environment
mkdir /var/lib/mock/fedora-25-x86_64/root/cool_stuff/;
#/home/george/KickStart/cool_stuff/ is the folder which we want the chrooted environment to have access to
sudo mount --bind /home/george/KickStart/cool_stuff/ /var/lib/mock/fedora-25-x86_64/root/cool_stuff/;


Fedora 25: Workaround to install system-config-kickstart 1

Recently, we tried to install system-config-kickstart on a Fedora 25 x86_64 Workstation but it failed because dnf could not find an installation candidate for system-config-date.

The hack-ish solution

After reviewing the packages that were available at the time in https://kojipkgs.fedoraproject.org/packages/system-config-date/ we found the latest rpm version and we had dnf install that manually.
sudo dnf install https://kojipkgs.fedoraproject.org/packages/system-config-date/1.10.9/3.fc25/noarch/system-config-date-1.10.9-3.fc25.noarch.rpm python-kickstart system-config-kickstart;
The installation went smoothly and we were able to use system-config-kickstart.

Output of successful installation

sudo dnf install https://kojipkgs.fedoraproject.org/packages/system-config-date/1.10.9/3.fc25/noarch/system-config-date-1.10.9-3.fc25.noarch.rpm python-kickstart system-config-kickstart
Last metadata expiration check: 2:57:07 ago on Sun May 14 08:43:53 2017.
Package python-kickstart-2.32-1.fc25.noarch is already installed, skipping.
Dependencies resolved.
===========================================================================================
 Package                          Arch        Version              Repository         Size
===========================================================================================
Installing:
 gnome-python2                    x86_64      2.28.1-18.fc25       fedora             51 k
 gnome-python2-canvas             x86_64      2.28.1-18.fc25       fedora             38 k
 libart_lgpl                      x86_64      2.3.21-15.fc25       fedora             71 k
 libglade2                        x86_64      2.6.4-14.fc24        fedora             67 k
 libgnomecanvas                   x86_64      2.30.3-11.fc24       fedora            230 k
 libselinux-python                x86_64      2.5-13.fc25          updates           239 k
 newt-python                      x86_64      0.52.19-2.fc25       fedora             60 k
 pygtk2-libglade                  x86_64      2.24.0-15.fc25       fedora             30 k
 pykickstart                      noarch      2.32-1.fc25          fedora             56 k
 python-slip                      noarch      0.6.4-4.fc25         fedora             37 k
 system-config-date               noarch      1.10.9-3.fc25        @commandline      602 k
 system-config-keyboard           noarch      1.4.0-10.fc25        fedora             38 k
 system-config-keyboard-base      noarch      1.4.0-10.fc25        fedora            108 k
 system-config-kickstart          noarch      2.9.3-3.fc24         fedora            361 k
 system-config-language           noarch      3.4.0-1.fc25         fedora            128 k

Transaction Summary
===========================================================================================
Install  15 Packages

Total size: 2.1 M
Total download size: 1.5 M
Installed size: 7.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/14): gnome-python2-canvas-2.28.1-18.fc25.x86_64.rpm     370 kB/s |  38 kB     00:00    
(2/14): pygtk2-libglade-2.24.0-15.fc25.x86_64.rpm          797 kB/s |  30 kB     00:00    
(3/14): newt-python-0.52.19-2.fc25.x86_64.rpm              371 kB/s |  60 kB     00:00    
(4/14): python-slip-0.6.4-4.fc25.noarch.rpm                595 kB/s |  37 kB     00:00    
(5/14): system-config-keyboard-1.4.0-10.fc25.noarch.rpm    867 kB/s |  38 kB     00:00    
(6/14): pykickstart-2.32-1.fc25.noarch.rpm                 579 kB/s |  56 kB     00:00    
(7/14): gnome-python2-2.28.1-18.fc25.x86_64.rpm            586 kB/s |  51 kB     00:00    
(8/14): system-config-language-3.4.0-1.fc25.noarch.rpm     1.0 MB/s | 128 kB     00:00    
(9/14): libart_lgpl-2.3.21-15.fc25.x86_64.rpm              656 kB/s |  71 kB     00:00    
(10/14): system-config-kickstart-2.9.3-3.fc24.noarch.rpm   701 kB/s | 361 kB     00:00    
(11/14): libglade2-2.6.4-14.fc24.x86_64.rpm                581 kB/s |  67 kB     00:00    
(12/14): libgnomecanvas-2.30.3-11.fc24.x86_64.rpm          964 kB/s | 230 kB     00:00    
(13/14): system-config-keyboard-base-1.4.0-10.fc25.noarch. 826 kB/s | 108 kB     00:00    
(14/14): libselinux-python-2.5-13.fc25.x86_64.rpm          1.4 MB/s | 239 kB     00:00    
-------------------------------------------------------------------------------------------
Total                                                      597 kB/s | 1.5 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Installing  : libglade2-2.6.4-14.fc24.x86_64                                        1/15 
  Installing  : pygtk2-libglade-2.24.0-15.fc25.x86_64                                 2/15 
  Installing  : libart_lgpl-2.3.21-15.fc25.x86_64                                     3/15 
  Installing  : newt-python-0.52.19-2.fc25.x86_64                                     4/15 
  Installing  : libgnomecanvas-2.30.3-11.fc24.x86_64                                  5/15 
  Installing  : libselinux-python-2.5-13.fc25.x86_64                                  6/15 
  Installing  : python-slip-0.6.4-4.fc25.noarch                                       7/15 
  Installing  : system-config-keyboard-base-1.4.0-10.fc25.noarch                      8/15 
  Installing  : system-config-keyboard-1.4.0-10.fc25.noarch                           9/15 
  Installing  : gnome-python2-2.28.1-18.fc25.x86_64                                  10/15 
  Installing  : gnome-python2-canvas-2.28.1-18.fc25.x86_64                           11/15 
  Installing  : system-config-date-1.10.9-3.fc25.noarch                              12/15 
  Installing  : system-config-language-3.4.0-1.fc25.noarch                           13/15 
  Installing  : pykickstart-2.32-1.fc25.noarch                                       14/15 
  Installing  : system-config-kickstart-2.9.3-3.fc24.noarch                          15/15 
  Verifying   : system-config-date-1.10.9-3.fc25.noarch                               1/15 
  Verifying   : system-config-kickstart-2.9.3-3.fc24.noarch                           2/15 
  Verifying   : gnome-python2-canvas-2.28.1-18.fc25.x86_64                            3/15 
  Verifying   : newt-python-0.52.19-2.fc25.x86_64                                     4/15 
  Verifying   : pygtk2-libglade-2.24.0-15.fc25.x86_64                                 5/15 
  Verifying   : python-slip-0.6.4-4.fc25.noarch                                       6/15 
  Verifying   : pykickstart-2.32-1.fc25.noarch                                        7/15 
  Verifying   : system-config-keyboard-1.4.0-10.fc25.noarch                           8/15 
  Verifying   : system-config-language-3.4.0-1.fc25.noarch                            9/15 
  Verifying   : gnome-python2-2.28.1-18.fc25.x86_64                                  10/15 
  Verifying   : libart_lgpl-2.3.21-15.fc25.x86_64                                    11/15 
  Verifying   : libgnomecanvas-2.30.3-11.fc24.x86_64                                 12/15 
  Verifying   : libglade2-2.6.4-14.fc24.x86_64                                       13/15 
  Verifying   : system-config-keyboard-base-1.4.0-10.fc25.noarch                     14/15 
  Verifying   : libselinux-python-2.5-13.fc25.x86_64                                 15/15 

Installed:
  gnome-python2.x86_64 2.28.1-18.fc25                                                      
  gnome-python2-canvas.x86_64 2.28.1-18.fc25                                               
  libart_lgpl.x86_64 2.3.21-15.fc25                                                        
  libglade2.x86_64 2.6.4-14.fc24                                                           
  libgnomecanvas.x86_64 2.30.3-11.fc24                                                     
  libselinux-python.x86_64 2.5-13.fc25                                                     
  newt-python.x86_64 0.52.19-2.fc25                                                        
  pygtk2-libglade.x86_64 2.24.0-15.fc25                                                    
  pykickstart.noarch 2.32-1.fc25                                                           
  python-slip.noarch 0.6.4-4.fc25                                                          
  system-config-date.noarch 1.10.9-3.fc25                                                  
  system-config-keyboard.noarch 1.4.0-10.fc25                                              
  system-config-keyboard-base.noarch 1.4.0-10.fc25                                         
  system-config-kickstart.noarch 2.9.3-3.fc24                                              
  system-config-language.noarch 3.4.0-1.fc25                                               

Complete!

Output of failed installation attempts

sudo dnf install system-config-kickstart;
 Last metadata expiration check: 2:55:26 ago on Sun May 14 08:43:53 2017.
 Error: nothing provides system-config-date needed by system-config-kickstart-2.9.3-3.fc24.noarch
 (try to add '--allowerasing' to command line to replace conflicting packages)
sudo dnf install system-config-kickstart --allowerasing;
 Last metadata expiration check: 1:44:34 ago on Sun May 14 08:43:53 2017.
 Error: nothing provides system-config-date needed by system-config-kickstart-2.9.3-3.fc24.noarch
sudo dnf install system-config-date;
 Last metadata expiration check: 2:22:31 ago on Sun May 14 08:43:53 2017.
 No package system-config-date available.
 Error: Unable to find a match.

Replace a character in all filenames

The following command will search for files in the current directory (.) that have in their name the colon character :.
The files that match will then be renamed and all instances of the colon character : in the names will be replaced by the full stop character ..

find . -name "*:*" -execdir sh -c 'mv "$1" "${1//:/.}"' _ {} \;
  • -execdir command {} + is like -exec, but the specified command is run from the subdirectory containing the matched file, which is not normally the directory in which you started find.

Example: if you have a file named 2017-03-15 14:34:44.116002523.png then it will be renamed to 2017-03-15 14.34.44.116002523.png.


How to Start/Stop or Enable/Disable firewalld on Fedora 25

firewalld (Dynamic Firewall Manager) tool provides a dynamically managed firewall. The tool enables network/firewall zones to define the trust level of network connections and/or interfaces. It has support both for IPv4 and IPv6 firewall settings. Also, it supports Ethernet bridges and allow you to separate between runtime and permanent configuration options. Finally, it supports an interface for services or applications to add firewall rules directly.

Disable firewalld

To disable firewalld, execute the following command as root or using sudo:

systemctl disable firewalld;

Enable firewalld

To enable firewalld, execute the following command as root or using sudo:

systemctl enable firewalld;

Stop firewalld

To stop (or deactivate) firewalld,execute the following command as root or using sudo:

systemctl stop firewalld;

Start firewalld

To start (or activate) firewalld, execute the following command as root or using sudo:

systemctl start firewalld;

Status of firewalld

To check the status of firewalld, execute the following command as root or using sudo:

systemctl status firewalld;

CONCEPTS

systemd provides a dependency system between various entities called “units” of 12 different types. Units encapsulate various objects that are relevant for system boot-up and maintenance. The majority of units are configured in unit configuration files, whose syntax and basic set of options is described in systemd.unit(5), however some are created automatically from other configuration, dynamically from system state or programmatically at runtime. Units may be “active” (meaning started, bound, plugged in, …, depending on the unit type, see below), or “inactive” (meaning stopped, unbound, unplugged, …), as well as in the process of being activated or deactivated, i.e. between the two states (these states are called “activating”, “deactivating”). A special “failed” state is available as well, which is very similar to “inactive” and is entered when the service failed in some way (process returned error code on exit, or crashed, or an operation timed out). If this state is entered, the cause will be logged, for later reference. Note that the various unit types may have a number of additional substates, which are mapped to the five generalized unit states described here.
— From man systemd

The above, in a nutshell:

  • enabled is a service that is configured to start when the system boots
  • disabled is a service that is configured to not start when the system boots
  • active is a service that is currently running
  • inactive is a service that is currently stopped and may be disabled, but it can be started and become active