Barry Dunn, 29, of South Road, admitted assault, drugs and breach of the peace charges.
Dunn had sentence deferred until February 20 for reports and a restriction of liberty order assessment by Sheriff Alastair Carmichael.
He said he was giving Dunn a chance by putting him on bail for reports.
Dunn admitted that on January 9, at police HQ in Bell Street, he possessed heroin.
He further admitted assaulting Ewan Haldane, a police custody security officer, by attempting to punch him on the head and striking him on the head with his head, and that he behaved in a threatening or abusive manner likely to cause fear or alarm, shouted, swore, uttered threats of violence towards police officers and acted in an aggressive manner.