Create an ISO Image from a source CD or DVD under Linux

(source: https://www.thomas-krenn.com/en/wiki/Create_an_ISO_Image_from_a_source_CD_or_DVD_under_Linux)

This brief article will describe the creation of a proper ISO image from a CD or DVD.

If an ISO image has been created with the help of the dd (diskdump) command from a CD or DVD then the ISO file created thereby may have an MD5 checksum, which is different than the original ISO file that was used for burning the source CD or DVD. A pair of zero data blocks at the end of the CD or DVD are responsible for this. Such an ISO image can be used without any problems, however testing the MD checksum against the source disk cannot be done (the download servers that provide ISO image for Linux, for example, typically also provide MD5 checksums for testing).

Using the following procedure, exactly the same ISO image that was used for burning the CD or DVD can be read from a CD or DVD:

1. Reading the block size and the volume size:

[root@testserver ~]# isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size' 
Logical block size is: 2048
Volume size is: 327867

2. Running dd with the parameters for block size and volume size:

[root@testserver ~]# dd if=/dev/cdrom of=test.iso bs=<block size from above> count=<volume size from above>

Note: When reading the ISO image, the following command can be used in a second console for viewing the current progress status (requires root rights):

killall -USR1 dd

With the of watch, this call can also be executed each second:

watch -n 1 killall -USR1 dd

Thereby, dd will display the progress status as follows:

admin@adminpc:~/Downloads/isos$ dd if=/dev/sr0 of=cdimage.iso bs=10M
1+0 records in
0+0 records out
0 bytes (0 B) copied, 10.2447 s, 0.0 kB/s
2+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 16.3769 s, 640 kB/s
3+0 records in
2+0 records out
20971520 bytes (21 MB) copied, 22.3123 s, 940 kB/s
5+0 records in
4+0 records out
41943040 bytes (42 MB) copied, 33.6603 s, 1.2 MB/s

Find Out What Process is Listening on a Specific TCP Port

There are two commands which are popular to get the result: netstat and lsof. We probably already have been familiar with

netstat -nlp

to list all the listening ports. We actually could do

lsof -Pnl +M -i4

to list all IPv4 ports or

lsof -Pnl +M -i6

to list all IPv6 ports as well.

Reset iptables / Clear / Remove all iptables rules

iptables has many different tables. In order to reset it or remove all rules of it, you need to run a series of commands like below:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -t raw -F
iptables -t raw -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

Don’t forget to save your iptables configuration. However, you have another option to do it easily and permanently by running the following command:

> /etc/sysconfig/iptables

And then restart the iptables service. All the rules will go away.