<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: alfiantirta85</title>
    <description>The latest articles on DEV Community by alfiantirta85 (@alfiantirta85).</description>
    <link>https://dev.to/alfiantirta85</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F918588%2Ff53b5178-7556-4f4a-9fcb-44efbddce78e.png</url>
      <title>DEV Community: alfiantirta85</title>
      <link>https://dev.to/alfiantirta85</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alfiantirta85"/>
    <language>en</language>
    <item>
      <title>Container and Podman</title>
      <dc:creator>alfiantirta85</dc:creator>
      <pubDate>Sun, 12 Feb 2023 08:46:43 +0000</pubDate>
      <link>https://dev.to/alfiantirta85/container-and-podman-3lbm</link>
      <guid>https://dev.to/alfiantirta85/container-and-podman-3lbm</guid>
      <description>&lt;h2&gt;
  
  
  Container
&lt;/h2&gt;

&lt;p&gt;containers are a set of one or more processes that are isolated from the rest of the system and a way of packaging applications to simplify deployment and management. the many benefits of containers such as security, storage, and network isolation. containers isolate application libraries and runtime resources from the host operating system or hypervisor and vice versa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;how containers interact with the underlying hardware and operating system?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Runs directly on the operating system, sharing hardware and operating system resources across all containers on the system. to keep apps light and running fast in parallel&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Share the same operating system kernel, isolate container application processes from the rest of the system, and use any software that is compatible with that kernel&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires significantly less hardware resources than virtual machines which makes it quick to start and stop and reduces storage requirements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Containers are an efficient way to provide hosted application usability and portability because they can be easily moved from one environment to another, but containers are usually temporary or ephemeral.&lt;/p&gt;

&lt;p&gt;Container is run from a container image which serves as a blueprint for creating containers. container image cannot be changed because files including code and dependencies are required to run the container. container images are built according to specifications such as the Open Container Initiative (OCI).&lt;/p&gt;

&lt;p&gt;A good way to start learning about containers is to work with each container on the server that acts as a host. a set of container tools you can use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;podman, which is used directly to manage containers and container images.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;skopeo, which is used to check, copy, delete, and sign images.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;buildah, which is used to create a new container image.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;containers can be run by non-privileged users called rootless containers. rootless containers is safer but has some limitations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running base containers on rhel 8&lt;/strong&gt;&lt;br&gt;
To start running and managing containers on your system, you need to install the necessary command line tools like podman and skopeo with the yum command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum module install container-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container registry is a place to store and retrieve container images which are then used to run containers so the source of container images is very important.&lt;br&gt;
redhat distributes certified container images through 2 main container registrars:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;registry.redhat.io&lt;/code&gt; for containers based on official redhat products&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;registry.connect.redhat.com&lt;/code&gt; for containers based on third-party products&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;container images are named based on the syntax:&lt;br&gt;
registry_name/user_name/image_name:tag&lt;br&gt;
&lt;code&gt;registry_name&lt;/code&gt; is the name of the register that stores the image.&lt;br&gt;
&lt;code&gt;user_name&lt;/code&gt; is the user/organization the image belongs to.&lt;br&gt;
&lt;code&gt;image_name&lt;/code&gt; is a unique user namespace&lt;br&gt;
&lt;code&gt;tag&lt;/code&gt; is the image version&lt;/p&gt;

&lt;p&gt;To run the container on the local system, you must first pull the container image with the podman pull command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman pull registry.access.redhat.com/ubi8/ubi:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use the &lt;code&gt;podman image&lt;/code&gt; command to view locally stored images.&lt;br&gt;
to run the image you can use the &lt;code&gt;podman run&lt;/code&gt; command and use the &lt;code&gt;-it&lt;/code&gt; option to interact with the container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman run -it registry.access.redhat.com/ubi8/ubi:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use the command podman run --rm to remove it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman run --rm registry.access.redhat.com/ubi8/ubi cat /etc/os-release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use the &lt;code&gt;podman info&lt;/code&gt; command to display podman configuration information.&lt;br&gt;
use the &lt;code&gt;podman search&lt;/code&gt; command to search the container registrar for a specific container image and the &lt;code&gt;--no-trunc&lt;/code&gt; option to view a longer image description.&lt;/p&gt;

