enable SSH by adding an empty file called “ssh” (yes, without any extension) to the boot volume
boot it up
set it up as I like
Extracting the OS image onto micro SD card is a “breeze” with right tools – select OS image, select where do you want to put it and click Flash:
After it’s finished, don’t forget to enable yourself the SSH access (it’s easier that way):
Done.
Let’s put the card back into Raspberry Pi and boot it up.
Few seconds later, you can use (e.g.) Windows Terminal and included SSH client to access your Raspberry Pi (default networking option is DHCP, with default username of pi and password raspberry):
I wanted to “tweak” my installation a bit (with the provided raspi-config script), so I’ve used the following for disabling unnecessary devices, custom network settings, etc.:
PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# raspi-config script is located in /usr/bin/raspi-config
# settings (some of them) are located in /boot/config.txt
# update the raspi-config script (or you can use 'sudo raspi-config nonint do_update') and vim... is nice to have
sudo apt update
sudo apt install-yraspi-configvim
# set static ip address (configure in '/etc/dhcpcd.conf', can check interfaces with 'ip link' - can be done nicer, but... :))
Sometimes, you need to know your public IP address because of… reasons. My particular reason was creating firewall rule to limit SSH only from my current public IP address, to a machine on the Internet. And how to do it?
You can always use free services like What Is My IP?, which shows you your public IP address in a nice form:
The other day I was creating some Linux virtual machines (I know, I know…) and, with Azure being my preferred hosting platform, I’ve decided to create this machines by using a simple PowerShell script. Not because I’m so good at PowerShell, but because I like it… and sometimes I really don’t like clicking through the wizard to create multiple machines.
I wanted to create multiple machines with ease, each with “static” IP address from the provided subnet, accessible via the Internet (SSH, HTTP) and running the latest Ubuntu Linux, of course.
Learn software management with advanced Linux administration in this tutorial by Frederik Vos, a Linux trainer and evangelist and a senior technical trainer of virtualization technologies, such as Citrix XenServer and VMware vSphere.
— post by Frederik Vos, provided by Packt —
Software management
In the old days, installing software was aĀ matterĀ of extracting an archive to a filesystem. There were several problems with this approach:
It was difficult to remove the software if the files were copied into directories that were also used by another software
It was difficult to upgrade software, maybe because the files were still in use or were renamed
It was difficult to handle shared libraries
That’s why Linux distributions invented software managers.
The RPM software manager
In 1997, Red Hat released the first version ofĀ theirĀ package manager, RPM. Other distributions such as SUSE adopted this package manager. RPM is the name of theĀ rpm utility, as well asĀ theĀ name of the format and the filename extension.
The RPM package contains the following:
A CPIO archive
Metadata with information about the software, such as a description and dependencies
Scriptlets for pre and post-installation scripts
In the past, Linux administrators used theĀ rpmĀ utility to install/update and remove software on a Linux system. If there was a dependency, theĀ rpmĀ command was able to tell exactly which other packages you needed to install. However, theĀ rpmĀ utility couldnāt fix the dependencies or possible conflicts between packages.
Nowadays, theĀ rpmĀ utility isnāt used any longer to install or remove software; instead, you use more advanced software installers.Ā After the installation of software withĀ yumĀ (Red Hat/CentOS) orĀ zypperĀ (SUSE), all the metadata goes into a database. Querying thisĀ rpmĀ database with theĀ rpmĀ command can be very handy.
A list of the most commonĀ rpmĀ query parameters are as follows:
Parameter
Description
-qa
List allĀ the installedĀ packages.
-qi <software>
List information.
-qc <software>
List the installed configuration files.
-qd <software>
List the installed documentation and examples.
-ql <software>
List all the installed files.
-qf <filename>
Shows the package that installed this file
-V <software>
Verifies the integrity/changes after the installation of a package;Ā useĀ -vaĀ to do it for all installed software.
-qp
Use this parameter together with other parameters if the package is not already installed. It’s especially useful if you combine this parameter withĀ –scriptĀ to investigate the pre and post-installation scripts in the package.
The followingĀ screenshotĀ is an example ofĀ gettingĀ information about the installed SSH server package:
The output of theĀ -VĀ parameter indicates that the modification time has changed since the installation. Now, make another change in theĀ sshd_configĀ file:
If you verify theĀ installedĀ package again, there is anĀ SĀ added to the output, indicating that the file size is different, and aĀ T, indicating that the modificationĀ timeĀ has changed:
Other possible characters in the output are as follows:
S
File size
M
Mode (permissions)
5
Checksum
D
Major/minor on devices
L
Readlink mismatch
U
User ownership
G
Group ownership
T
Modification time
P
Capabilities
For text files, theĀ diffĀ command can help show the differences between the backup in theĀ /tmpĀ directory and the configuration inĀ /etc/ssh:
Shell
1
sudo diff/etc/ssh/sshd_config/tmp/sshd_config
You can also restoreĀ theĀ originalĀ fileĀ as follows:
Shell
1
sudo cp/tmp/sshd_config/etc/ssh/sshd_config
The DPKG software manager
The Debian distribution doesn’tĀ useĀ the RPM format; instead, itĀ usesĀ the DEB format invented in 1995. The format is in use on all Debian and Ubuntu-based distributions.
A DEB package contains:
A file,Ā debian-binary, with the version of the package
An archive file, control.tar, with metadata (package name, version, dependencies, and maintainer)
An archive file, data.tar, containing the actual software
Management of DEB packages can be done with theĀ dpkgĀ utility. LikeĀ rpm, the utility is not in use any longer to install software. Instead, the more advancedĀ aptĀ command is used.Ā All the metadata goes into a database, which can be queried withĀ dpkgĀ orĀ dpkg-query.
The important parameters ofĀ dpkg-queryĀ are as follows:
-l
Lists all the packages without parameters, but you can use wildcards, for example,Ā dpkg -l *ssh*
-L <package>
Lists files in an installed package
-p <package>
Shows information about the package
-s <package>
Shows the state of the package
The first column from the output ofĀ dpkg -lĀ also shows a status as follows:
The first character in the first column is the desired action,Ā the second is the actual state of the package, and a possible third character indicates an error flag (R).Ā iiĀ means that the package is installed.
The possibleĀ desiredĀ states are as follows:
(u) unknown
(h) hold
(r) remove
(p) urge
The important packageĀ statesĀ are as follows:
n(ot) installed
H(a)lf installed
Hal(F) configured
Software management with YUM
Your Update ManagerĀ orĀ Yellowdog Updater ModifiedĀ (YUM) is a modernĀ softwareĀ managementĀ toolĀ that was introduced by Red Hat in Enterprise Linux version 5, replacing theĀ up2dateĀ utility. It isĀ currentlyĀ in use in all Red Hat-based distributions but will be replaced withĀ dnf, which is used by Fedora. TheĀ goodĀ news is thatĀ dnfĀ is syntax-compatible withĀ yum.
Yum isĀ responsibleĀ for:
Installing software, including dependencies
Updating software
Removing software
Listing and searching for software
The important basic parameters are as follows:
Command
DescriptionĀ
yum search
Search for software based onĀ packageĀ name/summary
yum provides
SearchĀ forĀ software basedĀ onĀ a filename in a package
yum install
Install software
yum info
InformationĀ andĀ status
yum update
UpdateĀ allĀ software
yum remove
RemoveĀ software
You can also install patterns of software, for instance, the pattern or groupĀ File and Print ServerĀ is a convenient way to install the NFS and Samba file servers together with the Cups print server:
Command
Description
yum groups list
List theĀ availableĀ groups.
yum groups install
Install a group.
yum groups info
InformationĀ aboutĀ a group, including theĀ groupĀ names that are in use by the Anaconda installer.Ā This information is important for unattended installations.
yum groups update
Update softwareĀ withinĀ a group.
yum groups remove
Remove theĀ installedĀ group.
AnotherĀ niceĀ feature ofĀ yumĀ isĀ workingĀ with history:
Command
Description
yum history list
List theĀ tasksĀ executed byĀ yum
yum history info <number>
List the content of a specific task
yum history undo <number>
Undo the task; a redo is also available
TheĀ yumĀ command uses repositories to be able to do all the software management. To list the currently configured repositories, use:
Shell
1
yum repolist
To add another repository, you’ll need theĀ yum-config-managerĀ tool, which creates and modifies the configuration files inĀ /etc/yum.repos.d. For instance, if you want to add a repository to install Microsoft SQL Server, use the following:
Shell
1
2
3
yum-config-manager--add-repo\
Ā https://packages.microsoft.com/config/rhel/7/\
Ā mssql-server-2017.repo
TheĀ yumĀ functionality can be extended with plugins, for instance, to select the fastest mirror, enabling the filesystemĀ /Ā LVM snapshots and runningĀ yumĀ as a scheduled task (cron).
Software management with Zypp
SUSE, like Red Hat, uses RPM forĀ packageĀ management. But instead of usingĀ yum, they use another toolset with Zypp (also known as libZypp) as backend. Software management can be doneĀ withĀ the graphical configuration software YaST or the command-line interface tool Zypper. The important basic parameters are as follows:
Command
Description
zypper search
SearchĀ forĀ software
zypper install
InstallĀ software
zypper remove
RemoveĀ software
zypper update
UpdateĀ software
zypper dist-upgrade
Perform aĀ distributionĀ upgrade
zypper info
ShowĀ information
There is a search option to search for a command,Ā what-provides, but it’s very limited. If you don’t know the package name, there is a utility calledĀ cnfĀ instead. Before you can useĀ cnf, you’ll need to installĀ scout; this way, the package properties can be searched:
Shell
1
sudo zypper install scout
After this, you can useĀ cnf:
If you want to update your system to aĀ newĀ distribution version, you have to modify the repositories first. For instance, if you want to update from SUSE LEAP 42.3 to version 15.0, executeĀ theĀ following procedure:
First, install the available updates for your current version:
Shell
1
sudo zypper update
Update to the latest version in the 42.3.x releases:
If you add a repository, you must always refreshĀ theĀ repositories:
Shell
1
sudo zypper refresh
Software management with apt
In Debian/Ubuntu-based distributions, softwareĀ managementĀ is doneĀ viaĀ theĀ aptĀ utility, which is a recent replacement for the utilities,Ā apt-getĀ andĀ apt-cache.
The most-used commands include:
Command
Description
apt list
ListĀ packages
apt search
SearchĀ inĀ descriptions
apt install
InstallĀ aĀ package
apt show
ShowĀ packageĀ details
apt remove
Remove aĀ package
apt update
Update catalog ofĀ availableĀ packages
apt upgrade
Upgrade theĀ installedĀ software
apt edit-sources
Edit theĀ repositoryĀ configuration
Repositories are configured inĀ /etc/apt/sources.listĀ and files in theĀ /etc/apt/sources.list.d/Ā directory. Alternatively, there is a command,Ā apt-add-repository, available:
Shell
1
2
apt-add-repository\
Ā 'deb http://myserver/path/to/repo stable'
TheĀ aptĀ repositories have the concept of release classes:
Old stable, tested in the previous version of a distribution
Stable
Testing
Unstable
They also have the concept of components:
Main: Tested and provided with support and updates
Contrib: Tested and provided with support and updates, but there are dependencies that are not in main, but for instance, in non-free
Universe: Community provided, no support, updates possible
Restricted: Proprietary device drivers
Multiverse: Software restricted by copyright or legal issues
If you found this article interesting, you can explore Frederik Vosā Hands-On Linux Administration on Azure to administer Linux on Azure. Hands-On Linux Administration on Azurewill help you efficiently run Linux-based workloads in Azure and make the most of the important tools required for deployment.
In light of “Microsoft loves Linux” initiative, you can now deploy your Linux virtual machines by using templates in the System Center 2016: Virtual Machine Manager. As I was searching on how to do this (successfully), there were couple of articles that helped, so Iāve decided to do a short list of all the necessary steps (in one place).
Steps to make your Linux VM template deployments work:
create a new (Generation 2) virtual machine (as you would normally do)
install the Linux operating system in that virtual machine (as you would normally do)
HINT: A list of supported Linux distributions and versions on Hyper-V is available here.
install the Linux Integration Services (LIS) (as per this post):
open the “modules” file
Shell
1
sudo nano/etc/initramfs-tools/modules
add the following to the end of this file:
1
2
3
4
hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc
save it (Ctrl+X and Y)
install LIS and reboot the machine by using the following commands:
check if the services are running by using the command:
Shell
1
sudo lsmod
install the Virtual Machine Manager agent (as per this post):
share the folder C:\Program Files\Microsoft System Center 2016\Agents\Linux on your VMM machine
copy the VMM agent files to Linux virtual machine
as a real Windows admin, I did it through the GUI
install the agent:
Shell
1
sudo./install scvmmguestagent.1.0.2.1075.x64.tar
fix the boot for Generation 2 virtual machine (boot information is by default stored in the VM configuration file, not on disk ā Ben wrote a great article on this āissueā)
Benās way (didnāt work for me):
change directory to the boot EFI directory
Shell
1
sudo cd/boot/efi/EFI
copy the ubuntu directory in to a new directory named boot
Shell
1
sudo cp-rubuntu/boot
change directory to the newly created boot directory
Shell
1
sudo cdboot
rename the shimx64.efi file
Shell
1
sudo mvshimx64.efibootx64.efi
TriJetScudās way in the comments (worked for me with Ubuntu 16.04 Generation 2 VM):
The other day I was āplayingā with setting up Office 365 for one of our clients ā they have Linux machines for their DNS servers, and BIND as their DNS solution. As this was my first encounter with configuring BIND by myself, I just wanted to share steps Iāve taken to make it work (in my lab environment) ā maybe it will help someoneā¦
DISCLAIMER: Iām not a Linux/UNIX expert! I try to figure out what I need, and then try to make this work⦠with the help of Internet resources (or experts), of course. There is plenty of resources on how to do this already, but I like to have things in one place if I need them again.
So, Iāve began my experiment with wondering which Linux distribution should I take. After some consulting (thanks, Ingrid ), the final choice was pretty easy ā Fedora(criteria ā had to be relatively easy to use (for non-Linux person like me), had to work in Hyper-V without much trouble, and there should be someone who can help if I got stuck).
After a pretty simple installation process (wizard, Next, ā¦, Next, Finish), Iāve had my Fedora box up and running.
Now, the more complicated part ā setup this box to be BIND server, and load the correct records in it, so that Office 365 can add and verify my domain.
Here are the high-level steps (Iāve used Terminal, with su rights):
1. install few packages to get things up and running:
Shell
1
yum-yinstall bind bind-utils bind-libs nano
2. configure the BIND (DNS) server to run at startup:
1
chkconfig named on
3. query the firewall rules for UDP port 53 access: