Wiki source code of Commands
Last modified by Julien Fleury on 2021/02/02 19:05
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
5 | = Useful Linux commands = | ||
6 | |||
7 | 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. | ||
8 | |||
9 | == Telnet like == | ||
10 | |||
11 | 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 | ||
12 | |||
13 | {{code language="shell"}} | ||
14 | echo > /dev/tcp/10.100.100.100/8000 && echo 'up' || echo 'down' | ||
15 | -bash: connect: Connection refused | ||
16 | -bash: /dev/tcp/10.100.100.100/8000: Connection refused | ||
17 | down | ||
18 | {{/code}} | ||
19 | |||
![]() |
2.1 | 20 | == Test disk speed == |
21 | |||
22 | dd command allows to copy all or parts of a disk by bytes block without impact from content structure of the disk. | ||
23 | |||
![]() |
3.1 | 24 | (% class="box warningmessage" %) |
![]() |
2.1 | 25 | ((( |
![]() |
3.1 | 26 | Use dd command with caution as it can cause severe dammage to the system |
![]() |
2.1 | 27 | Do not use dd to duplicate a disk. Prefer ddrescue command |
28 | ))) | ||
29 | |||
30 | Command structure | ||
31 | |||
32 | (% class="box" %) | ||
33 | ((( | ||
34 | dd if=<source> of=<target> bs=<block size> count=<number of blocks> oflag=<flag> | ||
35 | ))) | ||
36 | |||
37 | oflag: 'dsync' to use synchronized I/O for data | ||
38 | |||
![]() |
3.1 | 39 | {{code language="shell"}} |
40 | dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync | ||
![]() |
2.1 | 41 | 1000+0 records in |
42 | 1000+0 records out | ||
![]() |
3.1 | 43 | 512000 bytes (512 kB, 500 KiB) copied, 1.22846 s, 417 kB/s |
44 | {{/code}} |