If I hold the PS4 home button, then log out from PS4 user account, will that also log out the PSN account I logged in to on that user account? If I won't sign out from my psn account in my friend's Ps4 can i sign in with my ps4 to my account ?
If you don't sign out on your friends system and try to sign into your account on your PS4, the account will be automatically signed out on your friends end. So no worries there. (I've done this on PS3, and saw it happen on a GameGrumps episode for PS4)
And yes, logging out of your user account will log you out of PSN. This can be seen when you re-log into the user account, you will see the log in process happen (store becomes available, friends start to show up, etc..).