Linux - Commands

Page / - last modified by Julien Fleury on 2021/02/02 19:01

Commands

last modified by Julien Fleury

on 2021/02/02 19:01

Table of Contents

Useful Linux commands

Telnet like

Test disk speed

Contents

Useful Linux commands

Telnet like

Test disk speed

Useful Linux commands

Here is a list of useful commands to be executed on a Linux server (debian). Feel free to contribute by feeding this page with your own tricks and tips.

Telnet like

It is often required to test if a host[:port] is reachable and access is granted from a server. Best way to execute a telnet like command on a Linux console is to work with special files used to communcate with peripherals. Thus, in order to test tcp port 8000 on server 10.100.100.100, simply try to write in file /dev/tcp/10.100.100.100/8000 and add a return value depending on success or failure

echo > /dev/tcp/10.100.100.100/8000 && echo 'up' || echo 'down'
-bash: connect: Connection refused
-bash: /dev/tcp/10.100.100.100/8000: Connection refused
down

Test disk speed

dd command allows to copy all or parts of a disk by bytes block without impact from content structure of the disk.

Use dd command with caution as it can cause severe dammage to the system
Do not use dd to duplicate a disk. Prefer ddrescue command

Command structure

dd if=<source> of=<target> bs=<block size> count=<number of blocks> oflag=<flag>

oflag: 'dsync' to use synchronized I/O for data

dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync
1000+0 records in
1000+0 records out
512000 bytes (512 kB, 500 KiB) copied, 1.22846 s, 417 kB/s