# Is it possible to start a tmux session on login?



## mrjayviper (May 19, 2014)

I often SSH into my FreeBSD box as it's running headless. I log in using a normal user and then switch user to root.

I want to automatically create a new tmux session (with the name "my-session") once I `su` to root. I tried creating a new session by running it from /root/.cshrc but nothing happened (i.e. no sesssion was created). If the session is already created (i.e. I'm already connected to my box on another terminal tab), nothing happens.

Can someone suggest on how to go about it?

Thanks


----------



## DutchDaemon (May 19, 2014)

Set something like 
	
	



```
/usr/local/bin/tmux attach || /usr/local/bin/tmux new
```
 in your root shell's .rc file (.shrc, .profile, or similar).


----------



## mrjayviper (May 19, 2014)

Thanks. That worked nicely.


----------



## DutchDaemon (May 19, 2014)

Strictly speaking, you should use 
	
	



```
[ -x /usr/local/bin/tmux ] && /usr/local/bin/tmux attach || /usr/local/bin/tmux new
```


----------

