Differences between revisions 4 and 9 (spanning 5 versions)
Revision 4 as of 2019-12-07 10:00:07
Size: 357
Editor: Sciuro
Comment:
Revision 9 as of 2020-03-07 11:05:16
Size: 1666
Editor: Sciuro
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Shell examples #lang en
Line 3: Line 3:
== Sort IP adresses == <<TableOfContents()>>

= File operations =
== Remove files ==
Sometimes a file starts with a dash (-), for example, you ended up with a file named "-help". (don't ask me how you did it...) Of course you can remove the higher directory, but there are other ways of removing this file:
Line 5: Line 10:
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 rm -- -help
rm ./-help
Line 7: Line 13:
[[https://www.madboa.com/geek/sort-addr/]]
Line 9: Line 14:
== Scan PTR records == == Change files ==
Change the serial of a zone file. This is for BSD.
Line 11: Line 17:
for i in `seq 1 254`; do host 192.168.1.$i 192.168.1.1; done |grep pointer sed -i '' 's/2020022301/2020022302/g' filename
Line 15: Line 21:
Extract all files out of an image.
Line 19: Line 26:
== Mount ISO partitions ==
This is a raspberry pi image:

{{{
user@wks010~/Download$ sudo parted disk.bin unit s print
Model: (file)
Disk /home/user/Download/disk.bin: 581632s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
 1 8192s 49151s 40960s primary fat16 boot, lba
 2 57344s 581631s 524288s primary ext2
}}}

To calculate the offset, its in this case the start value times 512, so 8192 * 512 = 4194304

{{{
user@wks010~/Download$ sudo mount -o loop,offset=4194304 /home/user/Download/disk.iso /mnt/mydisk
}}}

= List operations =
== Sort IP adresses ==
Sort a list of IP adresses.
{{{
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4
}}}
Thanks: [[https://www.madboa.com/geek/sort-addr/]]

= Processes =
Line 20: Line 58:
Kill your current process.
Line 23: Line 62:

= Networking operations =
== Scan PTR records ==
Do a reverse scan of an IP range.
{{{
for i in `seq 1 254`; do host 192.168.1.$i 8.8.8.8; done |grep pointer
}}}

File operations

Remove files

Sometimes a file starts with a dash (-), for example, you ended up with a file named "-help". (don't ask me how you did it...) Of course you can remove the higher directory, but there are other ways of removing this file:

rm -- -help
rm ./-help

Change files

Change the serial of a zone file. This is for BSD.

sed -i '' 's/2020022301/2020022302/g' filename

Extract files

Extract all files out of an image.

binwalk --dd='.*' file.bin

Mount ISO partitions

This is a raspberry pi image:

user@wks010~/Download$ sudo parted disk.bin unit s print
Model:  (file)
Disk /home/user/Download/disk.bin: 581632s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End      Size     Type     File system  Flags
 1      8192s   49151s   40960s   primary  fat16        boot, lba
 2      57344s  581631s  524288s  primary  ext2

To calculate the offset, its in this case the start value times 512, so 8192 * 512 = 4194304

user@wks010~/Download$ sudo mount -o loop,offset=4194304 /home/user/Download/disk.iso /mnt/mydisk

List operations

Sort IP adresses

Sort a list of IP adresses.

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4

Thanks: https://www.madboa.com/geek/sort-addr/

Processes

Kill processes

Kill your current process.

kill -9 $$

Networking operations

Scan PTR records

Do a reverse scan of an IP range.

for i in `seq 1 254`; do host 192.168.1.$i 8.8.8.8; done |grep pointer

Howto/Shell (last edited 2020-03-07 11:05:16 by Sciuro)