Part 1. Background
Part 2. Getting Set Up
Part 3. Using tmux
Part 4. Use tmux, Exit AWS, Log back in to AWS
Part 5. tmux: Summary of Primary Commands
- Lets you tile window panes in a command-line environment.
- This in turn allows you to run, or keep an eye on, multiple programs within one terminal.
- 🔑 With tmux, you can leave scripts running for a while, and it doesn’t matter if the terminal closes or you lose your internet connection for a moment; the script is running in the background
Tmux: A Gentle Introduction to tmux by Alek Shnayder
- Installation
- Getting In & Getting Out
- Managing Panes
- Custom Themes
Note 1: I am using fastai deep learning AMI
Note 2: tmux is already installed.
Note 3: On the fastai AWS AMI, tmux mouse mode is enabled, so hold down shift while selecting to copy to your local clipboard.
Note 4: If tmux is not installed:
- Mac: brew install tmux
- Linux: sudo apt-get install tmux
- see the Resource above for instructions
Note 1: Log into AWS Console and check that instance is running
Note 2: Ensure I am in the appropriate directory
pwd
/Users/reshamashaikh/.ssh
my syntax for logging in
ssh -i aws_fastai_gpu.pem [email protected] -L8888:localhost:8888
my example
ssh -i aws_fastai_gpu.pem [email protected] -L8888:localhost:8888
The authenticity of host '54.164.78.42 (54.164.78.42)' can't be established.
ECDSA key fingerprint is SHA256:RoHkdmFaS+2/w/9CGncGb4cPO3lUutStxQ7BACCzopI.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '54.164.78.42' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1039-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
5 packages can be updated.
0 updates are security updates.
(fastai) ubuntu@ip-172-31-10-243:~$
sudo apt-get update
my example
(fastai) ubuntu@ip-172-31-10-243:~$ sudo apt-get update
Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:5 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu xenial InRelease
Reading package lists... Done
(fastai) ubuntu@ip-172-31-10-243:~$
tmux -V
my example
(fastai) ubuntu@ip-172-31-10-243:~$ tmux -V
tmux 2.1
tmux ls
my example
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
error connecting to /tmp/tmux-1000/default (No such file or directory)
Note: right now, I have no tmux sessions running.
tmux
Note: A green bar will appear at the bottom
tmux ls
- hit ctrl and b at the same time and then let go
- then type subsequent command
example for creating two stacked windows
ctrl and b (at same time)
%
ctrl+b ?
ctrl+b "
ctrl+b %
Note: type ctrl+b then let go, and then type %
ctrl+b [then arrow up/down/side]
ctrl+b
🔑 This is the key prompt for using tmux.
ctrl+b x
This will detach the current session and return you to your normal shell. You can exit AWS with tmux running in background, and ssh
into the instance again.
ctrl+b d
tmux ls
my example
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
0: 1 windows (created Sat Nov 11 15:31:41 2017) [159x38]
(fastai) ubuntu@ip-172-31-10-243:~$
tmux a -t 0
tmux ls
tmux kill-server
tmux ls
my example
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
0: 1 windows (created Sat Nov 11 15:31:41 2017) [159x38]
(fastai) ubuntu@ip-172-31-10-243:~$ tmux kill-server
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
no server running on /tmp/tmux-1000/default
(fastai) ubuntu@ip-172-31-10-243:~$
tmux ls
tmux
tmux ls
exit
my example
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
no server running on /tmp/tmux-1000/default
(fastai) ubuntu@ip-172-31-10-243:~$ tmux
[detached (from session 0)]
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
0: 1 windows (created Sat Nov 11 15:52:31 2017) [159x38]
(fastai) ubuntu@ip-172-31-10-243:~$
(fastai) ubuntu@ip-172-31-10-243:~$ exit
logout
Connection to 54.164.78.42 closed.
ssh -i aws_fastai_gpu.pem [email protected] -L8888:localhost:8888
tmux ls
my example
(fastai) ubuntu@ip-172-31-10-243:~$ tmux ls
0: 1 windows (created Sat Nov 11 15:52:31 2017) [159x38]
(fastai) ubuntu@ip-172-31-10-243:~$
Note: The tmux session is still running!