Tricks for extracting and copying files from an ISO image (Linux)
GuideSuppose your Linux server has an oversized ISO image file. You want to open it and extract or copy one of the files. What would you do? In fact, in Linux, there are many ways to achieve this requirement.
For example, you can use the traditional mount command to load the ISO image file as a loop device in read-only mode, and then copy the file to another directory.
Extracting ISO image files in LinuxTo complete this test, you have to have an ISO image file (I am using a ubuntu-16.10-server-amd64.iso system image file) and a directory for mounting and extracting ISO image files.
First, use the following command to create a mount directory to mount the ISO image file:
$ sudo mkdir /mnt/iso
After the directory is created, you can run the following command to easily mount the ubuntu-16.10-server-amd64.iso system image file and view its contents.
$ sudo mount -o loop ubuntu-16.10-server-amd64.iso /mnt/iso$ ls /mnt/iso/
Mounting ISO images in LinuxNow you can go to the Mount directory/mnt/iso to view the file or use the cp command to copy the file to the/tmp directory.
$ cd /mnt/iso$ sudo cp md5sum.txt /tmp/$ sudo cp -r ubuntu /tmp/
Copy an ISO image file in a Linux SystemNote: The "-r" option is used to recursively copy contents in the directory. If necessary, you can also monitor the progress of the replication command.
Use the 7zip command to extract content from the ISO ImageIf you do not want to mount an ISO image, you can simply install a 7zip tool, which is a free and open-source decompression software used to compress or decompress files of different formats, including TAR, XZ, GZIP, ZIP, and BZIP2.
$ sudo apt-get install p7zip-full p7zip-rar [On Debian/Ubuntu systems]$ sudo yum install p7zip p7zip-plugins [On CentOS/RHEL systems]
After the 7zip software is installed, you can use the 7z command to extract the content from the ISO image file.
$ 7z x ubuntu-16.10-server-amd64.iso
Use the 7zip tool to Extract files from the ISO image in LinuxNote: compared with the Linux mount command, 7zip is faster and smarter when compressing and extracting files in any format.
Use the isoinfo command to extract the content of an ISO Image FileAlthough the isoinfo command is used to list the content of the iso9660 image file in the form of a directory, you can also use this program to Extract files.
As I said, the isoinfo program will display the directory list, so the content of the ISO image file will be listed first.
$ isoinfo -i ubuntu-16.10-server-amd64.iso -l
List ISO files in LinuxNow you can extract a single file from an ISO image file as follows:
$ isoinfo -i ubuntu-16.10-server-amd64.iso -x MD5SUM.TXT > MD5SUM.TXT
Note: Because "-x" is extracted to the standard output, you must use redirection to extract the specified file.
Extract A single file from an ISO Image FileThere are still many ways to achieve this. If you know other useful commands or tools to extract and copy files from an ISO image file, please share with you in the following comments.
From: https://linux.cn/article-7992-1.html
Address: http://www.linuxprobe.com/linux-iso-copy.html