<?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: Mohammad-Alwan</title>
    <description>The latest articles on DEV Community by Mohammad-Alwan (@mohammadalwan).</description>
    <link>https://dev.to/mohammadalwan</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%2F924737%2F0fe3b446-99c2-4c20-83e1-586e5a1674bc.png</url>
      <title>DEV Community: Mohammad-Alwan</title>
      <link>https://dev.to/mohammadalwan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohammadalwan"/>
    <language>en</language>
    <item>
      <title>Accessing Linux File Systems on RHEL 8 (RedHat Enterprise 8)</title>
      <dc:creator>Mohammad-Alwan</dc:creator>
      <pubDate>Mon, 26 Sep 2022 02:35:33 +0000</pubDate>
      <link>https://dev.to/mohammadalwan/accessing-linux-file-systems-on-rhel-8-redhat-enterprise-linux-8-25aa</link>
      <guid>https://dev.to/mohammadalwan/accessing-linux-file-systems-on-rhel-8-redhat-enterprise-linux-8-25aa</guid>
      <description>&lt;h2&gt;
  
  
  Disk Partitions
&lt;/h2&gt;

&lt;p&gt;Normally, you do not make the entire storage device into one file system. Storage devices are typically divided up into smaller chunks called partitions.&lt;br&gt;
Partitions are block devices in their own right. On SATA-attached storage, the first partition on the first disk is /dev/sda1. The third partition on the second disk is /dev/sdb3, and so on. Paravirtualized storage devices have a similar naming system.Partitions allow you to compartmentalize a disk: the various partitions can be formatted with different file systems or used for different purposes.&lt;br&gt;
&lt;strong&gt;Blok Device Naming&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--er1bJCmg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y08fng9i53q1c1zmaoju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--er1bJCmg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y08fng9i53q1c1zmaoju.png" alt="Image description" width="709" height="304"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Tools for Managing Partitions on Linux
&lt;/h2&gt;

&lt;p&gt;There are several command line interface (CLI) based tools that are commonly used to view drive and partition information and to manage partitions.&lt;/p&gt;

