After a verb: indicates there is no choice but to do something (e.g., 'have no choice but to...').
雨が止まないから、今日は出かけるのを諦めるしかない。
Since the rain won't stop, there's no choice but to give up going out today.
合格するためにはもっと勉強するしかない。
To pass, there's nothing to do but study harder.
電車が止まったから歩いて帰るしかない。
The train stopped, so we have no choice but to walk home.
After a noun or counter: indicates there is only that amount/thing (e.g., 'there is only...').
財布に千円しかない。
I only have 1,000 yen in my wallet.
彼の選択肢はそれしかないようだ。
It seems that's his only option.
残りは一つしかないから、大事に使ってください。
There is only one left, so please use it carefully.