{"id":139557,"date":"2023-08-13T01:39:15","date_gmt":"2023-08-12T22:39:15","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=139557"},"modified":"2023-11-04T12:42:09","modified_gmt":"2023-11-04T09:42:09","slug":"manage-photon-os-from-command-line-interface-cli","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/manage-photon-os-from-command-line-interface-cli\/","title":{"rendered":"Manage Photon OS from Command Line Interface (CLI)"},"content":{"rendered":"\n<p><strong>Photon OS<\/strong> is an open-source Linux distribution designed by <em>VMware<\/em> to run containerized workloads. It is optimised to run on several cloud platforms such as vSphere, Microsoft Azure, Google Compute Engine, Amazon Elastic Compute Cloud etc, offering a small but still secure platform to run containerized workloads.<\/p>\n\n\n\n<p>It is shipped with only the required tools to run containers. This is so vital as it eliminates the attack surface and any other unnecessary libraries or packages that might increase its size. It also has fast boot times with less resource utilization which is so ideal for any containerized environment. <\/p>\n\n\n\n<p><a href=\"https:\/\/vmware.github.io\/photon\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/vmware.github.io\/photon\/\" rel=\"noreferrer noopener\">Photon OS<\/a> is secure by default using the Kernel Self-Protection Project (KSPP) recommendations. The Kernel is secure by default and all the packages are built with hardened security flags. To improve its security even further, Photon OS also includes SELinux and AppArmor to safeguard against any malicious activities on the system. <\/p>\n\n\n\n<p>OSTree is a powerful tool designed to handle bootable, unchangeable, and versioned filesystem trees. Unlike traditional package managers such as rpm or dpkg, which handle package installation, removal, and configuration, OSTree doesn&#8217;t have file-level awareness. However, when combined with rpm functionality, OSTree transforms into RPM-OSTree, a system capable of replicating filetrees while also being aware of packages. This integration allows for a comprehensive filetree replication system that incorporates package management capabilities.<\/p>\n\n\n\n<p>Photon OS also supports a traditional package management system, it includes a yum-compatible, package-based lifecycle management system known as <em><strong>tdnf<\/strong><\/em>. This gives the users the flexibility to select the tools that work best in their setup. <\/p>\n\n\n\n<p>With all the above features and benefits, Photon OS is a common choice for DevOps and any other area where cloud-native applications exist.<\/p>\n\n\n\n<p>In our previous guide, we learned how to<a href=\"https:\/\/computingforgeeks.com\/deploy-kubernetes-cluster-using-vmware-photon-os\/\" target=\"_blank\" rel=\"noreferrer noopener\"> deploy Kubernetes Cluster using VMware Photon OS<\/a>. Today we will focus on how to Administer or manage Photon OS from Command Line Interface(CLI). This guide covers the basic tasks such as managing packages, controlling services with systemd, configuring networking etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Manage Photon OS Packages<\/h2>\n\n\n\n<p>Photon OS repositories contain several packages. To view the packages that appear in the Photon OS repositories check the <a href=\"https:\/\/github.com\/vmware\/photon\/tree\/master\/SPECS\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a> website. To view the version of the package, select the package and click on the <strong>.spec f<\/strong>ile.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"389\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI.png\" alt=\"\" class=\"wp-image-139562\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI.png 923w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-300x126.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-768x324.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-696x293.png 696w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">a. Using sudo on Photon OS<\/h3>\n\n\n\n<p>The other important things when logging in to Photon and managing packages is <code>sudo<\/code>. Normally, Photon allows root login and users are able to execute commands without <code>sudo<\/code>. For the minimal version, you should install <em><strong>sudo<\/strong><\/em> to be able to use it.<\/p>\n\n\n\n<p>Use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tdnf install sudo<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">b. Checking Signatures on Photon OS<\/h3>\n\n\n\n<p>To enhance security, the packages on Photon OS are signed using GPG signatures. This uses keyed-hash authentication such as the SHA1 algorithm, RSA Data Security and MD5.<\/p>\n\n\n\n<p>The signature verification happens automatically when packages are installed or updated using the default package manager <code>tdnf<\/code><\/p>\n\n\n\n<p>By default, the GPG check for the tdnf config file is set to 1. Verify with the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">cat \/etc\/tdnf\/tdnf.conf<\/mark>\n&#91;main]\ngpgcheck=1\ninstallonly_limit=3\nclean_requirements_on_remove=0\nrepodir=\/etc\/yum.repos.d\ncachedir=\/var\/cache\/tdnf<\/code><\/pre>\n\n\n\n<p>To view the keys signings, use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">rpm -qa gpg-pubkey*<\/mark>\ngpg-pubkey-66fd4949-4803fe57\ngpg-pubkey-8a6a826d-596882ca<\/code><\/pre>\n\n\n\n<p>You can view detailed information of the key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">rpm -qi <em>gpg-pubkey-66fd4949-4803fe57<\/em><\/mark>\nName        : gpg-pubkey\nVersion     : 66fd4949\nRelease     : 4803fe57\nArchitecture: (none)\nInstall Date: Wed 10 May 2023 10:34:00 AM UTC\nGroup       : Public Keys\nSize        : 0\nLicense     : pubkey\nSignature   : (none)\nSource RPM  : (none)\nBuild Date  : Tue 15 Apr 2008 01:01:11 AM UTC\nBuild Host  : localhost\nPackager    : VMware, Inc. -- Linux Packaging Key -- &lt;linux-packages@vmware.com&gt;\nSummary     : VMware, Inc. -- Linux Packaging Key -- &lt;linux-packages@vmware.com&gt; public key\nDescription :\n-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: rpm-4.18.0\n\nmI0ESAP+VwEEAMZylR8dOijUPNn3He3GdgM\/kOXEhn3uQl+sRMNJUDm1qebi2D5b\nQa7GNBIlXm3DEMAS+ZlkiFQ4WnhUq5awEXU7MGcWCEGfums5FckV2tysSfn7HeWd\n9mkEnsY2CUZF54lyKfY0f+vdFd6QdYo6b+YxGnLyiunEYHXSEo1TNj1vABEBAAG0\nQlZNd2FyZSwgSW5jLiAtLSBMaW51eCBQYWNrYWdpbmcgS2V5IC0tIDxsaW51eC1w\nYWNrYWdlc0B2bXdhcmUuY29tPoi8BBMBAgAmBQJIA\/5XAhsDBQkRcu4ZBgsJCAcD\nAgQVAggDBBYCAwECHgECF4AACgkQwLXgq2b9SUkw0AP\/UlmWQIjMNcYfTKCOOyFx\nCsl3bY5OZ6HZs4qCRvzESVTyKs0YN1gX5YDDRmE5EbaqSO7OLriA7p81CYhstYID\nGjVTBqH\/zJz\/DGKQUv0A7qGvnX4MDt\/cvvgEXjGpeRx42le\/mkPsHdwbG\/8jKveY\nS\/eu0g9IenS49i0hcOnjShGIRgQQEQIABgUCSAQWfAAKCRD1ZoIQEyn810LTAJ9k\nIOziCqa\/awfBvlLq4eRgN\/NnkwCeJLOuL6eAueYjaODTcFEGKUXlgM4=\n=bXtp\n-----END PGP PUBLIC KEY BLOCK-----<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">c. Photon OS Package Repositories<\/h3>\n\n\n\n<p>Photon OS includes yum-compatible repositories by default. To view the repositories, use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls -l \/etc\/yum.repos.d\/<\/mark>\ntotal 24\n-rw-r--r-- 1 root root 313 Apr 24 20:29 photon-debuginfo.repo\n-rw-r--r-- 1 root root 238 Apr 24 20:29 photon-iso.repo\n-rw-r--r-- 1 root root 299 Apr 24 20:29 photon-release.repo\n-rw-r--r-- 1 root root 303 Apr 24 20:29 photon.repo\n-rw-r--r-- 1 root root 331 Apr 24 20:29 photon-srpms.repo\n-rw-r--r-- 1 root root 307 Apr 24 20:29 photon-updates.repo<\/code><\/pre>\n\n\n\n<p>Below is a breakdown of the repositories:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong> photon-iso.repo<\/strong> has the packages for photon OS loaded during the installation.<\/li>\n\n\n\n<li><strong>photon.repo<\/strong> has packages built for a given release<\/li>\n\n\n\n<li><strong>photon-updates.repo<\/strong> has the latest release versions for the rpms for a particular Photon release<\/li>\n\n\n\n<li><strong>photon-debuginfo.repo<\/strong> this has the debuginfo rpms that can be installed for issues or coredumps or issues. It is disabled by default.<\/li>\n\n\n\n<li><strong>photon-release.repo<\/strong> as deisbaled by default, contains the rpms snapped at the major release time<\/li>\n\n\n\n<li><strong>photon-srpms.repo<\/strong> contains the source rpms for a particular Photon release. It is disabled by default.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">d. Manage packages with tdnf<\/h3>\n\n\n\n<p>The default package manager for Photon OS is tdnf.  This is a C implementation of DNF without the Python dependencies. This package manage is available in both Minimal and full Photon OS versions.<\/p>\n\n\n\n<p>To view the available repositories, you can use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> tdnf repolist<\/mark>\nrepo id             repo name                                status   \nphoton-updates      VMware Photon Linux 5.0 (x86_64) Updates enabled  <\/code><\/pre>\n\n\n\n<p>The local cache is stored at <em><strong>\/var\/cache\/tdnf\/photon<\/strong><\/em>, you can clear that to make it simple for you to troubleshoot when you have issues or slow tdnf performance.<\/p>\n\n\n\n<p>To clear that, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo tdnf clean all<\/mark>\ncleaning photon-updates: metadata dbcache packages keys expire-cache\ncleaning photon-iso: metadata dbcache packages keys expire-cache\ncleaning photon-debuginfo: metadata dbcache packages keys expire-cache\ncleaning photon-srpms: metadata dbcache packages keys expire-cache\ncleaning photon-release: metadata dbcache packages keys expire-cache\ncleaning photon: metadata dbcache packages keys expire-cache\nDone.<\/code><\/pre>\n\n\n\n<p>New repositories on Photon OS are added to <strong><em>\/etc\/yum.repos.d\/<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls  \/etc\/yum.repos.d\/<\/mark>\nphoton-debuginfo.repo  photon-release.repo  photon-srpms.repo\nphoton-iso.repo        photon.repo          photon-updates.repo<\/code><\/pre>\n\n\n\n<p>You can view the syntax of the file, For example, the <strong>photon-release.repo<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">cat \/etc\/yum.repos.d\/photon-release.repo<\/mark>\n&#91;photon-release]\nname=VMware Photon Linux $releasever ($basearch)\nbaseurl=https:\/\/packages.vmware.com\/photon\/$releasever\/photon_release_$releasever_$basearch\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/VMWARE-RPM-GPG-KEY file:\/\/\/etc\/pki\/rpm-gpg\/VMWARE-RPM-GPG-KEY-4096\ngpgcheck=1\nenabled=0\nskip_if_unavailable=1<\/code><\/pre>\n\n\n\n<p>To demonstrate how to add a new repo, we will use the sample command below to add the Kopia YUM repo<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &lt;&lt;EOF | sudo tee \/etc\/yum.repos.d\/kopia.repo\n&#91;Kopia]\nname=Kopia\nbaseurl=http:\/\/packages.kopia.io\/rpm\/stable\/\\$basearch\/\ngpgcheck=1\nenabled=1\ngpgkey=https:\/\/kopia.io\/signing-key\nEOF<\/code><\/pre>\n\n\n\n<p>Once added, import the key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rpm --import https:\/\/kopia.io\/signing-key<\/code><\/pre>\n\n\n\n<p>Update the package index:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo tdnf makecache<\/mark>\nRefreshing metadata for: 'VMware Photon Linux 5.0 (x86_64) Updates'\nRefreshing metadata for: 'Kopia'        240884 100%\nMetadata cache created.                   3181 100%<\/code><\/pre>\n\n\n\n<p>Now there are several methods to install packages from the CLI using tdnf. These are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Using a Repo<\/strong><\/li>\n<\/ul>\n\n\n\n<p>You can use a repository to install a package on Photon OS. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install kopia<\/code><\/pre>\n\n\n\n<p>Sample output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"389\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-1.png\" alt=\"\" class=\"wp-image-139563\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-1.png 923w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-1-300x126.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-1-768x324.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-1-696x293.png 696w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Using a URL<\/strong><\/li>\n<\/ul>\n\n\n\n<p>It is possible to install an RPM package on Photon OS directly. All you need to do is provide the URL to the RPM file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><em>&lt;URL-to-RPM-file&gt;<\/em><\/mark><\/code><\/pre>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install https:\/\/repo.mongodb.org\/yum\/redhat\/9\/mongodb-org\/6.0\/x86_64\/RPMS\/mongodb-org-mongos-6.0.6-1.el9.x86_64.rpm<\/code><\/pre>\n\n\n\n<p>Sample output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"295\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-1024x295.png\" alt=\"\" class=\"wp-image-139564\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-1024x295.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-300x86.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-768x221.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-1536x443.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-696x201.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-1068x308.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2-1457x420.png 1457w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-2.png 1790w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Using RPM file<\/strong><\/li>\n<\/ul>\n\n\n\n<p>You can also download and install a package using an RPM file. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/repo.mongodb.org\/yum\/redhat\/9\/mongodb-org\/6.0\/x86_64\/RPMS\/mongodb-org-mongos-6.0.6-1.el9.x86_64.rpm<\/code><\/pre>\n\n\n\n<p>Now install the package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install .\/mongodb-org-mongos-6.0.6-1.el9.x86_64.rpm<\/code><\/pre>\n\n\n\n<p>Sample Output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"163\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3-1024x163.png\" alt=\"\" class=\"wp-image-139565\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3-1024x163.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3-300x48.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3-768x122.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3-696x111.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3-1068x170.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-3.png 1138w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">e. Update\/Upgrade Photon OS<\/h3>\n\n\n\n<p>To update or upgrade the Photon OS system use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf update<\/code><\/pre>\n\n\n\n<p>The command will check, download and install all the available system and package updates.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"996\" height=\"897\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-4.png\" alt=\"\" class=\"wp-image-139566\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-4.png 996w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-4-300x270.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-4-768x692.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-4-696x627.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2023\/06\/Administer-Manage-Photon-OS-from-Command-Line-InterfaceCLI-4-466x420.png 466w\" sizes=\"auto, (max-width: 996px) 100vw, 996px\" \/><\/figure>\n\n\n\n<p>Now you can automate the update process using the <code>tdnf-automatic<\/code>command. This can be used as an alternative command to  <code>tdnf upgrade\/tdnf update<\/code> with other added features to be executed as a corn job.<\/p>\n\n\n\n<p>The command is controlled by a config file located at <strong><em>\/etc\/tdnf\/automatic.conf<\/em><\/strong>. The tool checks and synchronizes package metadata for any available updates and outputs via <code>stdio<\/code><\/p>\n\n\n\n<p>To learn how to customize the <strong>\/etc\/tdnf\/automatic.conf<\/strong> use the help command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo tdnf-automatic help<\/mark>\ntdnf-automatic - started at Thu Jun 15 10:28:28 AM UTC 2023...\n\n\ntdnf-automatic help:\ntdnf-automatic &#91;{-c|--conf config-file}(optional)] &#91;{-i|--install}] &#91;{-n|--notify}] &#91;{-h|--help}] &#91;{-v|--version}]\n\n-c, --conf\ttdnf-automatic configuration file (Optional argument)\n-i, --install\tOverride automatic.conf apply_updates and install updates\n-n, --notify\tShow available updates\n-h, --help\tShow this help message\n-v, --version\tShow tdnf-automatic version information\n\n\ntdnf-automatic - completed with exit status 22 at Thu Jun 15 10:28:28 AM UTC 2023..<\/code><\/pre>\n\n\n\n<p>If not available, install it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install tdnf-automatic<\/code><\/pre>\n\n\n\n<p>To view the available updates, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo tdnf-automatic -n<\/mark>\ntdnf-automatic - started at Thu Jun 15 10:30:07 AM UTC 2023...\n\nRefreshCache success...\nRefreshCache success...\n\nThe following updates are available on - photon-lab:\nglibc-libs-2.36-5.ph5\ncoreutils-selinux-9.1-5.ph5\nxmlsec1-1.2.37-2.ph5\nvim-9.0.1532-1.ph5\nsystemd-udev-253-4.ph5\nsystemd-rpm-macros-253-4.ph5\n.....\ntdnf-automatic - completed with exit status 0 at Thu Jun 15 10:30:09 AM UTC 2023...<\/code><\/pre>\n\n\n\n<p>You can install the updates:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf-automatic -i<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Manage Services with Systemd on Photon OS<\/h2>\n\n\n\n<p>On Photon OS, services are managed by <strong><em>systemd<\/em><\/strong>. For that reason, you are able to manage services using the <code>systemctl<\/code> command and not the deprecated commands of<code> init.d<\/code>.<\/p>\n\n\n\n<p>To view the services, use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl<\/code><\/pre>\n\n\n\n<p>View the statuses:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl --all<\/code><\/pre>\n\n\n\n<p>To view the unit files, use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl list-unit-files<\/code><\/pre>\n\n\n\n<p>You can filter the required services using the grp command. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">systemctl list-unit-files | grep ssh<\/mark>\nsshd.service                           enabled         enabled\nsshd@.service                          static          -\nsshd.socket                            enabled         enabled<\/code><\/pre>\n\n\n\n<p>Now you can start, enable and stop the services using the <code>systemctl<\/code> command. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em><strong>##To start SSH\n<\/strong><\/em>sudo systemctl start sshd\n\n<strong><em>##To Enable SSH\n<\/em><\/strong>sudo systemctl enable sshd\n\n<strong><em>##To Stop SSH\n<\/em><\/strong>sudo systemctl stop sshd\n\n<strong><em>##Check status\n<\/em><\/strong>systemctl status sshd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. Manage Networks On Photon Os<\/h2>\n\n\n\n<p>You can manage network services using systemd that include <code>systemd-networkd<\/code>,&nbsp;<code>systemd-resolvd<\/code>, and&nbsp;<code>networkctl<\/code><\/p>\n\n\n\n<p>To view the status of the service use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">systemctl status systemd-networkd<\/mark>\n systemd-networkd.service - Network Configuration\n     Loaded: loaded (\/usr\/lib\/systemd\/system\/systemd-networkd.service; enabled; preset: enabl&gt;\n     Active: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">active (running)<\/mark> since Thu 2023-06-15 09:28:10 UTC; 1h 18min ago\nTriggeredBy: \u25cf systemd-networkd.socket\n       Docs: man:systemd-networkd.service(8)\n   Main PID: 522 (systemd-network)\n     Status: \"Processing requests...\"\n      Tasks: 1 (limit: 4624)\n     Memory: 3.0M\n        CPU: 24ms\n     CGroup: \/system.slice\/systemd-networkd.service\n             \u2514\u2500522 \/usr\/lib\/systemd\/systemd-networkd<\/code><\/pre>\n\n\n\n<p>Now to configure the network on Photon OS, you need to edit the<strong><em> systemd-networkd<\/em><\/strong> files at <strong><em>\/etc\/systemd\/network<\/em><\/strong> and <strong><em>\/usr\/lib\/systemd\/network<\/em><\/strong>.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls \/etc\/systemd\/network\/<\/mark>\n50-static-en.network<\/code><\/pre>\n\n\n\n<p>For this guide, we have the file as <strong><em>50-static-en.network<\/em><\/strong>. Now you can modify the file as desired.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim \/etc\/systemd\/network\/50-static-en.network<\/code><\/pre>\n\n\n\n<p>For example to configure DHCP:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Match]\nName=e*\n\n&#91;Network]\nDHCP=yes<\/code><\/pre>\n\n\n\n<p>For Static IP:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Match]\nName=eth0\n\n&#91;Network]\nIPv6AcceptRA=no\nAddress=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">192.168.200.61\/24<\/mark>\nDNS=8.8.8.8\nGateway=192.168.200.1<\/code><\/pre>\n\n\n\n<p>Once the changes have been made, ensure the file is owned by <strong><em>systemd-network<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown systemd-network:systemd-network  \/etc\/systemd\/network\/50-static-en.network<\/code><\/pre>\n\n\n\n<p>Verify if the system network locates the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo updatedb<\/mark>\n$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">locate systemd\/network<\/mark>\n\/etc\/systemd\/network\n\/etc\/systemd\/network\/50-static-en.network\n\/etc\/systemd\/networkd.conf\n\/run\/systemd\/network\n\/usr\/lib\/systemd\/network\n\/usr\/lib\/systemd\/network\/80-6rd-tunnel.network\n\/usr\/lib\/systemd\/network\/80-container-host0.network\n\/usr\/lib\/systemd\/network\/80-container-vb.network\n\/usr\/lib\/systemd\/network\/80-container-ve.network\n\/usr\/lib\/systemd\/network\/80-container-vz.network\n\/usr\/lib\/systemd\/network\/80-ethernet.network.example\n\/usr\/lib\/systemd\/network\/80-vm-vt.network\n\/usr\/lib\/systemd\/network\/80-wifi-adhoc.network\n\/usr\/lib\/systemd\/network\/80-wifi-ap.network.example\n\/usr\/lib\/systemd\/network\/80-wifi-station.network.example\n\/usr\/lib\/systemd\/network\/99-default.link<\/code><\/pre>\n\n\n\n<p>To apply the changes, restart the service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-networkd<\/code><\/pre>\n\n\n\n<p>Now check the IP address:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ifconfig<\/mark>\neth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500\n        inet 192.168.200.61  netmask 255.255.255.0  broadcast 192.168.200.255\n        inet6 fe80::cc85:4cff:fe74:cde6  prefixlen 64  scopeid 0x20&lt;link&gt;\n        ether ce:85:4c:74:cd:e6  txqueuelen 1000  (Ethernet)\n        RX packets 10603  bytes 95291495 (90.8 MiB)\n        RX errors 0  dropped 0  overruns 0  frame 0\n        TX packets 8695  bytes 766871 (748.8 KiB)\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\n....<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. Manage SELinux and Firewall on Photon OS<\/h2>\n\n\n\n<p>You can improve security on your Photon OS using SELinux or firewall settings. To be able to enable SELinux, you need to ensure that the required default policy and dependencies are installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install -y selinux-policy<\/code><\/pre>\n\n\n\n<p>Once installed, you can set SELinux in enforcing mode using two methods. The first one is a temporary setting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo setenforce 1<\/code><\/pre>\n\n\n\n<p>To make a permanent setting, you need to modify the below file as shown:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo vim \/etc\/selinux\/config<\/mark>\nSELINUX=enforcing\nenforcing=1<\/code><\/pre>\n\n\n\n<p>Save the file and reboot the system<\/p>\n\n\n\n<p>You can then load customized policies to SELinux. First, install the required packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo  tdnf install -y selinux-policy-devel semodule-utils make<\/code><\/pre>\n\n\n\n<p>Create the config file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">vim getty_local.te<\/mark>\npolicy_module(getty_local, 1.0)\n\ngen_require(`\n    type getty_t;\n      ')\n\nallow getty_t self:capability sys_admin;<\/code><\/pre>\n\n\n\n<p>Compile it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make -f \/usr\/share\/selinux\/devel\/Makefile getty_local.pp<\/code><\/pre>\n\n\n\n<p>Now load the policy with priority 200.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo semodule -i getty_local.pp -X 200<\/code><\/pre>\n\n\n\n<p>You can view all the loaded modules:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo semodule -lfull<\/code><\/pre>\n\n\n\n<p>You can manage firewall rules on Photon OS using iptables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install iptables<\/code><\/pre>\n\n\n\n<p>Export the profile if the iptables command is not found:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"export PATH=\\$PATH:\/usr\/sbin\" | sudo tee -a \/etc\/profile\nsource \/etc\/profile<\/code><\/pre>\n\n\n\n<p>Now you can allow a desired port:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT\nsudo iptables -A INPUT -p tcp -m tcp --dport 2379:2380 -j ACCEPT<\/code><\/pre>\n\n\n\n<p>Save the rules:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iptables-save &gt; \/etc\/systemd\/scripts\/ip4save<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. Manage Storage on Photon OS<\/h2>\n\n\n\n<p>Managing storage on Photon Os is similar to other Linux distributions. Check the disk usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> df -h<\/mark>\nFilesystem      Size  Used Avail Use% Mounted on\ndevtmpfs        4.0M     0  4.0M   0% \/dev\ntmpfs           1.9G     0  1.9G   0% \/dev\/shm\ntmpfs           777M  8.7M  768M   2% \/run\n\/dev\/sda3        40G  931M   37G   3% \/\ntmpfs           1.9G     0  1.9G   0% \/tmp\n\/dev\/sda2        10M  2.2M  7.9M  22% \/boot\/efi\ntmpfs           389M     0  389M   0% \/run\/user\/1000<\/code><\/pre>\n\n\n\n<p>View the attached disks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">lsblk<\/mark>\nNAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS\nsda      8:0    0    40G  0 disk \n\u251c\u2500sda1   8:1    0     4M  0 part \n\u251c\u2500sda2   8:2    0    10M  0 part \/boot\/efi\n\u2514\u2500sda3   8:3    0    40G  0 part \/\nsr0     11:0    1 537.5M  0 rom  <\/code><\/pre>\n\n\n\n<p>To partition a disk, use parted, installed with the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tdnf install parted<\/code><\/pre>\n\n\n\n<p>Once installed, perform disk partitioning:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo parted \/dev\/sdx<\/code><\/pre>\n\n\n\n<p>Where \/dev\/sdx is the exact name of the disk.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verdict<\/h2>\n\n\n\n<p>That marks the end of this detailed guide on how to Administer \/ Manage Photon OS from the Command Line Interface(CLI). This guide has only provided the basic administration tasks, there are more other tasks, please feel free to explore.<\/p>\n\n\n\n<p>Interested in more?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/computingforgeeks.com\/deploy-kubernetes-cluster-using-vmware-photon-os\/\" target=\"_blank\" rel=\"noreferrer noopener\">Deploy Kubernetes Cluster using VMware Photon OS<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/computingforgeeks.com\/install-flatcar-container-linux-in-vmware-workstation\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Flatcar Container Linux in VMware Workstation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/computingforgeeks.com\/deploy-multi-node-okd-cluster-using-fedora-coreos\/\" target=\"_blank\" rel=\"noreferrer noopener\">How To Deploy Multi-Node OKD Cluster using Fedora CoreOS<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Photon OS is an open-source Linux distribution designed by VMware to run containerized workloads. It is optimised to run on several cloud platforms such as vSphere, Microsoft Azure, Google Compute Engine, Amazon Elastic Compute Cloud etc, offering a small but still secure platform to run containerized workloads. It is shipped with only the required tools &#8230; <a title=\"Manage Photon OS from Command Line Interface (CLI)\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/manage-photon-os-from-command-line-interface-cli\/\" aria-label=\"Read more about Manage Photon OS from Command Line Interface (CLI)\">Read more<\/a><\/p>\n","protected":false},"author":21,"featured_media":142850,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,50,832,9275],"tags":[38580],"class_list":["post-139557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux-tutorials","category-tech","category-terminal","tag-photon-os"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/139557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=139557"}],"version-history":[{"count":0,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/139557\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/142850"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=139557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=139557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=139557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}