Browse code

Updated photon-admin-guide doc

Change-Id: Ia3722affa7dc9548738a0553c59fc9ad99f3f10c
Reviewed-on: http://photon-jenkins.eng.vmware.com/1071
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>
Tested-by: Divya Thaluru <dthaluru@vmware.com>

dthaluru authored on 2016/06/11 04:07:52
Showing 5 changed files
1 1
new file mode 100755
2 2
Binary files /dev/null and b/docs/images/ova-firefox.png differ
3 3
new file mode 100755
4 4
Binary files /dev/null and b/docs/images/ova-import.png differ
5 5
new file mode 100755
6 6
Binary files /dev/null and b/docs/images/photon-installer-sm.png differ
7 7
new file mode 100755
8 8
Binary files /dev/null and b/docs/images/ws-new-vm.png differ
9 9
new file mode 100755
... ...
@@ -0,0 +1,1540 @@
0
+# Photon Administration Guide
1
+
2
+-   [Introduction](#introduction)
3
+    -   [Examining the Packages in the SPECS Directory on
4
+        Github](#examining-the-packages-in-the-specs-directory-on-github)
5
+    -   [Looking at the Differences Between the Minimal and the Full
6
+        Version](#looking-at-the-differences-between-the-minimal-and-the-full-version)
7
+    -   [The Root Account and the sudo and su
8
+        Commands](#the-root-account-and-the-sudo-and-su-commands)
9
+-   [Quick Start](#quick-start)
10
+    -   [Obtaining the ISO from Bintray and Creating a Photon OS VM in
11
+        VMware
12
+        Workstation](#obtaining-the-iso-from-bintray-and-creating-a-photon-os-vm-in-vmware-workstation)
13
+    -   [Installing the OVA for the Minimal Version in
14
+        vSphere](#installing-the-ova-for-the-minimal-version-in-vsphere)
15
+    -   [Rapidly Deploying the Photon OS OVA in VMware Workstation 12
16
+        Pro](#rapidly-deploying-the-photon-os-ova-in-vmware-workstation-12-pro)
17
+    -   [Root Password Rules](#root-password-rules)
18
+    -   [Permitting Root Login with
19
+        SSH](#permitting-root-login-with-ssh)
20
+    -   [Deploying Photon OS on a Mac with
21
+        AppCatalyst](#deploying-photon-os-on-a-mac-with-appcatalyst)
22
+    -   [PXE Boot](#pxe-boot)
23
+    -   [Kickstart](#kickstart)
24
+    -   [Checking the Version and Build
25
+        Number](#checking-the-version-and-build-number)
26
+-   [Tiny DNF for Package Management](#tiny-dnf-for-package-management)
27
+    -   [Configuration Files and
28
+        Repositories](#configuration-files-and-repositories)
29
+    -   [Options for Commands](#options-for-commands)
30
+    -   [Commands](#commands)
31
+    -   [Adding a New Repository](#adding-a-new-repository)
32
+-   [Managing Services with systemd](#managing-services-with-systemd)
33
+    -   [Viewing Services](#viewing-services)
34
+    -   [Controlling Services](#controlling-services)
35
+    -   [Creating a Startup Service](#creating-a-startup-service)
36
+    -   [Disabling the Photon OS
37
+        httpd.service](#disabling-the-photon-os-httpd.service)
38
+    -   [Auditing System Events with
39
+        auditd](#auditing-system-events-with-auditd)
40
+    -   [Analyzing systemd Logs with
41
+        journalctl](#analyzing-systemd-logs-with-journalctl)
42
+    -   [Migrating Scripts to systemd](#migrating-scripts-to-systemd)
43
+-   [Managing the Network
44
+    Configuration](#managing-the-network-configuration)
45
+    -   [Use `ip` and `ss` Commands Instead of `ifconfig` and
46
+        `netstat`](#use-ip-and-ss-commands-instead-of-ifconfig-and-netstat)
47
+    -   [Configuring Network
48
+        Interfaces](#configuring-network-interfaces)
49
+    -   [Setting a Static IP Address](#setting-a-static-ip-address)
50
+    -   [Turning Off DHCP](#turning-off-dhcp)
51
+    -   [Adding a DNS Server](#adding-a-dns-server)
52
+    -   [Setting Up Networking for Multiple
53
+        NICs](#setting-up-networking-for-multiple-nics)
54
+    -   [Combining DHCP and Static IP Addresses with IPv4 and
55
+        IPv6](#combining-dhcp-and-static-ip-addresses-with-ipv4-and-ipv6)
56
+    -   [Inspecting the Status of Network Links with
57
+        `networkctl`](#inspecting-the-status-of-network-links-with-networkctl)
58
+    -   [Turning on Network Debugging](#turning-on-network-debugging)
59
+    -   [Mounting a Network File
60
+        System](#mounting-a-network-file-system)
61
+    -   [Installing the Packages for tcpdump and netcat with
62
+        tdnf](#installing-the-packages-for-tcpdump-and-netcat-with-tdnf)
63
+-   [Cloud-Init on Photon OS](#cloud-init-on-photon-os)
64
+    -   [Creating a Stand-Alone Photon Machine with
65
+        cloud-init](#creating-a-stand-alone-photon-machine-with-cloud-init)
66
+    -   [Customizing a Photon OS Machine on
67
+        EC2](#customizing-a-photon-os-machine-on-ec2)
68
+    -   [Running a Photon OS Machine on
69
+        GCE](#running-a-photon-os-machine-on-gce)
70
+-   [Docker Containers](#docker-containers)
71
+-   [Kubernetes](#kubernetes)
72
+-   [RPM-OSTree](#rpm-ostree)
73
+-   [Disabling TLS 1.0 to Improve Transport Layer
74
+    Security](#disabling-tls-1.0-to-improve-transport-layer-security)
75
+-   [Building a Package from a Source
76
+    RPM](#building-a-package-from-a-source-rpm)
77
+-   [References](#references)
78
+
79
+
80
+## Introduction
81
+
82
+This guide covers managing packages, controlling services with systemd, setting up networking, initializing Photon OS with cloud-init, running Docker containers, and working with other technologies, such as Kubernetes. 
83
+
84
+Photon OS is a Linux container host optimized for vSphere and cloud-computing platforms such as Amazon Elastic Compute and Google Compute Engine. Photon OS is lightweight and extensible. It supports the most common container formats, including Docker, Rocket, and Garden. Photon OS includes a yum-compatible, package-based lifecycle management system called tdnf and optionally works with RPM-OSTree for image-based system versioning. 
85
+
86
+When used with development tools and environments such as VMware Fusion, VMware Workstation, HashiCorp (Vagrant and Atlas), and production runtime environments (vSphere, vCloud Air), Photon OS lets you seamlessly migrate container-based applications from development to production. With a small footprint and fast boot and run times, Photon OS is optimized for cloud computing and cloud  applications.  
87
+
88
+There are two versions of Photon OS: a minimal version and a full version. 
89
+
90
+The minimal version of Photon OS is lightweight container host runtime environment best suited to managing and hosting containers. The minimal version contains just enough packaging and functionality to manage and modify containers while remaining a fast runtime environment. The minimal version is ready to work with appliances. 
91
+
92
+The full version of Photon OS includes additional packages to help you customize the system and create containerized applications. For  running containers, the full version is excessive. The full version is targeted at helping you create, develop, test, and package an application that runs a container. 
93
+
94
+Two characteristics of Photon OS stand out: It manages services with systemd and it manages packages with an open source, yum-compatible package manager called tdnf, for Tiny DNF. 
95
+
96
+By using systemd, Photon OS adopts a contemporary Linux standard to manage system services. Photon OS bootstraps the user space and concurrently starts services with systemd. The systemctl utility controls services on Photon OS. For example, instead of running the /etc/init.d/ssh script to stop and start the OpenSSH server on a init.d-based Linux system, you run the following systemctl commands on Photon OS: 
97
+
98
+	systemctl stop sshd
99
+	systemctl start sshd
100
+
101
+Tdnf keeps the operating system as small as possible while preserving yum's robust package-management capabilities. On Photon OS, tdnf is the default package manager for installing new packages. It is a C implementation of DNF package manager. 
102
+
103
+### Examining the Packages in the SPECS Directory on Github
104
+
105
+The SPECS directory of the GitHub website for Photon OS contains all the packages that can appear in Photon OS repositories:  
106
+
107
+https://github.com/vmware/photon/tree/master/SPECS
108
+
109
+To see the version of a package, in the SPECS directory, click the name of the subdirectory of the package that you want to examine, and then click the `.spec` filename in the subdirectory. For example, the version of OpenJDK, which contains the openjre package that installs the Java class library and the javac Java compiler, looks like this: 
110
+
111
+<pre>
112
+%define _use_internal_dependency_generator 0
113
+Summary:	OpenJDK 
114
+Name:		openjdk
115
+Version:	1.8.0.72
116
+Release:	1%{?dist}
117
+License:	GNU GPL
118
+URL:		https://openjdk.java.net
119
+Group:		Development/Tools
120
+Vendor:		VMware, Inc.
121
+Distribution:   Photon
122
+AutoReqProv: 	no
123
+Source0:	http://anduin.linuxfromscratch.org/files/BLFS/OpenJDK-%{version}/OpenJDK-%{version}-x86_64-bin.tar.xz
124
+%define sha1 OpenJDK=0c705d7b13f4e22611d2da654209f469a6297f26
125
+%description
126
+The OpenJDK package installs java class library and javac java compiler. 
127
+
128
+%package	-n openjre
129
+Summary:	Jave runtime environment
130
+AutoReqProv: 	no
131
+%description	-n openjre
132
+It contains the libraries files for Java runtime environment
133
+#%global __requires_exclude ^libgif.*$
134
+#%filter_from_requires ^libgif.*$...
135
+...
136
+</pre>
137
+
138
+### Looking at the Differences Between the Minimal and the Full Version
139
+
140
+The minimal version of Photon OS contains about 50 packages. The full version of Photon OS adds several hundred packages to those in the minimal version to create a more fully featured operating system. 
141
+
142
+You can view a list of the packages that appear in the minimal version by examining the following file: 
143
+
144
+[https://github.com/vmware/photon/blob/master/common/data/packages_minimal.json](https://github.com/vmware/photon/blob/master/common/data/packages_minimal.json)
145
+
146
+You can view a list of the packages that appear in the minimal version by examining the following file: 
147
+
148
+[https://github.com/vmware/photon/blob/master/common/data/packages_full.json](https://github.com/vmware/photon/blob/master/common/data/packages_full.json)
149
+
150
+If the minimal or the full version of Photon OS does not contain a package that you want, you can of course install it with tdnf, which appears in both the minimal and full versions of Photon OS by default. In the full version of Photon OS, you can also install packages by using yum. 
151
+
152
+One notable difference between the two versions of Photon OS pertains to OpenJDK, the package that contains not only the Java runtime environment (openjre) but also the Java compiler (javac). The OpenJDK package appears in the full but not the minimal version of Photon OS. To add support for Java programs to the minimal version of Photon OS, install the Java packages and their dependencies: 
153
+
154
+	tdnf install openjdk
155
+	Installing:
156
+	openjre 	x86_64    1.8.0.92-1.ph1    95.09 M
157
+	openjdk 	x86_64    1.8.0.92-1.ph1    37.63 M
158
+
159
+A later section covers tdnf. 
160
+
161
+### The Root Account and the sudo and su Commands
162
+
163
+This guide assumes that you are logged in to Photon OS with the root account and running commands as root. The sudo program comes with the full version of Photon OS. On the minimal version, you must install sudo with tdnf if you want to use it. As an alternative to installing sudo on the minimal version, you can switch users as needed with the `su` command to run commands that require root privileges. 
164
+
165
+## Quick Start
166
+
167
+This section helps you get Photon OS up and running quickly and easily. There are several ways to deploy Photon OS for free within a matter of minutes:
168
+
169
+* Obtain the ISO from Bintray and use it to create a virtual machine running Photon OS.
170
+* Install the OVA for the minimal version of Photon OS in VMware vSphere.
171
+* Rapidly deploy the OVA for the minimal version of Photon OS in VMware Workstation 12 Pro. 
172
+* Install VMware AppCatalyst for free on a Mac and launch a virtual machine running Photon OS, which is included with AppCatalyst.
173
+
174
+### Obtaining the ISO from Bintray and Creating a Photon OS VM in VMware Workstation
175
+
176
+The full version of Photon OS installs from an ISO in VMware Workstation and other hypervisors in a matter of minutes. Photon OS is a free download from the Bintray web site.
177
+
178
+This section demonstrates how to create a virtual machine running Photon OS in VMware Workstation 12 Pro. If you are using a different hypervisor, the example set by this section should help you install it in your system. If you work on a Mac, see the section on deploying Photon OS on a Mac with VMware AppCatalyst below. For instructions on how to install Photon OS from an ISO in VMware vSphere, see [Installing Photon OS on VMware vSphere from an ISO Image](https://github.com/vmware/photon/wiki/Running-Project-Photon-on-vSphere).
179
+
180
+1. Go to the following Bintray URL and download the ISO for the general availability release of Photon OS:
181
+
182
+	https://bintray.com/vmware/photon/iso/view
183
+
184
+1. In VMware Workstation, type Ctrl+N to create a new virtual machine. 
185
+
186
+1. In the New Virtual Machine Wizard, select `Typical`, and then click `Next`.
187
+
188
+1. Select `Installer disk image file (iso)`, click `Browse` to locate the Photon OS ISO that you downloaded from Bintray, and then click `Next`.
189
+
190
+1. For the guest operating system, select `Linux`. From the `Version` drop-down menu, select `VMware Photon 64-bit`. If you have an older version of VMware Workstation and Photon does not appear in the list, select `Other Linux 3.x kernel 64-bit`.
191
+![Alt text](images/ws-new-vm.png)
192
+
193
+1. Click `Next` through the remaining dialog boxes of the wizard,  either accepting the default settings, which is recommended, or making the changes that you want, and then click `Finish`.
194
+
195
+1. Power on the virtual machine and, in the Workstation window containing Photon, press Enter to start the installation.
196
+![installer](images/photon-installer-sm.png)
197
+
198
+1. During disk setup, the installer might ask you to confirm that this will erase the disk. If so, accept the default value of `yes` by hitting your Enter key.
199
+
200
+1. Select the installation that you want. For this example, choose `Photon Full` by using the tab key to move to Photon Full and then hitting the space bar to select it. Press Enter to install it. 
201
+
202
+1. Either accept the default hostname that Photon provides or type the name that you want. Press Enter to continue. 
203
+
204
+1. Type the root password. Photon OS requires the root password to be a complex string containing no common words or names.
205
+
206
+The installation typically completes in about 150 seconds for the full version and in less than 30 seconds for the minimal version. After the installation finishes, boot the system and log in as root with your root password. 
207
+
208
+To connect to Photon OS by SSH, see the section on permitting root login with SSH below.  
209
+
210
+You can also build an ISO containing Photon OS from its source code on GitHub by following the instructions in the document on [building Photon OS](https://github.com/vmware/photon/blob/master/docs/build-photon.md). 
211
+
212
+### Installing the OVA for the Minimal Version in vSphere
213
+
214
+You can download the OVA for the minimal version of Photon OS from Bintray and deploy it in vSphere in a matter of seconds. 
215
+
216
+Download the OVA for the minimal version of Photon OS from the following URL: 
217
+
218
+	https://bintray.com/vmware/photon/ova
219
+
220
+To install the OVA in vSphere, on the File menu, click Deploy OVF Template, and then click Browse to locate the image that you downloaded. Move through the Deploy OVF Template dialog boxes by clicking Next to accept the default settings, and then click Finish. 
221
+
222
+In vSphere Client, turn on the power of the Photon OS virtual machine and open a console to it.
223
+
224
+The default password for the root account is `changeme`, and you must change it when you first login. For security, Photon OS forbids common dictionary words for the root password. 
225
+
226
+There are other options for installing Photon OS in vSphere, such as building an ISO from the source code. For more information about the versions of Photon and their installation options, see [Running Photon OS on vSphere](https://github.com/vmware/photon/wiki/Running-Project-Photon-on-vSphere).
227
+
228
+### Rapidly Deploying the Photon OS OVA in VMware Workstation 12 Pro
229
+
230
+Here's how to rapidly deploy the OVA for Photon in VMware Workstation 12 Pro by using an up-to-date version of Firefox. The procedure in other browsers or another version of Workstation might be different. 
231
+
232
+In Firefox, download the OVA for the minimal version of Photon OS from this URL: 
233
+
234
+	https://bintray.com/vmware/photon/ova
235
+
236
+In the download dialog box, select `Open with VMware Workstation (default)`, like this:
237
+
238
+![Alt text](images/ova-firefox.png)
239
+
240
+In the Workstation Import dialog box, click Import.
241
+
242
+![Alt text](images/ova-import.png)
243
+
244
+Workstation creates a virtual machine from the Photon OS OVA template in a few seconds. In Workstation, power on the virtual machine and log in as root with the initial password of `changeme`.
245
+
246
+Photon OS then prompts you to change the root password.  
247
+	
248
+###	Root Password Rules
249
+
250
+When you first log on a new Photon OS machine, you must set the root password to a complex string containing no common words or names. Photon OS rejects a root password that contains simplistic patterns, common words, or words derived from the name of your account. The rules apply only to the root password, not other user and group accounts. 
251
+
252
+###	Permitting Root Login with SSH
253
+
254
+The full version of Photon OS prevents root login with SSH by default. To permit root login over SSH, open `/etc/ssh/sshd_config` with the vim text editor and set `PermitRootLogin` to `yes`. 
255
+
256
+Vim is the default text editor available in both the full and minimal versions of Photon OS. (Nano is also in the full version.) After you modify the SSH daemon's configuration file, you must restart the sshd daemon for the changes to take effect. Example: 
257
+
258
+	vim /etc/ssh/sshd_config
259
+
260
+	# override default of no subsystems
261
+	Subsystem       sftp    /usr/libexec/sftp-server
262
+
263
+	# Example of overriding settings on a per-user basis
264
+	#Match User anoncvs
265
+	#       X11Forwarding no
266
+	#       AllowTcpForwarding no
267
+	#       PermitTTY no
268
+	#       ForceCommand cvs server
269
+	PermitRootLogin yes
270
+	UsePAM yes
271
+
272
+Save your changes in vim and then restart the sshd daemon: 
273
+
274
+	systemctl restart sshd
275
+
276
+You can then connect to the Photon OS machine with the root account over SSH:
277
+
278
+	steve@ubuntu:~$ ssh root@192.168.137.131
279
+
280
+### Deploying Photon OS on a Mac with AppCatalyst
281
+
282
+VMware AppCatalyst brings the data center to your Mac desktop. AppCatalyst furnishes a Mac computer with a free hypervisor for creating virtual machines that run Photon OS, which is bundled with AppCatalyst. 
283
+
284
+Driven by an API and a command-line interface, AppCatalyst empowers you to replicate a cluster of virtual machines on a Mac to build containerized applications with microservices on Photon OS. AppCatalyst also integrates with Vagrant. AppCatalyst is a technology preview. 
285
+
286
+AppCatalyst is optimized for cloud-native application workloads. A common use case of developers is to run a desktop hypervisor so they can install a Linux machine, and for many developers, this setup takes place on a Mac. For these developers, a common use case for the desktop hypervisor is running Docker to accelerate the development and testing of their code. 
287
+
288
+By bundling Photon OS with AppCatalyst, VMware streamlines the workflow of getting a Docker engine running on a Linux machine inside a hypervisor on a Mac. 
289
+
290
+Here's how to install AppCatalyst, create a VM running Photon OS, and run a Docker container---all in a matter of minutes. The technology preview version of AppCatalyst requires Mac OS X 10.9 or later.
291
+
292
+First, turn off Fusion if you are running it on your Mac. 
293
+
294
+Second, download AppCatalyst from the following URL and then install the `.dmg` file by following the instructions in the installation wizard: 
295
+
296
+	https://www.vmware.com/cloudnative/appcatalyst-download
297
+
298
+After the wizard finishes installing AppCatalyst, you're ready to run the application. AppCatalyst does not appear in the Applications directory. Instead, in Terminal, run the following command: 
299
+
300
+	/opt/vmware/appcatalyst/bin/appcatalyst
301
+
302
+The following command creates a VM named `photonos1` by taking advantage of the template for Photon OS that is built into AppCatalyst: 
303
+
304
+	/opt/vmware/appcatalyst/bin/appcatalyst vm create photonos1
305
+
306
+By default, the VMs that you create reside in the `AppCatalyst` subdirectory of the user's `/Documents` directory.
307
+
308
+Next, make sure that there are no machines running in VMware Fusion and that it is shut down, and then turn on the VM by running this command.  
309
+
310
+	/opt/vmware/appcatalyst/bin/appcatalyst vmpower on photonos1
311
+
312
+Obtain the IP address of the VM so you can establish an SSH connection to it: 
313
+
314
+	/opt/vmware/appcatalyst/bin/appcatalyst guest getip photonos1
315
+
316
+You can then connect to the VM with the SSH keys included with AppCatalyst by running the following command and replacing the example IP address with the IP address of your VM: 
317
+
318
+	ssh -i /opt/vmware/appcatalyst/etc/appcatalyst_insecure_ssh_key photon@192.168.137.131
319
+
320
+Photon OS includes Docker. From your SSH terminal connection to the Photon OS virtual machine, you can launch a Docker container that, for example, downloads Ubuntu from the Docker repository and runs it in the Photon OS VM in AppCatalyst on your Mac: 
321
+
322
+	systemctl start docker
323
+	docker run -i -t ubuntu:14.04 /bin/bash
324
+
325
+When you are done, exit the Ubuntu machine to stop the Docker container to conserve system resources.  
326
+
327
+Photon OS also gives you the option of running a Docker container that, in turn, runs an instance of Photon OS:
328
+
329
+	docker run -i -t photon /bin/bash
330
+
331
+If you need to troubleshoot, the log files for AppCatalyst reside here:  
332
+
333
+	/Users/<your_username>/Library/Logs/VMware
334
+
335
+Virtual machines in AppCatalyst can be managed through its API. For more information, see the [AppCatalyst documentation](http://getappcatalyst.com/docs/Tech_Preview_August/) and the [AppCatalyst community site](https://communities.vmware.com/community/vmtn/devops/vmware-appcatalyst).
336
+
337
+### PXE Boot
338
+
339
+Photon OS works with the Preboot Execution Environment, or PXE, to boot by retrieving software from a PXE server over a network connection. For instructions on how to set Photon OS to boot from a PXE server, see [Network PXE Boot](https://github.com/vmware/photon/blob/master/docs/PXE-boot.md).
340
+
341
+### Kickstart
342
+
343
+Photon OS supports kickstart for unattended installations through a CD-ROM or an HTTP server. On Photon OS, kickstart can set the hostname, password, run post-installation scripts, and add public keys for SSH. See [Kickstart Support](https://github.com/vmware/photon/blob/master/docs/kickstart.md).
344
+
345
+### Checking the Version and Build Number
346
+
347
+To check the version and build number of Photon OS, concatenate `/etc/photon-release`. Example: 
348
+
349
+	cat /etc/photon-release
350
+	VMware Photon Linux 1.0
351
+	PHOTON_BUILD_NUMBER=a6f0f63
352
+
353
+The build number in the results maps to the commit number on the VMware Photon OS GitHub [commits page](https://github.com/vmware/photon/commits/master).
354
+
355
+## Tiny DNF for Package Management
356
+
357
+On Photon OS, Tiny DNF is the default package manager for installing new packages. Tdnf is a C implementation of DNF package manager. The standard syntax for tdnf commands is the same as that for DNF: 
358
+
359
+	tdnf [options] <command> [<arguments>...]
360
+
361
+You can view its help information like this: 
362
+
363
+	tdnf --help
364
+	tdnf -h
365
+
366
+In the minimal version of Photon OS, tdnf serves as the sole package manager to streamline the operating system. The full version of Photon OS includes yum, a common utility that checks for, downloads, and automatically installs RPM packages. On the minimal version of Photon OS, you can install yum by using tdnf if you are unconcerned with the size of the operating system: 
367
+
368
+	tdnf install yum
369
+
370
+### Configuration Files and Repositories
371
+
372
+The main configuration files reside in /etc/tdnf/tdnf.conf. The configuration file looks like this: 
373
+
374
+	cat /etc/tdnf/tdnf.conf
375
+	[main]
376
+	gpgcheck=1
377
+	installonly_limit=3
378
+	clean_requirements_on_remove=true
379
+	repodir=/etc/yum.repos.d
380
+	cachedir=/var/cache/tdnf
381
+
382
+The cache files for data and metadata reside in /var/cache/tdnf. 
383
+
384
+The repositories appear in /etc/yum.repos.d/ with `.repo` file extensions:
385
+
386
+	ls /etc/yum.repos.d/
387
+	lightwave.repo
388
+	photon-extras.repo
389
+	photon-iso.repo
390
+	photon-updates.repo
391
+	photon.repo 
392
+
393
+You can list the the repositories by using the tdnf repolist command. Tdnf filters the results with `enabled`, `disabled`, and `all`. Running the command without specifying an argument returns the enabled repositories:  
394
+
395
+	tdnf repolist
396
+	repo id             repo name                               status
397
+	lightwave           VMware Lightwave 1.0(x86_64)            enabled
398
+	photon-updates      VMware Photon Linux 1.0(x86_64)Updates  enabled
399
+	photon-extras       VMware Photon Extras 1.0(x86_64)        enabled
400
+	photon              VMware Photon Linux 1.0(x86_64)         enabled
401
+
402
+The photon-iso.repo, however, does not appear in the list of repositories because it is unavailable on the virtual machine from which these examples are taken. Photon-iso.repo is the default repository; it points to /media/cdrom. The contents of photon-iso.repo look like this: 
403
+
404
+	cat /etc/yum.repos.d/photon-iso.repo
405
+	[photon-iso]
406
+	name=VMWare Photon Linux 1.0(x86_64)
407
+	baseurl=file:///mnt/cdrom/RPMS
408
+	gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY
409
+	gpgcheck=1
410
+	enabled=0
411
+	skip_if_unavailable=True
412
+
413
+The local cache is populated with data from the repository: 
414
+
415
+	ls -l /var/cache/tdnf/photon
416
+	total 8
417
+	drwxr-xr-x 2 root root 4096 May 18 22:52 repodata
418
+	d-wxr----t 3 root root 4096 May  3 22:51 rpms
419
+
420
+You can clear the cache to help troubleshoot a problem, but keep in mind that doing so might slow the performance of tdnf until the cache becomes repopulated with data. Here is how to clear the cache: 
421
+
422
+	tdnf clean all
423
+	Cleaning repos: photon photon-extras photon-updates lightwave
424
+	Cleaning up everything
425
+
426
+The command purges the repository data from the cache: 
427
+
428
+	ls -l /var/cache/tdnf/photon
429
+	total 4
430
+	d-wxr----t 3 root root 4096 May  3 22:51 rpms
431
+
432
+### Options for Commands
433
+
434
+You can add the following options to tdnf commands. If the option to override a configuration is unavailable in a command, consider adding it to the configuration file, /etc/tdnf/tdnf.conf.
435
+
436
+	OPTION 					DESCRIPTION
437
+	--allowerasing 			Allow erasing of installed packages to resolve dependencies
438
+	--assumeno 				Answer no for all questions
439
+	--best 					Try the best available package versions in transactions
440
+	--debugsolver 			Dump data aiding in dependency solver debugging info.
441
+	--disablerepo=<repoid> 	Disable specific repositories by an id or a glob.
442
+	--enablerepo=<repoid> 	Enable specific repositories
443
+	-h, --help 				Display help
444
+	--refresh 				Set metadata as expired before running command
445
+	--nogpgcheck 			Skip gpg check on packages
446
+	--rpmverbosity=<debug level name> 	Debug level for rpm
447
+	--version 				Print version and exit
448
+	-y, --assumeyes 		Answer yes to all questions
449
+
450
+Here is an example that adds the short form of the `assumeyes` option to the install command:
451
+
452
+	tdnf -y install gcc
453
+	Upgrading:
454
+	gcc 	x86_64	5.3.0-1.ph1 	91.35 M
455
+
456
+
457
+### Commands
458
+
459
+**check-local**: This command resolves dependencies by using the local RPMs to help check RPMs for quality assurance before publishing them. To check RPMs with this command, you must create a local directory and place your RPMs in it. The command, which includes no options, takes the path to the local directory containing the RPMs as its argument. The command does not, however, recursively parse directories; it checks the RPMs only in the directory that you specify. For example, after creating a directory named `/tmp/myrpms` and placing your RPMs in it, you can run the following command to check them:  
460
+
461
+	tdnf check-local /tmp/myrpms
462
+	Checking all packages from: /tmp/myrpms
463
+	Found 10 packages
464
+	Check completed without issues
465
+
466
+**check-update**: This command checks for updates to packages. It takes no arguments. The `tdnf list updates` command performs the same function. Here is an example of the `check update` command: 
467
+
468
+	tdnf check-update
469
+	rpm-devel.x86_64 	4.11.2-8.ph1 	photon
470
+	yum.noarch      	3.4.3-3.ph1 	photon
471
+
472
+**clean**: This command cleans up temporary files, data, and metadata. It takes the argument `all`. Example: 
473
+
474
+	tdnf clean all
475
+	Cleaning repos: photon photon-extras photon-updates lightwave
476
+	Cleaning up everything
477
+
478
+**distro-sync**: This command synchronizes the machine's RPMs with the latest version of all the packages in the repository. Abridged example:
479
+
480
+	tdnf distro-sync
481
+
482
+	Upgrading:
483
+	zookeeper                             x86_64        3.4.8-2.ph1               3.38 M
484
+	yum                                   noarch        3.4.3-3.ph1               4.18 M
485
+
486
+	Total installed size: 113.01 M
487
+
488
+	Reinstalling:
489
+	zlib-devel                            x86_64        1.2.8-2.ph1             244.25 k
490
+	zlib                                  x86_64        1.2.8-2.ph1             103.93 k
491
+	yum-metadata-parser                   x86_64        1.1.4-1.ph1              57.10 k
492
+
493
+	Total installed size: 1.75 G
494
+
495
+	Obsoleting:
496
+	tftp                                  x86_64        5.2-3.ph1                32.99 k
497
+
498
+	Total installed size: 32.99 k
499
+	Is this ok [y/N]:
500
+
501
+**downgrade**: This command downgrades the package that you specify as an argument to the next lower package version. Example: 
502
+
503
+	tdnf downgrade boost
504
+	Downgrading:
505
+	boost                                 x86_64        1.56.0-2.ph1              8.20 M
506
+	Total installed size: 8.20 M
507
+	Is this ok [y/N]:y
508
+	Downloading:
509
+	boost                                  2591470    100%
510
+	Testing transaction
511
+	Running transaction
512
+	Complete!
513
+
514
+To downgrade to a version lower than the next one, you must specify it by name, epoch, version, and release, all properly hyphenated. Example: 
515
+
516
+	tdnf downgrade boost-1.56.0-2.ph1 
517
+
518
+**erase**: This command removes the package that you specify as an argument. Example: 
519
+
520
+	tdnf erase vim
521
+	Removing:
522
+	vim                                   x86_64        7.4-4.ph1                 1.94 M
523
+	Total installed size: 1.94 M
524
+	Is this ok [y/N]:
525
+
526
+You can also erase multiple packages: 
527
+
528
+	tdnf erase docker cloud-init
529
+
530
+**info**: This command displays information about packages. It can take the name of a package. Or it can take one of the following arguments: all, available, installed, extras, obsoletes, recent, upgrades. Examples: 
531
+
532
+	tdnf info ruby
533
+	tdnf info obsoletes
534
+	tdnf info upgrades
535
+
536
+**install**: This command takes the name of a package as its argument. It then installs the package and its dependencies. Examples: 
537
+
538
+	tdnf install kubernetes
539
+
540
+You can also install multiple packages: 
541
+
542
+	tdnf install python-curses lsof audit gettext chkconfig ntsysv bindutils 
543
+		 wget gawk irqbalance lvm2 cifs-utils c-ares distrib-compat
544
+	
545
+
546
+**list**: This command lists the packages of the package that you specify as the argument. The command can take one of the following arguments: all, available, installed, extras, obsoletes, recent, upgrades. 
547
+
548
+	tdnf list updates
549
+
550
+The list of packages might be long. To more easily view it, you can concatenate it into a text file, and then open the text file in a text editor: 
551
+
552
+	tdnf list all > pkgs.txt
553
+	vi pkgs.txt
554
+
555
+**makecache**: This command updates the cached binary metadata for all known repositories. Example:
556
+
557
+	tdnf makecache
558
+	Refreshing metadata for: 'VMware Lightwave 1.0(x86_64)'
559
+	Refreshing metadata for: 'VMware Photon Linux 1.0(x86_64)Updates'
560
+	Refreshing metadata for: 'VMware Photon Extras 1.0(x86_64)'
561
+	Refreshing metadata for: 'VMware Photon Linux 1.0(x86_64)'
562
+	Metadata cache created.
563
+
564
+**provides**: This command finds the packages that provide the package that you supply as an argument. Examples: 
565
+
566
+	tdnf provides docker
567
+	docker-1.11.0-1.ph1.x86_64 : Docker
568
+	Repo     : photon
569
+	docker-1.11.0-1.ph1.x86_64 : Docker
570
+	Repo     : @System
571
+
572
+**reinstall**: This command reinstalls the packages that you specify. If some packages are unavailable or not installed, the command fails. Example: 
573
+
574
+	tdnf reinstall docker kubernetes
575
+
576
+	Reinstalling:
577
+	kubernetes                            x86_64        1.1.8-1.ph1             152.95 M
578
+	docker                                x86_64        1.11.0-1.ph1             57.20 M
579
+
580
+	Total installed size: 210.15 M
581
+
582
+**remove**: This command removes a package. When removing a package, tdnf by default also removes dependencies that are no longer used if they were was installed by tdnf as a dependency without being explicitly requested by a user. You can modify the dependency removal by changing the `clean_requirements_on_remove` option in /etc/tdnf/tdnf.conf to `false`. 
583
+
584
+	tdnf remove packagename
585
+
586
+**search**: This command searches for the attributes of packages. The argument can be the names of packages, as this example testifies: 
587
+
588
+	tdnf search docker kubernetes
589
+	docker : Docker
590
+	docker : Docker
591
+	docker-debuginfo : Debug information for package docker
592
+	docker : Docker
593
+	kubernetes : Kubernetes cluster management
594
+	kubernetes : Kubernetes cluster management
595
+	kubernetes-debuginfo : Debug information for package kubernetes
596
+	kubernetes : Kubernetes cluster management
597
+
598
+The argument of the search command can also be a keyword or a combination of keywords and packages: 
599
+
600
+	tdnf search terminal bash
601
+	rubygem-terminal-table : Simple, feature rich ascii table generation library
602
+	ncurses : Libraries for terminal handling of character screens
603
+	mingetty : A minimal getty program for virtual terminals
604
+	ncurses : Libraries for terminal handling of character screens
605
+	ncurses : Libraries for terminal handling of character screens
606
+	bash : Bourne-Again SHell
607
+	bash-lang : Additional language files for bash
608
+	bash-lang : Additional language files for bash
609
+	bash : Bourne-Again SHell
610
+	bash-debuginfo : Debug information for package bash
611
+	bash : Bourne-Again SHell
612
+	bash-lang : Additional language files for bash
613
+
614
+**upgrade**: This command upgrades the package or packages that you specify to an available higher version that tdnf can resolve. If the package is already the latest version, the command returns `Nothing to do`. Example: 
615
+
616
+	tdnf upgrade boost
617
+
618
+	Upgrading:
619
+	boost                                 x86_64        1.60.0-1.ph1              8.11 M
620
+
621
+	Total installed size: 8.11 M
622
+	Is this ok [y/N]:y
623
+
624
+	Downloading:
625
+	boost                                  2785950    100%
626
+	Testing transaction
627
+	Running transaction
628
+
629
+	Complete!
630
+
631
+You can also run the `upgrade` command with the `refresh` option to update the cached metadata with the latest information from the repositories. The following example refreshes the metadata and then checks for a new version of tdnf but does not find one, so tdnf takes no action: 
632
+
633
+	tdnf upgrade tdnf --refresh
634
+	Refreshing metadata for: 'VMware Lightwave 1.0(x86_64)'
635
+	Refreshing metadata for: 'VMware Photon Linux 1.0(x86_64)Updates'
636
+	Refreshing metadata for: 'VMware Photon Extras 1.0(x86_64)'
637
+	Refreshing metadata for: 'VMware Photon Linux 1.0(x86_64)'
638
+	Nothing to do.
639
+
640
+**upgrade-to**: This command upgrades to the version of the package that you specify. Example:
641
+
642
+	tdnf upgrade-to ruby2.3
643
+
644
+The commands and options of tdnf are, at present, a subset of those of dnf. For more help with tdnf commands, see the [DNF documentation](https://media.readthedocs.org/pdf/dnf/latest/dnf.pdf).
645
+
646
+### Adding a New Repository
647
+
648
+With Photon OS, you can add a new repository from which tdnf installs packages. To do so, you create a repository configuration file with a `.repo` extension and place it in /etc/yum.repos.d. The repository can be on either the Internet or a local server containing your in-house applications. 
649
+
650
+Be careful if you add a repository that's on the Internet: Installing packages from untrusted or unverified sources might put the security, stability, or compatibility of your system at risk. It might also make your system harder to maintain.  
651
+
652
+On Photon OS, the existing repositories appear in /etc/yum.repos.d:
653
+
654
+	ls /etc/yum.repos.d/
655
+	lightwave.repo
656
+	photon-extras.repo
657
+	photon-iso.repo
658
+	photon-updates.repo
659
+	photon.repo 
660
+
661
+Looking at one of the `.repo` files reveals the format and information that a new repository configuration file should contain:
662
+
663
+	cat /etc/yum.repos.d/lightwave.repo
664
+	[lightwave]
665
+	name=VMware Lightwave 1.0(x86_64)
666
+	baseurl=https://dl.bintray.com/vmware/lightwave
667
+	gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY
668
+	gpgcheck=1
669
+	enabled=1
670
+	skip_if_unavailable=True
671
+
672
+The minimal information needed to establish a repository is an ID and human-readable name of the repository and its base URL. The ID, which appears in square brackets, must be one word that is unique amoung the system's repositories; in the example above, it is `[lightwave]`.
673
+
674
+The `baseurl` is a URL for the repository's repodata directory. For a repository on a local server that can be accessed directly or mounted as a file system, the base URL can be a file referenced by `file://`. Example:  
675
+
676
+	baseurl=file:///server/repo/
677
+
678
+The `gpgcheck` setting specifies whether to check the GPG signature. The `gpgkey` setting furnishes the URL for the repository's ASCII-armored GPG key file. Tdnf uses the GPG key to verify a package if its key has not been imported into the RPM database.
679
+
680
+The `enabled` setting tells tdnf whether to poll the repository. If `enabled` is set to `1`, tdnf polls it; if it is set to `0`, tdnf ignores it. 
681
+
682
+The `skip_if_unavailable` setting instructs tdnf to continue running if the repository goes offline.
683
+
684
+Other options and variables can appear in the repository file. The variables that go with some of the options can reduce future changes to the repository configuration files. There are variables to replace the value of the version of the package and to replace the base architecture. For more information, see the man page for yum.conf on the full version of Photon OS: `man yum.conf`
685
+
686
+Here is an example of how to add a new repository for a local server that tdnf polls for packages:
687
+
688
+	cat > /etc/yum.repos.d/apps.repo << "EOF"
689
+	[localapps]
690
+	name=Local In-House Applications(x86_64)
691
+	baseurl=file:///appserver/apps
692
+	enabled=1
693
+	skip_if_unavailable=True
694
+	EOF
695
+
696
+Because this new repository resides on a local server, make sure the Photon OS machine can connect to it by, for instance, mounting it. 
697
+
698
+After establishing a new repository, you must run the following command to update the cached binary metadata for the repositories that tdnf polls. Example:
699
+
700
+	tdnf makecache
701
+	Refreshing metadata for: 'VMware Lightwave 1.0(x86_64)'
702
+	Refreshing metadata for: 'VMware Photon Linux 1.0(x86_64)Updates'
703
+	Refreshing metadata for: 'VMware Photon Extras 1.0(x86_64)'
704
+	Refreshing metadata for: 'Local In-House Applications(x86_64)'
705
+	Refreshing metadata for: 'VMware Photon Linux 1.0(x86_64)'
706
+	Metadata cache created.
707
+
708
+## Managing Services with systemd
709
+
710
+Photon OS manages services with systemd. By using systemd, Photon OS adopts a contemporary Linux standard to bootstrap the user space and concurrently start services---an architecture that differs from traditional Linux systems such as SUSE Linux Enterprise Server. 
711
+
712
+A traditional Linux system contains an initialization system called SysVinit. With SLES 11, for instance, SysVinit-style init programs control how the system starts up and shuts down. Init implements system runlevels. A SysVinit runlevel defines a state in which a  process or service runs. 
713
+
714
+In contrast to a SysVinit system, systemd defines no such runlevels. Instead, systemd uses a dependency tree of targets to determine which services to start when. Combined with the declarative nature of systemd commands, systemd targets reduce the amount of code needed to run a command, leaving you with code that is easier to maintain and probably faster to execute. For an overview of systemd, see [systemd System and Service Manager](https://www.freedesktop.org/wiki/Software/systemd/) and the [man page for systemd](https://www.freedesktop.org/software/systemd/man/systemd.html).
715
+
716
+On Photon OS, you should manage services with systemd and its command-line utility for inspecting and controlling the system, `systemctl`, not the deprecated commands of init.d. 
717
+
718
+The following sections present a brief overview of useful systemctl commands and options for examining and managing the state of systemd services. For more information, see the index of all the systemd man pages, including systemctl, at the following URL: 
719
+
720
+[https://www.freedesktop.org/software/systemd/man/](https://www.freedesktop.org/software/systemd/man/)
721
+
722
+### Viewing Services 
723
+
724
+To view a description of all the active, loaded units, execute the systemctl command without any options or arguments: 
725
+
726
+	systemctl
727
+
728
+To see all the loaded, active, and inactive units and their description, run this command: 
729
+
730
+	systemctl --all
731
+
732
+To see all the unit files and their current status but no description, run this command: 
733
+
734
+	systemctl list-unit-files
735
+
736
+The `grep` command filters the services by a search term, a helpful tactic to recall the exact name of a unit file without looking through a long list of names. Example: 
737
+
738
+	systemctl list-unit-files | grep network
739
+	org.freedesktop.network1.busname           static
740
+	dbus-org.freedesktop.network1.service      enabled
741
+	systemd-networkd-wait-online.service       enabled
742
+	systemd-networkd.service                   enabled
743
+	systemd-networkd.socket                    enabled
744
+	network-online.target                      static
745
+	network-pre.target                         static
746
+	network.target                             static
747
+
748
+### Controlling Services
749
+
750
+To control services on Photon OS, you use systemctl. For example, instead of running the /etc/init.d/ssh script to stop and start the OpenSSH server on a init.d-based Linux system, you run the following systemctl commands on Photon OS: 
751
+
752
+	systemctl stop sshd
753
+	systemctl start sshd
754
+
755
+The systemctl tool includes a range of commands and options for inspecting and controlling the state of systemd and the service manager; for more information, see the [systemctl man page](https://www.freedesktop.org/software/systemd/man/systemctl.html).
756
+
757
+### Creating a Startup Service
758
+
759
+This section shows you how to create a systemd startup service that changes the maximum transmission unit, or MTU, of the default Ethernet connection, eth0.
760
+
761
+First, concatenate the following block of code into a file: 
762
+	
763
+	cat << EOF >> /lib/systemd/system/eth0.service
764
+	[Unit]
765
+	Description=Network interface initialization
766
+	After=local-fs.target network-online.target network.target
767
+	Wants=local-fs.target network-online.target network.target
768
+
769
+	[Service]
770
+	ExecStart=/bin/ifconfig eth0 mtu 1460 up
771
+	Type=oneshot
772
+
773
+	[Install]
774
+	WantedBy=multi-user.target
775
+	EOF
776
+
777
+Second, set the service to auto-start when the system boots: 
778
+
779
+	cd /lib/systemd/system/multi-user.target.wants/
780
+	ln -s ../eth0.service eth0.service
781
+
782
+### Disabling the Photon OS httpd.service 
783
+
784
+If your application or appliance includes its own HTTP server, you should turn off and disable the HTTP server that comes with Photon OS so that it does not conflict with your own HTTP server. 
785
+
786
+To support the option to run RPM-OSTree, the full version of Photon OS runs the <code>httpd.service</code> by default. To stop it and disable it, run the following commands as root: 
787
+
788
+	systemctl stop httpd.service
789
+	systemctl disable httpd.service
790
+
791
+### Auditing System Events with auditd
792
+
793
+Because Photon OS emphasizes security, the Linux auditing service, auditd, is enabled and active by default on the full version of Photon OS: 
794
+
795
+	systemctl status auditd
796
+	* auditd.service - Security Auditing Service
797
+	   Loaded: loaded (/usr/lib/systemd/system/auditd.service; enabled; vendor preset: enabled)
798
+	   Active: active (running) since Fri 2016-04-29 15:08:50 UTC; 1 months 9 days ago
799
+	 Main PID: 250 (auditd)
800
+	   CGroup: /system.slice/auditd.service
801
+	           `-250 /sbin/auditd -n
802
+
803
+To help improve security, the auditd service can monitor file changes, system calls, executed commands, authentication events, and network access. After you implement an audit rule to monitor an event, the `aureport` tool generates reports to display information about the events. 
804
+
805
+You can, for instance, use the auditctl utility to set a rule that monitors the sudoers file for changes:
806
+
807
+	auditctl -w /etc/sudoers -p wa -k sudoers_changes
808
+
809
+This rule specifies that the auditd service watch (`-w`) the /etc/sudoers file to log permissions changes (`p`) to the write access (`w`) or attributes (`a`) of the file and to identify them in logs as `sudoers_changes`. The auditing logs appear in /var/log/audit/audit.log. You can list the auditing rules like this: 
810
+
811
+	auditctl -l
812
+	-w /etc/sudoers -p wa -k sudoers_changes
813
+
814
+For more information on the Linux Audit Daemon, see its man page on Photon OS: 
815
+
816
+	man auditd
817
+
818
+For more information on setting auditing rules and options with auditctl, see its man page:
819
+
820
+	man auditctl
821
+
822
+For more information on viewing reports on audited events, see the aureport man page:
823
+
824
+	man aureport
825
+
826
+### Analyzing systemd Logs with journalctl
827
+
828
+The journalctl tool queries the contents of the systemd journal. For help troubleshooting systemd, two journalctl queries are particularly useful: showing the log entries for the last boot and showing the log entries for a systemd service unit. 
829
+
830
+This command displays the messages that systemd generated during the last time the machine started: 
831
+
832
+	journalctl -b
833
+
834
+This command reveals the messages for only the systemd service unit specified by the `-u` option, which is auditd in the following example: 
835
+
836
+	journalctl -u auditd
837
+
838
+For more information, see the journalctl man page: `man journalctl`
839
+
840
+### Migrating Scripts to systemd
841
+
842
+Although systemd maintains compatibility with init.d scripts, you should, as a best practice, adapt the scripts that you want to run on Photon OS to systemd to avoid potential problems. Such a conversion standardizes the scripts, reduces the footprint of your code, makes the scripts easier to read and maintain, and improves their robustness on a systemd system.
843
+
844
+## Managing the Network Configuration
845
+
846
+The network service, which is enabled by default, starts when the system boots. You manage the network service by using systemd commands, such as systemd-networkd, systemd-resolvd, and networkctl. You can check its status of the network service by running the following command: 
847
+
848
+	systemctl status systemd-networkd
849
+
850
+Here is a healthy result of the command: 
851
+
852
+	* systemd-networkd.service - Network Service
853
+	   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
854
+	   Active: active (running) since Fri 2016-04-29 15:08:51 UTC; 6 days ago
855
+	     Docs: man:systemd-networkd.service(8)
856
+	 Main PID: 291 (systemd-network)
857
+	   Status: "Processing requests..."
858
+	   CGroup: /system.slice/systemd-networkd.service
859
+	           `-291 /lib/systemd/systemd-networkd
860
+
861
+Because Photon OS relies on systemd to manage services, you should employ the systemd suite of commands, not deprecated init.d commands or other deprecated commands, to manage networking. 
862
+
863
+### Use `ip` and `ss` Commands Instead of `ifconfig` and `netstat`
864
+
865
+Although the `ifconfig` command and the `netstat` command work on Photon OS, VMware recommends that you use the `ip` or `ss` commands. The `ipconfig` and `netstat` commands are deprecated. 
866
+
867
+For example, instead of running `netstat` to display a list of network interfaces, run the `ss` command. Similarly, to display information for IP addresses, instead of running `ifconfig -a`, run the `ip addr` command. Examples:
868
+
869
+	USE THIS IPROUTE COMMAND 	INSTEAD OF THIS NET-TOOL COMMAND
870
+	ip addr 					ifconfig -a
871
+	ss 							netstat
872
+	ip route 					route
873
+	ip maddr 					netstat -g
874
+	ip link set eth0 up 		ifconfig eth0 up
875
+	ip -s neigh					arp -v
876
+	ip link set eth0 mtu 9000	ifconfig eth0 mtu 9000
877
+
878
+Using the `ip route` version of a command instead of the net-tools version often provides more complete, accurate information on Photon OS, as the following example demonstrates: 
879
+
880
+	ip neigh
881
+	192.168.137.2 dev eth0 lladdr 00:50:56:e2:02:0f STALE
882
+	192.168.137.254 dev eth0 lladdr 00:50:56:e7:13:d9 STALE
883
+	192.168.137.1 dev eth0 lladdr 00:50:56:c0:00:08 DELAY
884
+
885
+	arp -a
886
+	? (192.168.137.2) at 00:50:56:e2:02:0f [ether] on eth0
887
+	? (192.168.137.254) at 00:50:56:e7:13:d9 [ether] on eth0
888
+	? (192.168.137.1) at 00:50:56:c0:00:08 [ether] on eth0
889
+
890
+### Configuring Network Interfaces
891
+
892
+Network configuration files for systemd-networkd reside in /etc/systemd/network and /usr/lib/systemd/network. Example:
893
+
894
+	root@photon-rc [ ~ ]# ls /etc/systemd/network/
895
+	10-dhcp-en.network
896
+
897
+By default, when Photon OS starts, it creates a DHCP network configuration file, or rule, which appears in /etc/systemd/network, the highest priority directory for network configuration files:
898
+
899
+	cat /etc/systemd/network/10-dhcp-en.network
900
+	[Match]
901
+	Name=e*
902
+
903
+	[Network]
904
+	DHCP=yes
905
+
906
+Network configuration files can also appear in the system network directory, /usr/lib/systemd/network, as the results of the following search illustrate:
907
+
908
+	root@photon-rc [ ~ ]# updatedb
909
+	root@photon-rc [ ~ ]# locate systemd/network
910
+	/etc/systemd/network
911
+	/etc/systemd/network/10-dhcp-en.network
912
+	/usr/lib/systemd/network
913
+	/usr/lib/systemd/network/80-container-host0.network
914
+	/usr/lib/systemd/network/80-container-ve.network
915
+	/usr/lib/systemd/network/99-default.link
916
+	root@photon-rc [ ~ ]#
917
+
918
+As you can see, the /usr/lib/systemd/network directory contains several network configuration files. Photon OS applies the configuration files in the [lexicographical order](https://en.wikipedia.org/wiki/Lexicographical_order) specified by the file names without regard for the network configuration directory in which the file resides unless the file name is the same. Photon OS processes files with identical names by giving precedence to files in the /etc directory over the other directory. Thus, the settings in /etc/systemd/network override those in /usr/lib/systemd/network. Once Photon OS matches an interface in a file, Photon OS ignores the interface if it appears in files processed later in the lexicographical order. 
919
+
920
+Each .network file contains a matching rule and a configuration that Photon OS applies when a device matches the rule. You set the matching rule and the configuration as sections containing vertical sets of key-value pairs according to the information at https://www.freedesktop.org/software/systemd/man/systemd.network.html. 
921
+
922
+To configure Photon OS to handle a networking use case, such as setting a static IP address or adding a name server, you create a configuration file with a `.network` extension and place it in the /etc/systemd/network directory. For Photon OS to apply the new configuration, you must restart the `systemd-networkd` service by running the following command: 
923
+
924
+	systemctl restart systemd-networkd
925
+
926
+For information about network configuration files, their processing order, and their matching rules, sections, and keys, see https://www.freedesktop.org/software/systemd/man/systemd.network.html.
927
+
928
+For information about creating virtual network device files (`.netdev`), see https://www.freedesktop.org/software/systemd/man/systemd.netdev.html.
929
+
930
+### Setting a Static IP Address
931
+
932
+Before you set a static IP address, obtain the name of your Ethernet link by running the following command: 
933
+
934
+	networkctl
935
+	IDX LINK             TYPE               OPERATIONAL SETUP
936
+	  1 lo               loopback           carrier     unmanaged
937
+	  2 eth0             ether              routable    configured
938
+
939
+In the results of the command, you can see the name of an Ethernet link, `eth0`.
940
+
941
+To create a network configuration file that systemd-networkd uses to establish a static IP address for the eth0 network interface, execute the following command as root: 
942
+
943
+	cat > /etc/systemd/network/10-static-en.network << "EOF"
944
+
945
+	[Match]
946
+	Name=eth0
947
+
948
+	[Network]
949
+	Address=192.168.0.2/24
950
+	Gateway=192.168.0.1
951
+	EOF
952
+
953
+Apply the configuration by running the following command:
954
+
955
+	systemctl restart systemd-networkd
956
+
957
+For more information, see the man page for systemd-networkd: `man systemd.network`
958
+
959
+### Turning Off DHCP
960
+
961
+By default, when Photon OS first starts, it creates a DHCP network configuration file, or rule, which appears in /etc/systemd/network, the highest priority directory for network configuration files:
962
+
963
+	cat /etc/systemd/network/10-dhcp-en.network
964
+	[Match]
965
+	Name=e*
966
+
967
+	[Network]
968
+	DHCP=yes
969
+
970
+To turn off DHCP for all Ethernet interfaces, change the value of `DHCP` from `yes` to `no`, save the changes, and then restart the `systemd-networkd` service: 
971
+
972
+	systemctl restart systemd-networkd
973
+
974
+### Adding a DNS Server 
975
+
976
+Photon OS resolves domain names, IP addresses, and network names for local applications by using systemd-resolved. The systemd-resolved daemon automatically creates and maintains the /etc/resolv.conf file, into which systemd-resolved places the IP address of the DNS server. You should therefore never modify the /etc/resolv.conf file.
977
+
978
+(If you want to implement a local resolver like bind instead of systemd-resolved, stop the systemd-resolved service and disable it.)
979
+
980
+If you open the default /etc/resolv.conf file after you deploy Photon OS, it looks like this: 
981
+
982
+	root@photon-rc [ ~ ]# cat /etc/resolv.conf
983
+	# This file is managed by systemd-resolved(8). Do not edit.
984
+	#
985
+	# Third party programs must not access this file directly, but
986
+	# only through the symlink at /etc/resolv.conf. To manage
987
+	# resolv.conf(5) in a different way, replace the symlink by a
988
+	# static file or a different symlink.
989
+
990
+	nameserver 192.168.137.2
991
+
992
+To add a DNS server to your static network configuration file, insert a DNS key into the Network section of, in this example, /etc/systemd/network/10-eth0-static.network and set it to the IP address of your DNS server: 
993
+
994
+	[Match]
995
+	Name=e*
996
+
997
+	[Network]
998
+	Address=192.168.0.2/24
999
+	Gateway=192.168.0.1
1000
+	DNS=192.168.0.1
1001
+
1002
+Another way of adding a DNS server is to modify /etc/systemd/resolved.conf --- a method that can be particularly useful when your machine is working with DHCP. For more information, see https://www.freedesktop.org/software/systemd/man/resolved.conf.html.
1003
+
1004
+You can optionally activate the local DNS stub resolver of systemd-resolved by adding `dns` and `resolve` to /etc/nsswitch.conf. To do so, make a backup copy of /etc/nsswitch.conf and then execute the following command as root:
1005
+
1006
+	sed -i 's/^hosts.*$/hosts: files resolve dns/' /etc/nsswitch.conf
1007
+
1008
+For more information on the systemd-resolved service, see https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html.
1009
+
1010
+
1011
+### Setting Up Networking for Multiple NICs
1012
+
1013
+If your machine contains multiple NICs, you should, as a best practice, create a .network configuration file for each network interface. The following scenario demonstrates how to set one wired network interface to use a static IP address and another wired network interface to use a dynamic IP address obtained through DHCP. Keep in mind that the following configurations are examples: You must change the IP addresses and other information to match your network and requirements.  
1014
+
1015
+First, create the .network file for the static Ethernet connection in /etc/systemd/network. A best practice is to match the exact name of the network interface, which is in this example eth0. This example file also includes a DNS server for the static IP address. As a result, the configuration sets the UseDNS key to false in the DHCP column so that Photon OS ignores the DHCP server for DNS for this interface.  
1016
+
1017
+	cat > /etc/systemd/network/10-eth0-static-en.network << "EOF"
1018
+	[Match]
1019
+	Name=eth0
1020
+
1021
+	[Network]
1022
+	Address=10.137.20.11/19
1023
+	Gateway=10.137.23.253
1024
+	DNS=10.132.71.1
1025
+
1026
+	[DHCP]
1027
+	UseDNS=false
1028
+	EOF
1029
+
1030
+Second, create the .network file for the second network interface, which is named eth1 in this example. This configuration file sets the eth1 interface to an IP address from DHCP and sets DHCP as the source for DNS lookups. Setting the DHCP key to `yes` acquires an IP address for IPv4 and IPv6. To acquire an IP address for IPv4 only, set the DHCP key to <code>ipv4</code>.
1031
+
1032
+	cat > /etc/systemd/network/50-eth1-dhcp-en.network << "EOF"
1033
+
1034
+	[Match]
1035
+	Name=eth1
1036
+
1037
+	[Network]
1038
+	DHCP=yes  
1039
+
1040
+	[DHCP]
1041
+	UseDNS=true
1042
+	EOF
1043
+
1044
+### Combining DHCP and Static IP Addresses with IPv4 and IPv6 
1045
+
1046
+This section presents examples that demonstrate how to combine DHCP and static IP addresses with both IPv4 and IPv6. 
1047
+
1048
+Here's how to use DHCP to allocate both IPv4 and IPv6 addresses:
1049
+
1050
+	[Network]
1051
+	DHCP=yes
1052
+
1053
+Here's how to use DHCP to allocate only IPv4 addresses:
1054
+
1055
+	[Network]
1056
+	DHCP=ipv4
1057
+
1058
+Here's how to use DHCP to allocate only IPv6 addresses:
1059
+
1060
+	[Network]
1061
+	DHCP=ipv6
1062
+
1063
+Here's how to use DHCP for IPv4 addresses and static IP addresses for IPv6 addresses: 
1064
+
1065
+	[Network]
1066
+	DHCP=ipv4
1067
+	Address=fd00::1/48
1068
+	Gateway=fd00::252
1069
+
1070
+Here's how to use DHCP for IPv6 addresses and static IP addresses for IPv4: 
1071
+
1072
+	[Network]
1073
+	DHCP=ipv6
1074
+	Address=10.10.10.1/24
1075
+	Gateway=10.10.10.253
1076
+
1077
+Here's how to use static IP addresses for both IPv4 and IPv6: 
1078
+
1079
+	[Network]
1080
+	DHCP=ipv6
1081
+	Address=10.10.10.1/24
1082
+	Gateway=10.10.10.253
1083
+	Address=fd00::1/48
1084
+	Gateway=fd00::252
1085
+
1086
+### Inspecting the Status of Network Links with `networkctl`
1087
+
1088
+The `networkctl` command shows information about network connections that helps you configure networking services and troubleshoot networking problems. You can, for example, progressively add options and arguments to the `networkctl` command to move from general information about network connections to specific information about a network connection. 
1089
+
1090
+Running `networkctl` without options defaults to the list command:  
1091
+
1092
+	networkctl
1093
+	IDX LINK             TYPE               OPERATIONAL SETUP
1094
+	  1 lo               loopback           carrier     unmanaged
1095
+	  2 eth0             ether              routable    configured
1096
+	  3 docker0          ether              routable    unmanaged
1097
+	 11 vethb0aa7a6      ether              degraded    unmanaged
1098
+	 4 links listed.
1099
+
1100
+Running `networkctl` with the status command displays information that looks like this; you can see that there are active network links with IP addresses for not only the Ethernet connection but also a Docker container. 
1101
+
1102
+	root@photon-rc [ ~ ]# networkctl status
1103
+	*      State: routable
1104
+	     Address: 192.168.137.131 on eth0
1105
+	              172.17.0.1 on docker0
1106
+	              fe80::20c:29ff:fe55:3ca6 on eth0
1107
+	              fe80::42:f0ff:fef7:bd81 on docker0
1108
+	              fe80::4c84:caff:fe76:a23f on vethb0aa7a6
1109
+	     Gateway: 192.168.137.2 on eth0
1110
+	         DNS: 192.168.137.2
1111
+
1112
+You can then add a network link, such as the Ethernet connection, as the argument of the status command to show specific information about the link: 
1113
+
1114
+	root@photon-rc [ ~ ]# networkctl status eth0
1115
+	* 2: eth0
1116
+	       Link File: /usr/lib/systemd/network/99-default.link
1117
+	    Network File: /etc/systemd/network/10-dhcp-en.network
1118
+	            Type: ether
1119
+	           State: routable (configured)
1120
+	            Path: pci-0000:02:01.0
1121
+	          Driver: e1000
1122
+	      HW Address: 00:0c:29:55:3c:a6 (VMware, Inc.)
1123
+	             MTU: 1500
1124
+	         Address: 192.168.137.131
1125
+	                  fe80::20c:29ff:fe55:3ca6
1126
+	         Gateway: 192.168.137.2
1127
+	             DNS: 192.168.137.2
1128
+	        CLIENTID: ffb6220feb00020000ab116724f520a0a77337
1129
+
1130
+And you can do the same thing with the Docker container: 
1131
+
1132
+	networkctl status docker0
1133
+	* 3: docker0
1134
+	       Link File: /usr/lib/systemd/network/99-default.link
1135
+	    Network File: n/a
1136
+	            Type: ether
1137
+	           State: routable (unmanaged)
1138
+	          Driver: bridge
1139
+	      HW Address: 02:42:f0:f7:bd:81
1140
+	             MTU: 1500
1141
+	         Address: 172.17.0.1
1142
+	                  fe80::42:f0ff:fef7:bd81
1143
+
1144
+In the example above, it is OK that the state of the Docker container is unmanaged; Docker handles managing the networking for the containers without using systemd-resolved or systemd-networkd. Instead, Docker manages the container's connection by using its bridge drive.
1145
+
1146
+For more information about `networkctl` commands and options, see https://www.freedesktop.org/software/systemd/man/networkctl.html.
1147
+
1148
+### Turning on Network Debugging
1149
+
1150
+You can set `systemd-networkd` to work in debug mode so that you can analyze log files with debugging information to help troubleshoot networking problems. The following procedure turns on network debugging by adding a drop-in file in /etc/systemd to customize the default systemd configuration in /usr/lib/systemd. 
1151
+
1152
+First, run the following command as root to create a directory with this exact name, including the `.d` extension:
1153
+
1154
+	mkdir -p /etc/systemd/system/systemd-networkd.service.d/
1155
+
1156
+Second, run the following command as root to establish a systemd drop-in unit with a debugging configuration for the network service:
1157
+
1158
+	cat > /etc/systemd/system/systemd-networkd.service.d/10-loglevel-debug.conf << "EOF"
1159
+	[Service]
1160
+	Environment=SYSTEMD_LOG_LEVEL=debug
1161
+	EOF
1162
+ 
1163
+You must reload the systemctl daemon and restart the systemd-networkd service for the changes to take effect: 
1164
+
1165
+	systemctl daemon-reload
1166
+	systemctl restart systemd-networkd
1167
+
1168
+Verify that your changes took effect:
1169
+
1170
+	systemd-delta --type=extended
1171
+
1172
+View the log files by running this command: 
1173
+
1174
+	journalctl -u systemd-networkd
1175
+
1176
+When you are finished debugging the network connections, turn debugging off by deleting the drop-in file: 
1177
+
1178
+	rm /etc/systemd/system/systemd-networkd.service.d/10-loglevel-debug.conf
1179
+
1180
+### Mounting a Network File System
1181
+
1182
+To mount a network file system, Photon OS requires nfs-utils. The nfs-utils package contains the daemon, userspace server, and client tools for the kernel Network File System, or NFS. The tools include mount.nfs, umount.nfs, and showmount. 
1183
+
1184
+The nfs-utils package is installed by default in the full version of Photon OS but not in the minimal version. To install nfs-utils in the minimal version, run the following command as root: 
1185
+
1186
+	tdnf install nfs-utils
1187
+
1188
+For instructions on how to use nfs-utils to share files over a network, see [Photon OS nfs-utils](https://github.com/vmware/photon/blob/master/docs/nfs-utils.md).
1189
+
1190
+### Installing the Packages for tcpdump and netcat with tdnf
1191
+
1192
+The minimal version of Photon OS leaves out several useful networking tools to keep the operating system lean. Tcpdump, for example, is absent in the minimal version but available in the repository. The minimal version does, however, include the iproute2 tools by default. 
1193
+
1194
+Tcpdump captures and analyzes packets on a network interface. On Photon OS, you install tcpdump and its accompanying package libpcap, a C/C++ library for capturing network traffic, by using tdnf, Photon's command-line package manager: 
1195
+
1196
+	tdnf install tcpdump
1197
+
1198
+Netcat, a tool for sending data over network connections with TCP or UDP, appears in neither the minimal nor the full version of Photon OS. But since netcat furnishes powerful options for analyzing, troubleshooting, and debugging network connections, you might want to install it. To do so, run the following command: 
1199
+
1200
+	tdnf install netcat
1201
+
1202
+## Cloud-Init on Photon OS
1203
+
1204
+The minimal and full versions of Photon OS include the cloud-init service as a built-in component. Cloud-init is a set of Python scripts that initialize cloud instances of Linux machines. The cloud-init scripts configure SSH keys and run commands to customize the machine without user interaction. The commands can set the root password, create a hostname, configure networking, write files to disk, upgrade packages, run custom scripts, and restart the system. 
1205
+
1206
+There are several ways in which you can deploy Photon OS with cloud-init, including the following: 
1207
+
1208
+* As a stand-alone Photon machine
1209
+* In Amazon Elastic Compute Cloud, called EC2
1210
+* In the Google cloud through the Google Compute Engine, or GCE
1211
+* In a VMware Vsphere private cloud 
1212
+
1213
+When a cloud instance of Photon OS starts, cloud-init requires a data source. The data source can be an EC2 file for Amazon's cloud platform, a seed.iso for a stand-alone instance of Photon OS, or the internal capabilities of a system for managing virtual machines, such as VMware vSphere or vCenter. Cloud-init also includes data sources for OpenStack, Apache CloudStack, and OVF. The data source comprises two parts: 
1214
+
1215
+1. Metadata
1216
+2. User data
1217
+
1218
+The metadata gives the cloud service provider instructions on how to implement the Photon OS machine in the cloud infrastructure. Metadata typically includes the instance ID and the local host name. 
1219
+
1220
+The user data contains the commands and scripts that Photon OS executes when it starts in the cloud. The user data commonly takes the form of a shell script or a YAML file containing a cloud configuration. The [cloud-init documentation](https://launchpad.net/cloud-init and https://cloudinit.readthedocs.org/en/latest/) contains information about the types of data sources and the formats for metadata and user data. 
1221
+
1222
+On Photon OS, cloud-init is enabled and running by default. You can check its status like this: 
1223
+
1224
+	systemctl status cloud-init 
1225
+
1226
+The Photon OS directory that contains the local data and other resources for cloud-init is here: 
1227
+
1228
+	/var/lib/cloud
1229
+
1230
+Photon OS stores the logs for cloud-init in the following file:
1231
+
1232
+	/var/log/cloud-init.log
1233
+
1234
+The following sections demonstrate how to use cloud-init to customize a stand-alone Photon OS machine, instantiate a Photon OS machine in the Amazon EC2 cloud, and deploy a virtual machine running Photon OS in vSphere. Each section uses a different combination of the available options for the metadata and the user data that make up the data source. Specifications, additional options, and examples appear in the cloud-init documentation. 
1235
+
1236
+### Creating a Stand-Alone Photon Machine with cloud-init
1237
+
1238
+Cloud-init can customize a Photon OS virtual machine by using the `nocloud` data source. The nocloud data source bundles the cloud-init metadata and user data into a ISO that acts as a seed when you boot the machine. This seed.iso delivers the metadata and the user data without requiring a network connection. 
1239
+
1240
+Here's how customize a Photon OS VM with a nocloud data source:
1241
+
1242
+First, create the metadata file with the following lines in the [YAML](http://www.yaml.org/start.html) format and name it `meta-data`:
1243
+
1244
+	instance-id: iid-local01
1245
+	local-hostname: cloudimg
1246
+
1247
+Second, create the user data file with the following lines in YAML and name it user-data:
1248
+
1249
+	#cloud-config
1250
+	hostname: testhost
1251
+	packages:
1252
+	 - vim
1253
+
1254
+Third, generate the ISO that will serve as the seed; the ISO must have the volume ID set to `cidata`. In this example, the ISO is generated on an Ubuntu 14.04 computer containing the files named `meta-data` and `user-data` in the local directory: 
1255
+
1256
+	genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
1257
+
1258
+The ISO now appears in the current directory: 
1259
+
1260
+	steve@ubuntu:~$ ls
1261
+	meta-data seed.iso user-data
1262
+
1263
+Optionally, you can check the ISO that you generated on Ubuntu by transferring the ISO to the root directory of your Photon OS machine and then running the following command: 
1264
+
1265
+	cloud-init --file seed.iso --debug init
1266
+
1267
+After running the cloud-init command above, check the cloud-init log file: 
1268
+
1269
+	more /var/log/cloud-init.log
1270
+
1271
+Finally, attach the ISO to the Photon OS virtual machine as a CD-ROM and reboot it so that the changes specified by seed.iso take effect. In this case, cloud-init sets the hostname and adds the vim package.
1272
+
1273
+### Customizing a Photon OS Machine on EC2
1274
+
1275
+This section shows you how to upload an `ami` image of Photon OS to Amazon Elastic Compute Cloud, or EC2, and customize the Photon OS machine by using cloud-init with an EC2 data source. The ami version of Photon OS is available as a free download on Bintray:
1276
+
1277
+	https://bintray.com/vmware/photon/
1278
+
1279
+The cloud-init service is commonly used on EC2 to configure the cloud instance of a Linux image. On EC2, for example, cloud-init typically sets the `.ssh/authorized_keys` file to let you log in with a private key. The cloud-config user-data file that appears in the following example contains abridged SSH authorized keys to show you how to set them for an instance of Photon OS in the Amazon cloud. 
1280
+
1281
+Working with EC2 requires Amazon accounts for both AWS and EC2 with valid payment information. If you execute the following examples, you will be charged by Amazon. You will need to replace the placeholders for access keys and other account information in the examples with your account information. 
1282
+
1283
+The following code assumes you have installed and set up the Amazon AWS CLI and the EC2 CLI tools. See [Installing the AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) and [Setting Up the Amazon EC2 Command Line Interface Tools on Linux](http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/set-up-ec2-cli-linux.html).  
1284
+
1285
+	$ mkdir bundled
1286
+	$ tar -zxvf ./photon-ami.tar.gz 
1287
+	$ ec2-bundle-image -c ec2-cert.pem -k ec2-pk.pem -u <EC2 account id>  --arch x86_64 --image photon-ami.raw --destination ./bundled/
1288
+	$ aws s3 mb s3://<bucket-name>
1289
+	$ ec2-upload-bundle --manifest ./bundled/photon-ami.manifest.xml --bucket <bucket-name> --access-key <Account Access Key> --secret-key <Account Secret key>
1290
+	$ ec2-register <bucket-name>/photon-ami.manifest.xml --name photon-ami --architecture x86_64 --virtualization-type hvm
1291
+
1292
+In the following command, the `--user-data-file` option instructs cloud-init to import the cloud-config data in `user-data.txt`. The next command assumes you have created the keypair aws.pem and the group ami-validation as well as uploaded the user-data.txt file to the right place in the Amazon cloud; see the EC2 documentation.
1293
+
1294
+	$ ec2-run-instances $AMI_ID -t m3.medium -k aws -g ami-validation --user-data-file user-data.txt
1295
+	$ ec2-describe-instances
1296
+	$ aws ec2 describe-instances --instance-ids "+instance_id+" --query \"Reservations[*].Instances[*].PublicIpAddress\" --output=text
1297
+	$ ec2-describe-images
1298
+
1299
+**Important**: When you are done, run the following commands to terminate the machine. Because Amazon charges you while the host is running, make sure to shut it down, replacing the example instance ID in the second command with the ID of your instance:  
1300
+
1301
+	$ ec2-deregister ami-18956278
1302
+	$ ec2-terminate-instances i-0920384095842eccf
1303
+
1304
+Here is the contents of the user-data.txt file that cloud-init applies to the machine the first time that it boots up in the cloud: 
1305
+
1306
+	/#cloud-config
1307
+	hostname: photon-on-01
1308
+	groups:
1309
+	 - cloud-admins
1310
+	 - cloud-users
1311
+	users:
1312
+	 - default
1313
+	 - name: photonadmin
1314
+	   gecos: photon test admin user 
1315
+	   primary-group: cloud-admins
1316
+	   groups: cloud-users
1317
+	   lock-passwd: false
1318
+	   passwd: vmware 
1319
+	 - name: photonuser
1320
+	   gecos: photon test user
1321
+	   primary-group: cloud-users
1322
+	   groups: users
1323
+	   passwd: vmware
1324
+	packages:
1325
+	 - vim
1326
+	ssh_authorized_keys:
1327
+	 - ssh-rsa MIIEogIBAAKCAQEAuvHKAjBhpwuomcUTpIzJWRJAe71JyBgAWrwqyN1Mk5N+c9X5
1328
+	Ru2fazFA7WxQSD1KyTEvcuf8JzdBfrEJ0v3/nT2x63pvJ8fCl6HRkZtHo8zRu8vY
1329
+	KYTZS/sdvM/ruubHfq1ldRpgtYSqbkykoe6PCQIDAQABAoIBAEgveQtjVzHDhLTr
1330
+	rmwJmO316ERfkQ/chLaElhi9qwYJG/jqlNIISWFyztqD1b3fxU6m5MOBIujh7Xpg
1331
+	... ec3test@example.com
1332
+
1333
+Now check the cloud-init output log file on EC2 at `/var/log/cloud-init-output.log`. 
1334
+
1335
+For more information on using cloud-init user data on EC2, see [Running Commands on Your Linux Instance at Launch](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html).
1336
+
1337
+With Photon OS, you can also build cloud images on Google Compute Engine and other cloud providers; for more information, see [Compatible Cloud Images](https://github.com/vmware/photon/blob/master/docs/cloud-images.md).
1338
+
1339
+### Running a Photon OS Machine on GCE
1340
+
1341
+Photon OS comes in a preconfigured image ready for Google Cloud Engine. This section demonstrates how to create a Photon OS instance on Google Cloud Engine with and without cloud-init user data.
1342
+
1343
+This section assumes that you have set up a GCE account and, if you try the examples, are ready to pay Google for its cloud services. The GCE-ready version of Photon OS, however, comes for free. It is, in the parlance of Google cloud services, a private image. You can freely download it without registration from Bintray: 
1344
+
1345
+	https://bintray.com/vmware/photon/gce/view
1346
+
1347
+The GCE-ready image of Photon OS contains packages and scripts that prepare it for the Google cloud to save you time as you implement a compute cluster or develop cloud applications. The GCE-ready version of Photon OS adds the following packages to the [packages installed with the minimal version](https://github.com/vmware/photon/blob/master/common/data/packages_minimal.json): 
1348
+
1349
+	sudo, tar, which, google-daemon, google-startup-scripts, 
1350
+	kubernetes, perl-DBD-SQLite, perl-DBIx-Simple, perl, ntp
1351
+
1352
+In addition to a GCE account, the following examples require the gcloud command-line tool; see [https://cloud.google.com/compute/docs/gcloud-compute](https://cloud.google.com/compute/docs/gcloud-compute).
1353
+
1354
+Here are the commands to create an instance of Photon OS from the Photon GCE image without using cloud-init. In the following commands, you must replace `<bucket-name>` with the name of your bucket. You also need to replace the path to the Photon GCE tar file. 
1355
+
1356
+	$ gcloud compute instances list
1357
+	$ gcloud compute images list
1358
+	$ gcloud config list
1359
+	$ gsutil mb gs://<bucket-name>
1360
+	$ gsutil cp <path-to-photon-gce-image.tar.gz> gs://<bucket-name>/photon-gce.tar.gz
1361
+	$ gcloud compute images create photon-gce-image --source-uri gs://<bucket-name>/photon-gce.tar.gz 
1362
+	$ gcloud compute instances create photon-gce-vm --machine-type "n1-standard-1" --image photon-gce-image
1363
+	$ gcloud compute instances describe photon-gce-vm
1364
+	 
1365
+
1366
+Now, to create a new instance of a Photon OS machine and configure it with a cloud-init user data file, replace the `gcloud compute instances create` command in the example above with the following command. Before running this command, you must upload your user-data file to Google's cloud infrastructure and replace `<path-to-userdata-file>` with its path and file name. 
1367
+
1368
+	gcloud compute instances create photon-gce-vm --machine-type "n1-standard-1" --image photon-gce-vm --metadata-from-file=user-data=<path-to-userdata-file>
1369
+
1370
+You can also add a cloud-init user-data file to an existing instance of a Photon OS machine on GCE: 
1371
+
1372
+	gcloud compute instances add-metadata photon-gce-vm --metadata-from-file=user-data=<path-to-userdata-file>
1373
+
1374
+## Docker Containers
1375
+
1376
+Photon OS includes the open source version of Docker. With Docker, Photon OS becomes a Linux run-time host for containers---that is, a Linux cloud container. A container is a process that runs on the Photon OS host with its own isolated application, file system, and networking.
1377
+
1378
+On Photon OS, the Docker daemon is enabled by default. To view the status of the daemon, run this command: 
1379
+
1380
+	systemctl status docker
1381
+
1382
+Docker is loaded and running by default on the full version of Photon OS. On the minimal version, it is loaded but not running by default, so you have to start it: 
1383
+
1384
+	systemctl start docker
1385
+
1386
+To obtain information about Docker, run this command as root: 
1387
+
1388
+	docker info
1389
+
1390
+After you make sure that docker is enabled and started, you can, for example, run the following docker command as root to create a container running Ubuntu 14.04 with an interactive terminal shell: 
1391
+
1392
+	docker run -i -t ubuntu:14.04 /bin/bash
1393
+
1394
+Photon OS also enables you to run a docker container that, in turn, runs Photon OS: 
1395
+
1396
+	docker run -i -t photon /bin/bash
1397
+
1398
+## Kubernetes
1399
+
1400
+The full version of Photon OS includes Kubernetes so you can manage clusters of containers. For more information, see [Running Kubernetes on Photon OS](https://github.com/vmware/photon/blob/master/docs/kubernetes.md).
1401
+
1402
+## RPM-OSTree
1403
+
1404
+RPM-OSTree is a package-aware file tree replication system that can keep Linux machines synchronized with the latest bits in a predictable and reliable way. To maintain consistency across file systems, RPM-OSTree uses a git-like repository that records the changes to any file and replicates them to any subscriber.
1405
+
1406
+RPM-OSTree lets you compose packages and other configuration options into a file tree on a server. The hosts download the file tree from the server and incrementally upgrade when the file tree changes. In this way, RPM-OSTree delivers identical, predicatable installed systems to solve the problems that commonly plague system administrators as they struggle to maintain a farm of computers with different packages, files, and configurations installed in different order. 
1407
+
1408
+When you install Photon OS from its ISO, it offers two installation options to take advantage of OSTree, a server and a host. The OSTree Host installation option creates a Photon OS instance that obtains its packages from an RPM-OSTree server. The host instance's packages and library are then centrally managed by the server.
1409
+
1410
+The OSTree Server installation option creates an instance of a server that manages the file system tree of the OSTree hosts. Creating a Photon OSTree Server establishes a new repository and management node for the Photon OS OSTree hosts. The Photon OS OSTree Server then manages the hosts as versioned, atomic entities to simply lifecycle management and security on an enterprise scale.   
1411
+
1412
+For more information, see the extensive sections on RPM-OSTree in the [Photon OS wiki](https://github.com/vmware/photon/wiki).
1413
+
1414
+## Disabling TLS 1.0 to Improve Transport Layer Security
1415
+
1416
+Photon OS includes GnuTLS to help secure the transport layer. [GnuTLS](http://www.gnutls.org/) is a library that implements the SSL and TLS protocols to secure communications. 
1417
+
1418
+On Photon OS, SSL 3.0, which contains a known vulnerability, is disabled by default. 
1419
+
1420
+However, TLS 1.0, which also contains known vulnerabilities, is enabled by default.
1421
+
1422
+To turn off TLS 1.0, make a directory named `/etc/gnutls` and then in `/etc/gnutls` create a file named `default-priorities`. In the `default-priorities` file, specify GnuTLS priority strings that remove TLS 1.0 and SSL 3.0 but retain TLS 1.1 and TLS 1.2.
1423
+
1424
+After adding a new `default-priorities` file or after modifying it, you must restart all applications, including SSH, with an open TLS session for the changes to take effect.  
1425
+
1426
+Here is an example of a `default-priorities` file that contains GnuTLS priorities to disable TLS 1.0 and SSL 3.0:  
1427
+
1428
+	cat /etc/gnutls/default-priorities
1429
+	SYSTEM=NONE:!VERS-SSL3.0:!VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL
1430
+
1431
+This example priority string imposes system-specific policies. The NONE keyword means that no algorithms, protocols, or compression methods are enabled, so that you can enable specific versions individually later in the string. The example priority string then specifies that SSL version 3.0 and TLS version 1.0 be removed, as marked by the exclamation point. The priority string then enables, as marked by the plus sign, versions 1.1 and 1.2 of TLS. The cypher is AES-128-CBC. The key exchange is RSA. The MAC is SHA1. And the compression algorithm is COMP-NULL.
1432
+
1433
+On Photon OS, you can verify the system-specific policies in the `default-priorities` file as follows. 
1434
+
1435
+Concatenate the `default-priorities` file to check its contents: 
1436
+
1437
+	root@photon-rc [ ~ ]# cat /etc/gnutls/default-priorities
1438
+	SYSTEM=NONE:!VERS-SSL3.0:!VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL
1439
+
1440
+Run the following command to check the protocols that are enabled for the system: 
1441
+
1442
+	root@photon-rc [ /etc/gnutls ]# gnutls-cli --priority @SYSTEM -l
1443
+	Cipher suites for @SYSTEM
1444
+	TLS_RSA_AES_128_CBC_SHA1                                0x00, 0x2f      SSL3.0
1445
+
1446
+	Certificate types: none
1447
+	Protocols: VERS-TLS1.1, VERS-TLS1.2
1448
+	Compression: COMP-NULL
1449
+	Elliptic curves: none
1450
+	PK-signatures: none
1451
+
1452
+For information about the GnuTLS priority strings, see [https://gnutls.org/manual/html_node/Priority-Strings.html](https://gnutls.org/manual/html_node/Priority-Strings.html).
1453
+
1454
+For information about the vulnerability in SSL 3.0, see [SSL 3.0 Protocol Vulnerability and POODLE Attack](https://www.us-cert.gov/ncas/alerts/TA14-290A).
1455
+
1456
+For information about the vulnerabilities in TLS 1.0, see [Guidelines for the Selection, Configuration, and Use of Transport Layer Security (TLS) Implementations](http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-52r1.pdf).
1457
+
1458
+## Building a Package from a Source RPM
1459
+
1460
+This section describes how to install and build a package on the full version of Photon OS from the package's source RPM. You obtain the source RPMs that Photon OS uses from Bintray: 
1461
+
1462
+[https://bintray.com/vmware/photon](https://bintray.com/vmware/photon)
1463
+
1464
+To build a package from its source RPM, or SRPM, Photon OS requires the following packages:  
1465
+
1466
+* rpmbuild. This package is installed by default on the full version of Photon OS, so you should not have to install it. 
1467
+* gcc. This package is also installed by default on the full version of Photon OS, so you should not have to install it. 
1468
+* make, Cmake, automake, or another make package, depending on the package you are trying to install and build from its source RPM. Cmake is installed by default on Photon OS. You can install other make packages if need be by using tdnf or yum.  
1469
+
1470
+Another requirement is a local unprivileged user account other than the root account. You should build RPMs as an unprivileged user. Do not build a package as root---building an RPM with the root account might damage your system. 
1471
+
1472
+If you are building a package on a virtual machine running Photon OS in VMware vSphere, VMware Workstation, or VMware Fusion, take a snapshot of your virtual machine before building the package. 
1473
+
1474
+VMware recommends that you install and build packages from their source RPMs on the full version of Photon OS. Do not use the minimal version to work with source RPMs.  
1475
+
1476
+Here's how to install and build an example package--sed, in this case--from its source RPM on Photon OS with an unprivileged account. 
1477
+
1478
+First, check whether rpmbuild is installed by running the following command: 
1479
+
1480
+	rpmbuild --version
1481
+
1482
+If it is not installed, install it by running the following command as root: 
1483
+
1484
+	tdnf install rpm-build
1485
+
1486
+Second, create the directories for building RPMs under your local user account's home directory (not under root):
1487
+
1488
+	mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
1489
+
1490
+Next, create a .rpmmacros file under your home directory and override the default location of the RPM building tree with the new one. This command overwrites an existing .rpmmacros file. Before running the following command, make sure you do not already have a .rpmmacros file; if a .rpmmacros file exists, back it up under a new name in case you want to restore it later. 
1491
+
1492
+	echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
1493
+
1494
+Now place the source RPM file that you want to install and build in the /tmp directory. 
1495
+
1496
+To install the source file, run the following command with your unprivileged user account, replacing the sed example source RPM with the name of the one that you want to install: 
1497
+
1498
+	rpm -i /tmp/sed-4.2.2-2.ph1.src.rpm
1499
+
1500
+The above command unpacks the source RPM and places its .spec file in your ~/rpmbuild/SPECS directory. In the next step, the rpmbuild tool uses the .spec file to build the RPM. 
1501
+
1502
+To build the RPM, run the following commands with your unprivileged user account. Again, replace the sed.spec example file with the name of the .spec file that you want to build. 
1503
+
1504
+	cd ~/rpmbuild/SPECS
1505
+	rpmbuild -ba sed.spec
1506
+
1507
+If successful, the rpmbuild -ba command builds the RPM and generates an RPM package file in your ~/rpmbuild/RPMS/x86_64 directory. Example:
1508
+
1509
+	ls RPMS/x86_64/
1510
+	sed-4.2.2-2.x86_64.rpm  sed-debuginfo-4.2.2-2.x86_64.rpm  sed-lang-4.2.2-2.x86_64.rpm
1511
+
1512
+The rpmbuild command also generates a new SRPM file and saves it in your ~/rpmbuild/SRPMS directory. Example:  
1513
+
1514
+	ls SRPMS/
1515
+	sed-4.2.2-2.src.rpm
1516
+
1517
+If the rpmbuild command is unsuccessful with an error that it cannot find a library, you must install the RPMs for the library that your source RPM depends on before you can successfully build your source RPM. Iterate through installing the libraries that your source RPM relies on until you can successfully build it. 
1518
+
1519
+To install the RPM, run the following command with your unprivileged user account:  
1520
+
1521
+	rpm -i RPMS/x86_64/sed-4.2.2-2.x86_64.rpm
1522
+
1523
+## References
1524
+
1525
+The following technical articles and guides appear in the [Photon OS wiki](https://github.com/vmware/photon/wiki): 
1526
+
1527
+* FAQ
1528
+* Running Photon OS on vSphere
1529
+* Running Photon OS on Fusion
1530
+* Running Photon OS on vCloud Air
1531
+* Install and Configure a Swarm Cluster with DNS Service on Photon OS
1532
+* Install and Configure a Production Ready Mesos Cluster on Photon OS
1533
+* Install and Configure Marathon for Mesos Cluster on Photon OS
1534
+* Install and Configure DCOS CLI for Mesos
1535
+* Install and Configure Mesos DNS on a Mesos Cluster
1536
+* RPM OSTree Documentation
1537
+
1538
+
1539
+