&lt;p&gt;to inspect remote container images in registry and show information you can use &lt;code&gt;skopeo inspect&lt;/code&gt; command and to check locally stored ones use &lt;code&gt;podman inspect&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;skopeo inspect docker://registry.redhat.io/rhel8/python-36
podman inspect registry.redhat.io/rhel8/python-36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to delete locally stored images use the podman rmi command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman rmi registry.redhat.io/rhel8/python-36:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To provide network access to a container, you must connect to a port on the container host that forwards network traffic to the port on the container. You can map the container host port with the &lt;code&gt;podman run&lt;/code&gt; command using the &lt;code&gt;-p&lt;/code&gt; option and to run the container in separate mode (as a daemon) use the &lt;code&gt;-d&lt;/code&gt; option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman run -d -p 8000:8080 registry.redhat.io/rhel8/httpd-24
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see all used port mappings with the command podman port -a and to add the container host port on the firewall use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firewall-cmd --add-port=8000/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can pass the environment variables that the container uses to configure its application with the podman run command with the -e option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman run -d --name container_name -e MYSQL_USER=user_name -e MYSQL_PASSWORD=user_password -e MYSQL_DATABASE=database_name -⁠e MYSQL_ROOT_PASSWORD=mysql_root_password -p 3306:3306 registry.redhat.io/⁠rhel8/⁠mariadb-103:1-102
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To see running containers, use the &lt;code&gt;podman ps&lt;/code&gt; command and the &lt;code&gt;-a&lt;/code&gt; option include stopped containers.&lt;/li&gt;
&lt;li&gt;To stop a running container, use the &lt;code&gt;podman stop&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;To remove container from host use command &lt;code&gt;podman rm&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To restart a stopped container, use the &lt;code&gt;podman restart&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;To send a UNIX signal to the main process in the container, use the &lt;code&gt;podman kill&lt;/code&gt; command and the &lt;code&gt;-a&lt;/code&gt; option to specify the signal.&lt;/li&gt;
&lt;li&gt;To start additional processes in an already running container, use the &lt;code&gt;podman exec&lt;/code&gt; command, options &lt;code&gt;-i&lt;/code&gt; and &lt;code&gt;-t&lt;/code&gt; to open an interactive session and allocate a pseudo-terminal for the shell and option &lt;code&gt;-l&lt;/code&gt; to change the ID or name of the previous container.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>community</category>
    </item>
    <item>
      <title>Managing File System Permissions</title>
      <dc:creator>alfiantirta85</dc:creator>
      <pubDate>Sun, 25 Sep 2022 02:22:36 +0000</pubDate>
      <link>https://dev.to/alfiantirta85/managing-file-system-permissions-egf</link>
      <guid>https://dev.to/alfiantirta85/managing-file-system-permissions-egf</guid>
      <description>&lt;h2&gt;
  
  
  User Categories
&lt;/h2&gt;

&lt;p&gt;Files has three categories of users for which permissions apply:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The user who created the file&lt;/li&gt;
&lt;li&gt;A user who is in the same grub as the user&lt;/li&gt;
&lt;li&gt;All other users&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Permission Categories
&lt;/h2&gt;

&lt;p&gt;File/directory have three categories of applicable permissions: read, write, and execute.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;r(read)    --&amp;gt; file can be read&lt;/li&gt;
&lt;li&gt;w(write)   --&amp;gt; file can be edited&lt;/li&gt;
&lt;li&gt;x(execute) --&amp;gt; file can be run as command&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  View Permissions And Ownership
&lt;/h2&gt;

