الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

clear

Clean the terminal screen (and, by default, the scrollback buffer).

المستوى
لينكس اليومي
المجموعة
الطرفية والمساعدة
يحتاج root
لا
الحزمة
ncurses

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

ماذا يفعل

clear removes all text from the terminal window and puts the prompt at the top. It sends the right control codes for your terminal type (from the TERM variable).

Ctrl+L does almost the same: it clears the visible screen but usually keeps the scrollback. When the terminal shows strange characters after you printed a binary file, reset is stronger than clear.

طريقة الكتابة

clear [-x] [-T TYPE] [-V]

الخيارات 3

الأكثر استخدامًا

-x
Do not clear the scrollback buffer (only the visible screen).
-T type
Use this terminal type instead of $TERM.
-V
Show the version.

أمثلة 11

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

  1. 1Clear the screen

    clear

    The prompt moves to the top of the window.

  2. 2Clear the screen with the keyboard

    # press Ctrl+L

    Faster than typing clear. Works in Bash and most programs.

  3. 3Keep the scrollback, clear only the screen

    clear -x

    You can still scroll up to see older output.

  4. 4Clear the screen before a demo or a screen share

    clear && history -c

    Clean screen and no old commands with internal names or tokens.

  5. 5Fix a terminal that prints strange signs

    reset

    reset sets up the terminal again. Use it after you cat a binary file by mistake.

  6. 6Clear the screen at the start of a menu script

    clear; echo "1) status  2) restart  3) logs"; read -p "Choice: " c

    Each time the menu shows, the old output is gone.

  7. 7Refresh a simple status view every 5 seconds

    while true; do clear; date; systemctl is-active httpd sshd; sleep 5; done

    A tiny dashboard. watch does this better: watch -n5 'systemctl is-active httpd sshd'.

  8. 8Clear for another terminal type

    clear -T xterm

    Rarely needed: when $TERM is wrong for the terminal you use.

  9. 9Use the tput way in a portable script

    tput clear

    Same result; tput can also set colors and move the cursor.

  10. 10Clear the screen and the scrollback in a jump host session

    clear && printf '\e[3J'

    Some terminals keep the scrollback; the extra code removes it too. Good after showing secrets.

  11. 11Make an alias that clears and lists

    alias cls='clear; ls -l'

    Personal shortcut; put it in ~/.bashrc.

انتبه

  • clear does not remove anything from your shell history or from log files. It only cleans the window.
  • Some terminal programs keep the scrollback even after clear.

نصائح للحفظ

  • Ctrl+L = fast clear. reset = repair a broken terminal.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man clear