@lizuki Here are some basic screen
commands from the tldr
help page:
- Show open screen sessions:
screen -ls
- Start a new named screen session:
screen -S session_name
- Reattach to an open screen:
screen -r session_name
- Detach from inside a screen:
<Ctrl> + A, D
- Kill the current screen session:
<Ctrl> + A, K
Useful: Send text to a screen even if detached (except in version 5.0.0, it returns a buffer overflow instead):
screen -S <session_name> -X stuff <text>
For example, send "ls -l" to screen s1:
screen -S s1 -X stuff "ls -l\n"
Here \n
adds a newline at the end, effectively pressing enter after a command.
While we're here, I might as well do the same for tmux
.
Again, some basic tmux
commands from its tldr
page:
- Start a new session:
tmux
- Start a new named session:
tmux new -s name
- List existing sessions:
tmux ls
- Attach to the most recently used session:
tmux attach
- Detach from the current session (inside a tmux session):
<Ctrl>-B d
- Create a new window (inside a tmux session):
<Ctrl>-B c
- Switch between sessions and windows (inside a tmux session):
<Ctrl>-B w
Some more cool commands:
- Attach a specific session:
tmux attach -t <session_name>
- Split the session vertically:
<Ctrl>-B %
- Split the session horizontally:
<Ctrl>-B "
- Send text to a session, even if detached:
tmux send -t <session_name> <text>
- Send command to a session, even if detached:
tmux send -t <session_name> <command> ENTER
tmux send -t s1 "ls -l" ENTER
Finally, tmux
will automatically complete partial commands. For example, instead of using
tmux attach-session -t <session_name>
You can shorten it like so:
tmux attach -t <session_name>
tmux a -t <session_name>
Of course, there is a lot more information on both of their manpages.