So bitcoin daemon is running on ubuntu server, that is itself a wallet, right?
Let's say this is A wallet.
1. If some other(B) send bitcoin to A wallet's one address, then A knows it immediately?
Can we type command, [ bitcoin-cli listtransactions ] returns above simulataneously?
2. Based on above 1, can we do some custom behaviour like send all received bitcoin (from B) to another C's address?
This should automatically done by program running.
How to do this?
Yeah it's possible, you just have to write a program or script to connect to bitcoind via the RPC, and you probably need to use the ZMQ socket to get realtime notifications of transactions.
Just a small note, A wouldn't know it "immediately", but it would after a few seconds. It can take a bit to propagate through the network sometimes.