User Tools

Site Tools


linux:linux_tips

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:linux_tips [2023/09/15 18:13]
manu
linux:linux_tips [2023/11/15 18:07] (current)
manu
Line 26: Line 26:
  
 Screen is deprecated into Redhat, now replaced by **TMUX** Screen is deprecated into Redhat, now replaced by **TMUX**
 +
 +https://​www.redhat.com/​sysadmin/​introduction-tmux-linux
 +
 +TMUX is a terminal using a background session, so you can run long process without being disconnected from TIMEOUT (TMOUT)
 +<cli prompt='​$'>​
 +$ tmux
 +</​cli>​
 +
 +{{linux:​tmux01.png?​500}}
 +
 +**For HELP**
 +  You can now run your first Tmux command. For example, to get a list of all commands, you would type:
 +  Ctrl+b ?
 +
 +To start using tmux, type tmux on your terminal. This command launches a tmux server, creates a default session (number 0) with a single window, and attaches to it.
 +
 +You can detach from your tmux session by pressing **Ctrl+B** then **D**. Tmux operates using a series of keybindings (keyboard shortcuts) triggered by pressing the "​prefix"​ combination. By default, the prefix is Ctrl+B. After that, press D to detach from the current session.
 +
 +List you background sessions
 +<cli prompt='​$'>​
 +$ tmux ls
 +0: 1 windows (created Sat Aug 27 20:54:58 2022)
 +</​cli>​
 +
 +Connect to session number 0 (or maybe attach-session ?)
 +<cli prompt='​$'>​
 +$ tmux attach -t 0
 +</​cli>​
 +As you can see, the command continued to run and print messages on the screen. You can type Ctrl+C to cancel it.
 +
 +Satart a session with specific name
 +  tmux new -s Session1
 +
 +TMUX options
 +  * Ctrl+B D — Detach from the current session.
 +  * Ctrl+B % — Split the window into two panes horizontally.
 +  * Ctrl+B " — Split the window into two panes vertically.
 +  * Ctrl+B Arrow Key (Left, Right, Up, Down) — Move between panes.
 +  * Ctrl+B X — Close pane.
 +  * Ctrl+B C — Create a new window.
 +  * Ctrl+B N or P — Move to the next or previous window.
 +  * Ctrl+B 0 (1,2...) — Move to a specific window by number.
 +  * Ctrl+B : — Enter the command line to type commands. Tab completion is available.
 +  * Ctrl+B ? — View all keybindings. Press Q to exit.
 +  * Ctrl+B W — Open a panel to navigate across windows in multiple sessions.
 +
 +then toggle the mouse on (or off) with the command set -g mouse.
 +
 +Using colors:
 +  Change the status bar background color: set -g status-bg cyan
 +  Change inactive window color: set -g window-status-style bg=yellow
 +  Change active window color: set -g window-status-current-style bg=red,​fg=white
 +
 +=== Configure tmux ===
 +
 +You can change the tmux configuration permanently by modifying the tmux configuration file. By default, this file is located at $HOME/​.tmux.conf.
 +
 +For example, the default prefix key combination is Ctrl+B, but sometimes this combination is a little awkward to press, and it requires both hands. You can change it to something different by editing the configuration file. I like to set the prefix key to Ctrl+A. To do this, create a new configuration file and add these lines to it:
 +<cli prompt='​$'>​
 +$ cat $HOME/​.tmux.conf
 +# Set the prefix to Ctrl+a
 +set -g prefix C-a
 +# Remove the old prefix
 +unbind C-b
 +# Send Ctrl+a to applications by pressing it twice
 +bind C-a send-prefix
 +</​cli>​
 +
 +Another example
 +<​code>​
 +# Improve colors
 +set -g default-terminal '​screen-256color'​
 +
 +# Set scrollback buffer to 10000
 +set -g history-limit 10000
 +
 +# Customize the status line
 +set -g status-fg ​ green
 +set -g status-bg ​ black
 +</​code>​
 +
 +=== Screen ===
 +
 +//Only for historic info//
  
 Screen (command) is a background terminal, you can start applications in background, quit your windows and recall your session. Screen (command) is a background terminal, you can start applications in background, quit your windows and recall your session.
linux/linux_tips.1694794395.txt.gz · Last modified: 2023/09/15 18:13 by manu