Here’s another summary of commands used in Linux. These commands are related to filesystem maintenance. It is important to monitor disk space and check Linux file system.
du – shows disk usage
syntax:
du [options] directory
Options:
-a Show counts for all files & directories
-b Display size in bytes
-c Print total for all arguments after processing
-h Print in human readable form
-k Show size in Kilobytes
-m Display size in Megabytes
-s Display a summary for each argument
-x Skip directories containing other filesystems
df – show used and available disk space
syntax:
df [options] directory
Options:
-a Show counts for all filesystems
-t fs type Limit listing to fs type
-h Print in human readable form
-k Show size in Kilobytes
-m Display size in Megabytes
-i Display inode information
-l Limit listing to local filesystems
-x fs type Exclude fs type from listing
fsck – check and optionally repair one or more Linux file systems.
Syntax:
fsck [options] device
Options:
-p Automatically repair without prompting
-n Don’t make changes to filesystem
-y Assume yes to all questions
-f Force check even if fs is clean
-r Interactively prompt for changes
-v Be verbose
-A Check all filesystems in /etc/fstab
-C Display a progress bar
-N Don’t execute, show what would be done
When fsck completes, it will return a value:
Code and Meaning
0 No errors
1 Errors found & corrected
2 System should be rebooted
4 Filesystem error left uncorrected
8 Operational error
16 Usage or syntax error
128 Shared library error
e2fsck – check Linux second extended file system (e2fs).
mke2fs – create an ext2 filesystem or make an ext3 filesystem with the -j option.
syntax:
mke2fs [options] device
Options:
-V Be verbose
-b blocksize Make blocks blocksize bytes
-c Check for bad blocks on device
-i bytes per inode Create an inode for each bytes per inode
-j Create a journal (ext3)
-L label Set the volume label
-N inodes Create the fs with specified number of inodes
-n Show what would be done (don’t actually create fs)
debugfs – a file system debugger
syntax:
debugfs [options] device
commands:
cat filespec –dump contents of the inode filespec to stdout.
cd filespec –change current working directory to filespec.
chroot filespec –change root directory to be the directory file spec.
close –close currently open file system
quit –exit debugfs
dumpe2fs – print super block and blocks group information for the filesystem present on device
syntax:
dumpe2fs [options] device
Options:
-b Display badblocks on device
-h Display superblock information
tune2fs – adjust tunable filesystem parameters on a Linux ext2 filesystem.
Syntax:
tune2fs [options] device
Options:
-c max-mounts Set no of mounts before fsck is forced
-g group Set the group who can use reserved blocks
-j Add a journal to the filesystem
-L label Set the volume label
-r blocks Set the number of reserved blocks