I know that we can shut down windows after some specific time like this
shutdown -s -t <time>
But how can I do the same when I want my pc to sleep after some specific amount of time?? is there any command??
Also it will be helpful if you told me the command for Linux too, Cause i rarely use windows.
Since you want the Linux solution, on recent systems:
systemctl suspend systemctl hibernate
If you want this to happen after a delay, combine with the sleep command:
sleep 1h 30m && systemctl suspend
You can also use the
kshutdown utility that gives you a GUI to shutdown/sleep on various conditions: after some delay, at a specific time, or when some process terminates.