0% found this document useful (0 votes)
14 views4 pages

Disk Management

Uploaded by

Himani Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Disk Management

Uploaded by

Himani Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Disk management

Sysadmins generally have to deal with many issues when it comes to managing disks. These
include:

 Partitioning disks
 Creating file systems
 Mounting file systems
 Sharing file systems
 Monitoring free space within file systems
 Backing up (and sometimes restoring) file systems

The reasons to partition a disk include:

 protecting some file systems from running out of space (e.g., you may want the OS partition
to be separated from home directories or applications to keep it from being affected if users’
files begin to take up far an excessive amount of disk space)
 improving performance
 allocating swap space
 facilitating maintenance and backups (e.g., you might be able to unmount /apps if it’s not part
of / and you might want to back up /home more frequently than /usr)
 more efficient (and targeted) fsck
 maintaining (particularly on test systems) multiple operating systems
 reserving enough disk space for file system expansion
 sharing select file systems with other system

The “du” (Disk Usage) command line is a standard command under Unix and Linux. It is used to
list the disk space used by files on a machine and crucial for disk space management on unix and
linux systems. Several paramaters enable users to format and filter the results.
Using du is a good starting point when trying to clean up unsed disk space under Unix.

du –s
Display the disk space used by all files in the selected directory by adding -s. You cannot limit the
folder depths while using this argument.

du -s /etc

There are a number of excellent commands for examining disk partitions. The df command is
one of the most commonly used commands for reporting on disk space usage. With the -h
option, the df command displays the measurements in the most "human-friendly" format and
that is, in fact, what the “h” is meant to imply. As you can see in the example below, the
measurements are displayed in kilobytes, megabytes or gigabytes depending on the sizes
rather than all using the same scale.
$ df -h

The lsblk (list block devices) command illustrates the relationship between disks
and their partitions graphically and also supplies the major and minor device
numbers and mount points.

du -h
Adding the parameter -h shows the results in a human-readable format: It adds size information
in Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, and Petabyte.

Combine -h and -s for Detailed and easy-to-read Information


-hs will show you all files in the folder and present the results in human-readable format:

Sort Results
Add | sort to the command line to sort the output. | sort -rh sorts recursively and displays the
biggest sizes on top.
root@server:/# du -s /* | sort -rh

See the Top10


Limit the output to the first ten lines with the | head command and see the ten largest files or
folders.
root@server:/# du -sh /* | sort -rh | head

The df Command
The first way to manage your partition space is with the df (disk free) command. The
command df -k (disk free) displays the disk space usage in kilobytes

The du Command
The du (disk usage) command enables you to specify directories to show disk space usage
on a particular directory.
This command is helpful if you want to determine how much space a particular directory is
taking. The following command displays number of blocks consumed by each directory. A
single block may take either 512 Bytes or 1 Kilo Byte depending on your system.
$du /etc

Mounting the File System


A file system must be mounted in order to be usable by the system. To see what is currently
mounted (available for use) on your system, use the following command −
$ mount

The /mnt directory, by the Unix convention, is where temporary mounts (such as CDROM
drives, remote network drives, and floppy drives) are located. If you need to mount a file
system, you can use the mount command with the following syntax −
mount -t file_system_type device_to_mount directory_to_mount_to
For example, if you want to mount a CD-ROM to the directory /mnt/cdrom, you can type −
$ mount -t iso9660 /dev/cdrom /mnt/cdrom

This assumes that your CD-ROM device is called /dev/cdrom and that you want to mount it
to /mnt/cdrom.

Unmounting the File System


To unmount (remove) the file system from your system, use the umount command by
identifying the mount point or device.
For example, to unmount cdrom, use the following command −
$ umount /dev/cdrom
The mount command enables you to access your file systems, but on most modern Unix
systems, the automount function makes this process invisible to the user and requires no
intervention.

There are three types of accounts on a Unix system −


Root account
This is also called superuser and would have complete and unfettered control of the system.
A superuser can run any commands without any restriction. This user should be assumed as
a system administrator.
System accounts
System accounts are those needed for the operation of system-specific components for
example mail accounts and the sshd accounts. These accounts are usually needed for some
specific function on your system, and any modifications to them could adversely affect the
system.
User accounts
User accounts provide interactive access to the system for users and groups of users. General
users are typically assigned to these accounts and usually have limited access to critical
system files and directories.
Unix supports a concept of Group Account which logically groups a number of accounts.
Every account would be a part of another group account. A Unix group plays important role
in handling file permissions and process management.

Managing Users and Groups


There are four main user administration files −
 /etc/passwd − Keeps the user account and password information. This file holds the
majority of information about accounts on the Unix system.
 /etc/shadow − Holds the encrypted password of the corresponding account. Not all
the systems support this file.
 /etc/group − This file contains the group information for each account.
 /etc/gshadow − This file contains secure group account information.

Check all the above files using the cat command.


https://www.tutorialspoint.com/unix/unix-user-administration.htm
https://www.computernetworkingnotes.com/rhce-study-guide/linux-disk-management-tutorial.html

You might also like