متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 101System · Shell

How to keep a session running with tmux

You start a long job over SSH — a database restore, a big rsync, a system upgrade — and the Wi-Fi drops. Without tmux the job dies with your session. tmux keeps the terminal running on the server: you detach, close the laptop, log in again later and attach to the same screen. This how-to covers the few keys you really need, plus windows, split panes and scrolling.

  • 5 الدروس
  • 5 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

101.1

The quick answer

tmux new -s restore
tmux ls
restore: 1 windows (created Thu Nov 19 10:42:07 2026)
tmux attach -t restore

Inside tmux: Ctrl+b then d = detach (the job keeps running). Everything starts with the prefix Ctrl+b.

الأوامر في هذا الدرس

101.2

Step by step

  1. Install: dnf install tmux / apt-get install tmux.
  2. 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
  1. Detach and come back — even from another computer:
tmux ls
tmux attach -t restore
  1. The keys you need (press Ctrl+b, let go, then the key):
KeysDoes
dDetach (session keeps running).
c / n / pNew window / next / previous.
% / "Split the pane left-right / top-bottom.
arrow keysMove between panes.
[Scroll mode (arrows/PgUp; q to leave).
,Rename the window.
xClose the pane.
  1. A small config — mouse for scrolling and resizing, bigger history:
~/.tmux.conf
set -g mouse on
set -g history-limit 50000
set -g base-index 1
tmux source-file ~/.tmux.conf
  1. Pair work: two admins attach to the same session (same user) and see the same screen — good for guided changes.
  2. 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.)

101.3

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).

الأوامر في هذا الدرس

101.4

Common problems

ProblemCauseFix
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 careYou started tmux inside tmux.Detach the inner one; use windows instead.
Can not scroll with the mouseMouse mode off.set -g mouse on, or Ctrl+b [.
The session is gone after a reboottmux lives in memory.Expected — long jobs over a reboot need a systemd service.
Keys do nothingPrefix not pressed first, or a different prefix in .tmux.conf.Ctrl+b, release, then the key.
Colors look wrongTerminal type.set -g default-terminal "tmux-256color".

الأوامر في هذا الدرس

101.5

Go further

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.

الأوامر في هذا الدرس

كل الأوامر في هذا الفصل