هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
Step by step
- Install:
dnf install tmux/apt-get install tmux. - Start a named session on the server and run your job in it:
tmux new -s restore
pg_restore -j 4 -d shop /backup/shop.dir- Detach and come back — even from another computer:
- The keys you need (press
Ctrl+b, let go, then the key):
| Keys | Does |
|---|---|
d | Detach (session keeps running). |
c / n / p | New window / next / previous. |
% / " | Split the pane left-right / top-bottom. |
| arrow keys | Move between panes. |
[ | Scroll mode (arrows/PgUp; q to leave). |
, | Rename the window. |
x | Close the pane. |
- A small config — mouse for scrolling and resizing, bigger history:
set -g mouse on
set -g history-limit 50000
set -g base-index 1tmux source-file ~/.tmux.conf- Pair work: two admins attach to the same session (same user) and see the same screen — good for guided changes.
- End a session when the job is done:
tmux kill-session -t restore(screen is the older tool with the same idea: screen -S name, Ctrl+a d, screen -r name.)
Check that it worked
Detach, close your SSH connection, log in again: tmux ls still lists the session, and tmux attach shows the job still running (or finished, with its output on screen).
Common problems
| Problem | Cause | Fix |
|---|---|---|
no server running on /tmp/tmux-… | No session exists (or another user started it). | tmux new -s NAME; attach as the same user. |
sessions should be nested with care | You started tmux inside tmux. | Detach the inner one; use windows instead. |
| Can not scroll with the mouse | Mouse mode off. | set -g mouse on, or Ctrl+b [. |
| The session is gone after a reboot | tmux lives in memory. | Expected — long jobs over a reboot need a systemd service. |
| Keys do nothing | Prefix not pressed first, or a different prefix in .tmux.conf. | Ctrl+b, release, then the key. |
| Colors look wrong | Terminal type. | set -g default-terminal "tmux-256color". |
Go further
- Command pages: tmux, ssh.
- Next how-tos: Back up and restore PostgreSQL, Sync folders with rsync, Patch a server with security updates.
- Learn it: tmux in daily DevOps.
1How do you leave tmux without stopping the job?
Detach with Ctrl+b then d; attach again later with tmux attach -t NAME.
2Does a tmux session survive a server reboot?
No — it lives in memory; only SSH disconnects are survived.