tracking playback lag

When i go to record a guitar track on to an drum track that is on the Audacity interface that I am using the playback of the guitar track is a beat or so behind the actually drums even though I played to it in time while recording… Do you have any idea why that may be? This is my first time using Audacity, any help and info would be appreciated!

You need to calibrate your system to automatically correct the delay. It’s called “latency correction”. See:

Latency correction works perfectly under Windows (I follow the procedure connecting my USB interface Behringer UCA202 and found the exact latency).
But under Linux ( Audacity version 2.1.2 under Ubuntu 17.10) I don’t find some settings in the Edit->Preferences menu.
E.g. “Always record on a new track” seems to be not included (or I’m not able to find it); or, in the Selection Toolbar (in the lower side) is’not possible to select “Beginning and Leght of Selection”.
I don’t know if it’s for this lack, but when I try to start “Generate > Rhythm Track”, an error code appear on the display, thus I’m not able to correct latency under Linux (may be latency still remain the same, but i’m not sure that two different Operating Systems behave exactly in the same way and latency is only a problem of hardware interface (UCA202) I connect.
Is there a solution for Audacity version for Linux?

The version of Audacity in Ubuntu (Audacity 2.1.2) lags behind the current release version of Audacity (2.2.1).
Features that have been added to recent versions of Audacity will become available in Ubuntu when they catch up.

If you want to use the current release version of Audacity, the recommended way to get it is to build Audacity from the source code.
I posted a (slightly out of date) step-by-step guide for that here:

Alternatively, more recent versions of Audacity may be available through PPAs.
“Panda Jim’s” PPA is not an official release, but he generally keeps it up to date:
Note that you should only install software from sources that you trust.

I would strongly encourage users of PPAs to ensure that they understand the risks of using PPAs, and know how to cleanly remove a PPA (and any software that they have installed from that PPA) before they use the PPA.

I did exactly this and something went better; now i’m able to test latency, but delay is 160 ms and, when I set -160 ms and test if now latency is near to zero, Audacity states:
"Latency Correction setting has caused the recorded audio to be hidden before zero.
Audacity has brought it back to start at zero.
You may have to use the Time Shift Tool (<—> or F5) to drag the track to the right place.
And no record occurs.
Do you know what’s the maximum possible value for latency? E.g. -1000 ms is permitted?
I found this problem on Ubuntu only; in Windows 10 all works perfectly.
Have you a solution for this?