&lt;p&gt;To get an overview of local and remote file system devices and the amount of free space available, run the &lt;code&gt;df&lt;/code&gt;(disk free) command.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Example:&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ya80YF0K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvbcp4v90fzs3ne57lwk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ya80YF0K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvbcp4v90fzs3ne57lwk.png" alt="Image description" width="720" height="816"&gt;&lt;/a&gt; For more detailed information about space used by a certain directory tree, use the &lt;code&gt;du&lt;/code&gt;(disk usage) command.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Example :&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XMQJaKTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8scul5pevz5jxakyirb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XMQJaKTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8scul5pevz5jxakyirb3.png" alt="Image description" width="720" height="400"&gt;&lt;/a&gt; The &lt;code&gt;du&lt;/code&gt; command has &lt;code&gt;-h&lt;/code&gt; and &lt;code&gt;-H&lt;/code&gt; options to convert the output to human-readable format.&lt;br&gt;
Example :&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g7CXUbFs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfbwnjyll2orp1558mby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g7CXUbFs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfbwnjyll2orp1558mby.png" alt="Image description" width="720" height="380"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Mounting and Unmounting File Systems
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mounting File Systems Manually&lt;/strong&gt;&lt;br&gt;
before that, use the &lt;code&gt;lsblk&lt;/code&gt; command to list the specific block device details or all available devices.&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UBytz1K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5zs383p5vfmjhr76r4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UBytz1K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5zs383p5vfmjhr76r4m.png" alt="Image description" width="720" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mounting by Block Device Name&lt;/strong&gt;&lt;br&gt;
The following example mounts the file system in the /dev/sdb1 partition on the directory /mnt/data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# mount /dev/sdb1 /mnt/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To mount a file system, the destination directory must already exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mounting by File-system UUID&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;lsblk&lt;/code&gt; &lt;code&gt;-fp&lt;/code&gt; command lists the full path of the device, along with the UUIDs and mount points, as well as the type of file system in the partition.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r299t-iQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kel1sqa7ph7jih1nrxjl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r299t-iQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kel1sqa7ph7jih1nrxjl.png" alt="Image description" width="720" height="602"&gt;&lt;/a&gt;&lt;br&gt;
Mount the file system by the UUID of the file system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# mount UUID="959f776a-84bd-4cfb-a9c9-e13623930202" /mnt/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Unmounting File Systems&lt;/strong&gt;&lt;br&gt;
To unmount a file system, the umount command expects the mount point as an argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# umount /mnt/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the umount command to succeed, all processes needs to stop accessing data under the mount point.&lt;br&gt;
The lsof command lists all open files and the process accessing them in the provided directory. It is useful to identify which processes currently prevent the file system from successful unmounting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# lsof /mnt/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the processes are identified, an action can be taken, such as waiting for the process to complete or sending a &lt;code&gt;SIGTERM&lt;/code&gt; or &lt;code&gt;SIGKILL&lt;/code&gt; signal to the process. In this case, it is sufficient to change the current working directory to a directory outside the mount point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locating Files on the System
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Locating Files by Name&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;locate&lt;/code&gt; command finds files based on the name or path to the file. It is fast because it looks up this information from the mlocate database. However, this database is not updated in real time, and it must be frequently updated for results to be accurate. This also means that locate will not find files that have been created since the last update of the database.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;locate&lt;/code&gt; database is automatically updated every day. However, at any time the root user can issue the &lt;code&gt;updatedb&lt;/code&gt; command to force an immediate update.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Example of searching for a file with the name passwd.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IGdbo74N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uosl7i5508s9exeawrp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IGdbo74N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uosl7i5508s9exeawrp3.png" alt="Image description" width="720" height="1287"&gt;&lt;/a&gt;&lt;br&gt;
The -i option performs a case-insensitive search. With this option, all possible combinations of upper and lowercase letters match the search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ locate -i messages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output : &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UeHKUCRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cc38edoovvh228ds1zs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UeHKUCRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cc38edoovvh228ds1zs1.png" alt="Image description" width="720" height="1281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Searching for Files in Real Time&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;find&lt;/code&gt; command locates files by performing a real-time search in the file-system hierarchy. It is slower than locate, but more accurate. It can also search for files based on criteria other than the file name, such as the permissions of the file, type of file, its size, or its modification time.&lt;br&gt;
To search for files by file name, use the &lt;code&gt;-name&lt;/code&gt; FILENAME option. For example, to search for files named sshd_config starting from the / directory, run the following command:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sPndx5l8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5q46outmqezoagaczv1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sPndx5l8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5q46outmqezoagaczv1d.png" alt="Image description" width="720" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the following example, search for files starting in the / directory that end in .txt:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ud9yNwPQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vra76tgw0hh28ueqfcku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ud9yNwPQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vra76tgw0hh28ueqfcku.png" alt="Image description" width="720" height="1241"&gt;&lt;/a&gt;&lt;br&gt;
To search for files in the /etc/ directory that contain the word, pass, anywhere in their names on host, run the following command:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r550v_2S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7jqt6oikpu7bz6ppfv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r550v_2S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7jqt6oikpu7bz6ppfv6.png" alt="Image description" width="718" height="211"&gt;&lt;/a&gt;&lt;br&gt;
To perform a case-insensitive search for a given file name, use the &lt;code&gt;-iname&lt;/code&gt; option, followed by the file name to search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#find / -iname '*messages*'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Searching Files Based on Ownership or Permission&lt;/strong&gt;&lt;br&gt;
Search for files owned by user in the /home/user directory on host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find -user user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search for files owned by the group user in the /home/user directory on host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find -group user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search for files owned by user ID 1000 in the /home/user directory on host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find -uid 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search for files owned by group ID 1000 in the /home/user directory on host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find -gid 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-user&lt;/code&gt;, and &lt;code&gt;-group&lt;/code&gt; options can be used together to search files where file owner and group owner are different.&lt;br&gt;
Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# find / -user root -group mail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-perm&lt;/code&gt; option is used to look for files with a particular set of permissions. Permissions can be described as octal values, with some combination of 4, 2, and 1 for read, write, and execute. Permissions can be preceded by a / or - sign.&lt;/p&gt;

&lt;p&gt;To use a more complex example, the following command matches any file for which the user has read, write, and execute permissions, members of the group have read and write permissions, and others have read-only access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find /home -perm 764
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Searching Files Based on Size&lt;/strong&gt;&lt;br&gt;
Use the following list as the units with the &lt;code&gt;-size&lt;/code&gt; option:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;k&lt;/code&gt;, for kilobyte&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;M&lt;/code&gt;, for megabyte&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;G&lt;/code&gt;, for gigabyte&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The example below shows how to search for files with a size of 10 megabytes, rounded up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find -size 10M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To search the files with a size more than 10 gigabytes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ find -size +10G
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Searching Files Based on Modification Time&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;-mmin&lt;/code&gt; option, followed by the time in minutes, searches for all files that had their content changed at n minutes ago in the past.It also supports fractional values when used with ranges (+n and -n).&lt;/p&gt;

&lt;p&gt;To find all files that had their file content changed 120 minutes ago on host, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# find / -mmin 120
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, files that were modified more than 200 minutes ago are listed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# find / -mmin +200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Searching Files Based on File Type&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;-type&lt;/code&gt; option in the find command limits the search scope to a given file type. Use the following list to pass the required flags to limit the scope of search:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;f&lt;/code&gt;, for regular file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d&lt;/code&gt;, for directory&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;l&lt;/code&gt;, for soft link&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;b&lt;/code&gt;, for block device
Example ;
Search for all directories in the /etc directory on host.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# find /etc -type d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search for all soft links on host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# find / -type l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
