debugfs is a command line tool in Linux that can be used to interact with the ext2, ext3 and ext4 file systems. It is used to examine and modify the file system structures, and can be used for various tasks such as checking the file system consistency, checking the file system statistics, and recovering lost files.
debugfs is a powerful command-line tool and should be used with caution, as it can cause data loss if used improperly.
If you encounter the below error while running the command debugfs:
debugfs: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install e2fsprogs |
Ubuntu | apt-get install e2fsprogs |
Alpine | apk add e2fsprogs |
Arch Linux | pacman -S e2fsprogs |
Kali Linux | apt-get install e2fsprogs |
CentOS | yum install e2fsprogs |
Fedora | dnf install e2fsprogs |
OS X | brew install e2fsprogs |
Raspbian | apt-get install e2fsprogs |
debugfs Command Examples
1. Open the filesystem in read only mode:
# debugfs /dev/sdXN
2. Open the filesystem in read write mode:
# debugfs -w /dev/sdXN
3. Read commands from a specified file, execute them and then exit:
# debugfs -f path/to/cmd_file /dev/sdXN
4. View the filesystem stats in debugfs console:
# stats
5. Close the filesystem:
# close -a
6. List all available commands:
# lr