&lt;p&gt;To see the permissions and ownership of files and directories can use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -l or ls -ld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Option &lt;strong&gt;-l&lt;/strong&gt; --&amp;gt; view list with long list format.&lt;br&gt;
Option &lt;strong&gt;-d&lt;/strong&gt; --&amp;gt; view the directory listing itself.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94vgkuj1fapijofy6xnu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94vgkuj1fapijofy6xnu.png" alt="Image description"&gt;&lt;/a&gt;File permission consist of nine characters after the character d(directory).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Permission for the user is determined by the first set of 3 characters&lt;/li&gt;
&lt;li&gt;Permission for user groups are determined by the second set of 3 characters&lt;/li&gt;
&lt;li&gt;Permission for all other users are determined by the third set of 3 characters&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If the letters are replaced with -, then the category doesn't have that permission.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Change Permission
&lt;/h2&gt;

&lt;p&gt;To change permission from the command line can use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Permission instructions can be issued by symbolic methods and numerical methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  Symbolic Method
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod WhoWhatWhich file/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Who is u(user), g(group), o(other), a(all)&lt;/li&gt;
&lt;li&gt;What is +(add), -(remove), =(set exactly)&lt;/li&gt;
&lt;li&gt;Which is r(read), w(write), x(execute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndwa0w5t9p65o9imip9n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndwa0w5t9p65o9imip9n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3saeucnm495i2a1e0jdk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3saeucnm495i2a1e0jdk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;option -R to change the permissions of the directory and its contents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Numeric Method
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod ### file/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each digit represents a permission for the access level: user, group, other.&lt;br&gt;
Each digit is the sum of the numbers representing the permissions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;read permission is represented by the number 4&lt;/li&gt;
&lt;li&gt;write permission is represented by the number 2&lt;/li&gt;
&lt;li&gt;execute permission is represented by the number 1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz8kwyxsw911w5kpzsal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz8kwyxsw911w5kpzsal.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Change User And Group Ownership
&lt;/h2&gt;

&lt;p&gt;To change the ownership of users and groups can use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;only root user can change file ownership&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To change only the user, use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chown usernew file1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To change only the group, use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chown :groupnew file1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To change everything, use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chown usernew:groupnew file1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filyrwk6dkgk5oqc2fiyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filyrwk6dkgk5oqc2fiyh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We can use sudo privilege to use chown command.&lt;br&gt;
Option -R to change the ownership of the directory and its contents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Special Permission
&lt;/h2&gt;

&lt;p&gt;Special permission is the fourth type of permission besides basic user, grub and other types. These permissions have additional access features that are allowed by the basic permission types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Setuid Permission&lt;/strong&gt;&lt;br&gt;
on files containing this permission executable. however, the command that is executed becomes the user who owns the file, not as the user that executes the command.&lt;br&gt;
to add this permission, can use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod u+s file1 or chmod 4### file1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Setgid Permission&lt;/strong&gt;&lt;br&gt;
files created in a directory containing these permissions inherit ownership of grub rather than inheriting from the user who created it. this file is executable. however, the command that is executed becomes the grub that owns the file, not as the grub that runs the command.&lt;br&gt;
to add this permission, can use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod g+s file1 or chmod 2### file1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Sticky Permission&lt;/strong&gt;&lt;br&gt;
on directories that contain this permission, file deletion is subject to special restrictions. only file owner and root user can delete files in directory&lt;br&gt;
to add this permission, can use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod o+t file1 or chmod 1### file1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Default File Permission
&lt;/h2&gt;

&lt;p&gt;When you create a new file/directory it is given initial permission called umask.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you create a new directory, the operating system will grant octal permission 0777&lt;/li&gt;
&lt;li&gt;If you create a new file, the operating system will give permission octal 0666&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Octal permission will be reduced by the umask set, usually 0002.&lt;br&gt;
To see the umask that has been set, you can use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;umask
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To replace it, you can use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;umask 027
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
