<?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>Forem: sasysalma</title>
    <description>The latest articles on Forem by sasysalma (@sasysalma).</description>
    <link>https://forem.com/sasysalma</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%2F924710%2F0bf4e3a2-a4bd-46a1-88bd-1a415152794c.png</url>
      <title>Forem: sasysalma</title>
      <link>https://forem.com/sasysalma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sasysalma"/>
    <language>en</language>
    <item>
      <title>Linux File System</title>
      <dc:creator>sasysalma</dc:creator>
      <pubDate>Mon, 26 Sep 2022 11:19:08 +0000</pubDate>
      <link>https://forem.com/sasysalma/linux-file-system-1ol</link>
      <guid>https://forem.com/sasysalma/linux-file-system-1ol</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Examining File Systems
When the df command is run without arguments, it reports total disk space, used disk space, free disk space, and the percentage of the total disk space used on all mounted regular file systems.
The following example displays the file systems and mount points 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;[user@host ~]$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          912584       0    912584   0% /dev
tmpfs             936516       0    936516   0% /dev/shm
tmpfs             936516   16812    919704   2% /run
tmpfs             936516       0    936516   0% /sys/fs/cgroup
/dev/vda3        8377344 1411332   6966012  17% /
/dev/vda1        1038336  169896    868440  17% /boot
tmpfs             187300       0    187300   0% /run/user/1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The du command shows the size of all files in the current directory tree recursively.&lt;br&gt;
Show a disk usage report for the /usr/share 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;[root@host ~]# du /usr/share
...output omitted...
176 /usr/share/smartmontools
184 /usr/share/nano
8 /usr/share/cmake/bash-completion
8 /usr/share/cmake
356676  /usr/share
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Identifying the Block Device
Use the lsblk command to list the details of a specified block device or all the available devices.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda                       253:0    0   12G  0 disk
├─vda1                    253:1    0    1G  0 part /boot
├─vda2                    253:2    0    1G  0 part [SWAP]
└─vda3                    253:3    0   11G  0 part /
vdb                       253:16   0   64G  0 disk
└─vdb1                    253:17   0   64G  0 part
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Mounting by Block Device Name
The following example mounts the file system in the /dev/vdb1 partition on the directory /mnt/data.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# mount /dev/vdb1 /mnt/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Mounting by File-system UUID
The lsblk -fp 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;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# lsblk -fp
NAME        FSTYPE LABEL UUID                                 MOUNTPOINT
/dev/vda                                                      
├─/dev/vda1 xfs          23ea8803-a396-494a-8e95-1538a53b821c /boot
├─/dev/vda2 swap         cdf61ded-534c-4bd6-b458-cab18b1a72ea [SWAP]
└─/dev/vda3 xfs          44330f15-2f9d-4745-ae2e-20844f22762d /
/dev/vdb
└─/dev/vdb1 xfs          46f543fd-78c9-4526-a857-244811be2d88
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# umount /mnt/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Searching for Files
This section discusses two commands that can search for files in the file-system hierarchy.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The locate command searches a pregenerated index for file names or file paths and returns the results instantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The find command searches for files in real time by crawling through the file-system hierarchy.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Locating Files by Name&lt;br&gt;
The locate command finds files based on the name or path to the file.&lt;br&gt;
The locate database is automatically updated every day. However, at any time the root user can issue the updatedb 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;[root@host ~]# updatedb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The locate command restricts results for unprivileged users.&lt;br&gt;
Search for files with passwd in the name or path in directory trees readable by user 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;[user@host ~]$ locate passwd
/etc/passwd
/etc/passwd-
/etc/pam.d/passwd
/etc/security/opasswd
/usr/bin/gpasswd
/usr/bin/grub2-mkpasswd-pbkdf2
/usr/bin/lppasswd
/usr/bin/passwd
...output omitted...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Searching for Files in Real Time&lt;br&gt;
The first argument to the find command is the directory to search.&lt;br&gt;
For example, to search for files named sshd_config starting from the / directory, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# find / -name sshd_config
/etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Searching Files Based on Ownership or Permission
Search for files owned by user in the /home/user 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;[user@host ~]$ find -user user
.
./.bash_logout
./.bash_profile
./.bashrc
./.bash_history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Searching Files Based on Size
The example below shows how to search for files with a size of 10 megabytes, rounded up.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[user@host ~]$ find -size 10M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Searching Files Based on Modification Time
To find all files that had their file content changed 120 minutes ago on host, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# find / -mmin 120
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Searching Files Based on File Type&lt;br&gt;
Use the following list to pass the required flags to limit the scope of search:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;f, for regular file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;d, for directory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;l, for soft link&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;b, for block device&lt;br&gt;
Search for all directories in the /etc directory on host.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@host ~]# find /etc -type d
/etc
/etc/tmpfiles.d
/etc/systemd
/etc/systemd/system
/etc/systemd/system/getty.target.wants
...output omitted...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate a list of all block devices in the /dev 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;[root@host ~]# find /dev -type b
/dev/vda1
/dev/vda
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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