user6841: I wrote Arduino sketch and it works. It waits for a command and answers text on response. 

Simultaneously, I can't get any response with command line tools.
For example, I have the following code to get temperature:
#!/bin/bash
tty=/dev/ttyUSB0
exec 4<$tty 5>$tty
stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
#stty -F $tty 9600 -echo
#printf "temp\n" >&5
echo temp >&5
read reply <&4
echo "$reply"
#tail -n 1 - <&4

It returns empty or hang under different circumstances.
Also, if I run built-in Serial Monitor, I can see responses on command lines like:
echo temp > /dev/ttyUSB0

But I see nothing with commands like tail -f /dev/ttyUSB0
What I am doing wrong?

user4143: Add the flag -hupcl to your stty command.  That will disable the assertion of DTR which is resetting the board.
 hupcl (-hupcl)
             Stop asserting modem control (do not stop asserting modem
             control) on last close.

The first time it is run there will be a reset, since setting that flag entails opening the port, which causes a reset.  So you need to add a delay long enough to get past the bootloader - minimum 2 seconds, best make it 3.
You can do that with the sleep command: sleep 3
Note that you now won't be able to upload a new sketch since you have disabled the auto-reset feature that allows you to enter the bootloader, so before uploading a new sketch you need to turn the reset back on with 
stty -F $tty hupcl

If you don't disable the reset then every operation in your script that opens and then closes the serial port will trigger a reset of the board.  So in summary try this:
#!/bin/bash
tty=/dev/ttyUSB0
stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -hupcl
sleep 3
echo temp >$tty
read reply <$tty
echo "$reply"
stty -F $tty hupcl


6841: <p>I wrote Arduino sketch and it works. It waits for a command and answers text on response. </p>

<p><a href="https://i.stack.imgur.com/Nz3sh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nz3sh.png" alt="enter image description here"></a></p>

<p>Simultaneously, I can't get any response with command line tools.</p>

<p>For example, I have the following code to get temperature:</p>

<pre><code>#!/bin/bash
tty=/dev/ttyUSB0
exec 4&lt;$tty 5&gt;$tty
stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
#stty -F $tty 9600 -echo
#printf "temp\n" &gt;&amp;5
echo temp &gt;&amp;5
read reply &lt;&amp;4
echo "$reply"
#tail -n 1 - &lt;&amp;4
</code></pre>

<p>It returns empty or hang under different circumstances.</p>

<p>Also, if I run built-in <code>Serial Monitor</code>, I can see responses on command lines like:</p>

<pre><code>echo temp &gt; /dev/ttyUSB0
</code></pre>

<p>But I see nothing with commands like <code>tail -f /dev/ttyUSB0</code></p>

<p>What I am doing wrong?</p>
 4143: <p>Add the flag <code>-hupcl</code> to your <code>stty</code> command.  That will disable the assertion of DTR which is resetting the board.</p>

<pre><code> hupcl (-hupcl)
             Stop asserting modem control (do not stop asserting modem
             control) on last close.
</code></pre>

<p>The first time it is run there will be a reset, since setting that flag entails opening the port, which causes a reset.  So you need to add a delay long enough to get past the bootloader - minimum 2 seconds, best make it 3.</p>

<p>You can do that with the <code>sleep</code> command: <code>sleep 3</code></p>

<p>Note that you now won't be able to upload a new sketch since you have disabled the auto-reset feature that allows you to enter the bootloader, so before uploading a new sketch you need to turn the reset back on with </p>

<pre><code>stty -F $tty hupcl
</code></pre>

<p>If you don't disable the reset then every operation in your script that opens and then closes the serial port will trigger a reset of the board.  So in summary try this:</p>

<pre><code>#!/bin/bash
tty=/dev/ttyUSB0
stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -hupcl
sleep 3
echo temp &gt;$tty
read reply &lt;$tty
echo "$reply"
stty -F $tty hupcl
</code></pre>
