Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet161/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   157   158   159   160   161   162   163   164   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

file(s)
Common options for du are listed in Table 10.5.
You can obtain an entire directory’s disk usage by using 
du –s /
dir
as in 
du –s 
/home/foxr
, or 
du –sh /home/foxr
if you prefer. What about obtaining a disk 
usage summary of all regular files? For that, we might want write a script that iterates 
through files, testing each with the -f condition.
What follows is a script that will search the directory specified as a parameter for the 
size of all regular files. The du -s command will respond with both the file’s size and the 
file’s name. By using 
awk '{print $1}'
, we only obtain the file size.
TABLE 10.5 
Common du Options
Option
Meaning
-a
Provide details on files and directories
-B 
size
Provide sizes in blocks of 
size
, for example, -B 4K
-b
Provide sizes in bytes
-c
Provide a total at the end of the listing
-h
Provide human-readable output (summarizes in terms of K, M, G, etc.)
-L/-P
Follow/do not follow symbolic links
-s
Summary only, do not list specific file sizes
--time
Add last modification time/date for each item


The Linux File System

429
#!/bin/bash
for item in ‘ls $1/*‘; do
if [ –f $item ]; then
size
=
‘du –s $item | awk '{print $1}'‘
sum
=
$((sum
+
size))
fi
done
echo $1 has regular files of size $sum
Both du and df can give us statistics on file space and file utilization. The stat command, 
covered earlier, provides specific file details on individual files or file systems, including, 
for instance, size, number of blocks, inode, device number, permissions, last access, and 
modification times and dates. We examine many other monitoring commands, such as 
vmstat for virtual memory usage, in Chapter 14.
10.6.2 Identifying Bad Blocks and Disk Errors
Linux offers several instructions to examine the file systems for errors. The 
badblocks
instruction calls upon other programs (such as fcsk) to do much of the work. For bad-
blocks, specify a device to scan. This device will be one of the file systems (partitions) 
whose name might look something like /dev/hda1 or /dev/sda5. Table 10.6 lists some com-
mon options for badblocks.
If bad blocks are found, you would next use the 
fsck
program to attempt to repair 
those bad blocks. Or, you could use fsck to find errors itself. Note that you should never 
use fsck on a mounted drive as it can (and probably will) cause damage to that file system.
The fsck command receives any of a mount point, file system name or file system node 
(UUID) as a parameter. If no file system is specified, by default, fsck will examine every 
file system, in order, as listed in /etc/fstab. You can also specify the file system type to be 
tested using -t 
type
. For instance, 
-t ext4
would search all ext4 type file systems as listed 
in /etc/fstab. With this option, you can also accompany it with further options that must 
match that file system to be searched. The list of options 
-t ext4 opts 
=
ro,nosync
TABLE 10.6 
Common Options for badblocks

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   157   158   159   160   161   162   163   164   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish