Sessions are used to separate out completed unrelated workspaces. One of the sessions started can be for actual company work, while another session can be for our own personal side project. We can keep track of these sessions by names, and close (dettach) and open (reattach) them with their current states saved.
The moment you start Tmux with the
tmux command, you're placed in a session. If you'd like to name the session, use the
$ tmux new -s work
Here, we named our session "work". We can also use the keystroke:
To rename our session to "play", simply by using the
$ tmux rename-session play
Or use the keystroke:
To get a listing of all sessions, type Ctrl-b s or type:
$ tmux list-sessions # Same as: $ tmux ls
work: 2 windows (created Tue Dec 22 14:00:52 2015) [85x24]
Detaching means to save the session, unlike just exiting, which doesn't save. This feature is one of the hallmarks of tmux, and is what makes it persistent. To detach the current session, use the keystroke:
Or the command:
Attaching a session is used to return back to a previous session that you detached from. To re-attach a session, use:
$ tmux attach -t work
The name of the session can be found from the
list-sessions subcommand as shown above.
To switch to a particular session, use either the keystroke:
$ tmux switch -t session_name
To get rid of a session, type:
Probably the coolest feature of sessions is that you can share it with other users, much like a Google Docs file. This means that if two users are SSH'ed into a remote host, and are using the same session, they can see exactly what the other is typing in real-time.
tmux session open, try opening up a new terminal window and attaching that same session.
$ tmux list-sessions
base: 1 windows (created Tue Dec 22 13:04:34 2015) [80x24] (attached)
$ tmux attach -t base
You should now have control of both windows! This won't be of any use alone, so go make some friends and perhaps you guys can have a fun paired-programming session!
Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.$ Check price
Ever feel achy from sitting crunched up on your computer table? Try lying down with these optical glasses that allow you to work on your laptop while lying flat on your back. This is the perfect solution with those with limited mobility or those who wish to prevent neck cramps and back strains.$ Check price