Clear screen command linux

6 Commands to Clear Linux Terminal

Sometimes, as you go about running commands on a Linux terminal, you may feel that the terminal is somewhat ‘filled up’ with commands and outputs of those commands. Therefore, you may want to clear the terminal to declutter it and continue from the top once more.

In this tutorial, we are going to outline how you can clear the Linux terminal.

1) clear command

Let’s assume that your terminal is full of commands and output as shown below

Run the clear at the bottom of the terminal prompt.

Results

The terminal screen gets cleared as shown below

2) reset command

Just as in the example above, you need to run reset command at the bottom of the terminal to clear the screen as shown.

Results

As shown below, the terminal has been re-initialized by the reset command.

There’s also the tput reset command which will also do the trick.

3) Using the Ctrl + L shortcut

Another Handy method of clearing the terminal is the use of ctrl+L keyboard shortcut. It will have the same effect as the clear or reset command.

4) Using the printf «\033c» command

Another method one can use is by typing printf «\033c» on the terminal prompt and hitting enter. This will also have the same effect of reinitilaizing the screen.
This can also be defined as an alias through

5) Clearing the Linux terminal for KDE

For a KDE terminal also referred to as Konsole, the following command comes in handy

This can also be aliased as shown

Furthermore, you can use the keyboard shortcut when dealing with Yakauke

6) Clearing the Linux terminal for GNOME — Ubuntu 18.04

For a GNOME terminal, like you would find in Ubuntu 18.04, you can add keyboard shortcuts as shown

Note:

When using the above-mentioned methods to clear the screen, you’ll notice that the screen (putty) is still scrollable. That is one call still scroll up using a mouse or cursor up key to the previous commands and their output. If you want to clear the screen without a scrollback use the command clear && clear :

Conclusion

In this article, we have shown how you can clear the Linux terminal. you are welcome to try out the commands outlined and provide feedback. Thank you.

Источник

Как очистить терминал Linux

Если вы хотите делать снимки экрана терминала Linux или вам хочется чтобы окно терминала перед выполнением команды с очень длинным выводом было пустым, вам понадобиться возможность очистки терминала.

Существует несколько способов это сделать. Можно воспользоваться горячей клавишей, или выполнить несколько команд. Можно очистить только текущий экран или полностью весь вывод. В сегодняшней статье мы расскажем как выполняется очистка терминала в Linux.

Как очистить терминал в Linux

Самый простой способ очистить терминал — воспользоваться сочетанием клавиш Ctrl + L. После нажатия этих клавиш весь уже существующий вывод переместиться вверх, так, что текущее окно терминала будет пустым:

Тем не менее вся история вывода не будет удалена, вы сможете легко получить к ней доступ просто пролистав немного вверх:

Но если вы не будете пытаться листать историю, окно будет чистым. Если этого вам мало, вы можете воспользоваться командой clear. Она полностью очищает вывод и к предыдущему выводу вы уже вернуться не сможете:

Для того чтобы утилита clear не очищала полностью историю вывода, доступную при прокрутке, а работала аналогично сочетанию клавиш Ctrl+L используйте опцию -x:

Но и у этой команды есть одна проблема. Если вы по ошибке вывели содержимое двоичного файла, ваш эмулятор может быть сломан. Все вводимые вами символы могут превратиться в кракозябры, а приглашение ввода вовсе перестанет работать. Такое происходит потому что в двоичных файлах могут случайно встретиться какие-нибудь управляющие последовательности, ломающие работу терминала.

В такой ситуации команда clear не поможет, здесь нужна команда reset:

Она сбрасывает терминал полностью, не только предыдущий вывод, но и любые настройки, заданные с помощью управляющих последовательностей. После её выполнения вы получите чистый терминал.

Как видите, очистить терминал Linux очень просто. А какие способы знаете вы? Напишите в комментариях!

Источник

How to Clear Terminal Screen in Ubuntu and Other Linux Distributions [Beginner’s Tip]

Last updated October 27, 2020 By Abhishek Prakash 11 Comments

When you are working in the terminal, often you’ll find that your terminal screen is filled up with too many commands and their outputs.

Читайте также:  Grub rescue как загрузить windows

You may want to clear the terminal to declutter the screen and focus on the next task you are going to perform. Clearing the Linux terminal screen helps a lot, trust me.

Clear Linux terminal with clear command

So, how do you clear terminal in Linux? The simplest and the most common way is to use the clear command:

You need no option with the clear command. It’s that simple but there are some additional things you need to know about it.

The clear command and other methods of clearing screen may depend on the terminal emulator you are using. Terminal emulator is the terminal application that you use for accessing the Linux shell (command line).

If you use clear command on Ubuntu with GNOME Terminal, it will clear the screen and you won’t be able to see what else you had on the screen previously.

In many other terminal emulators or Putty, it may just clear the screen for one page. If you scroll with mouse or PageUp and PageDown keys, you can still access the old screen outputs.

Frankly, it depends on your need. If you suddenly realize that you need to refer to the output of a previously run command, perhaps having that option available will be helpful.

Other ways to clear terminal screen in Linux

Clear command is not the only way to clear the terminal screen.

You can use Ctrl+L keyboard shortcut in Linux to clear the screen. It works in most terminal emulators.

If you use Ctrl+L and clear command in GNOME terminal (default in Ubuntu), you’ll notice the difference between their impact. Ctrl+L moves the screen one page down giving the illusion of a clean screen but you can still access the command output history by scrolling up.

Some other terminal emulators have this keyboard shortcut set at Ctrl+Shift+K.

You can also use reset command for clearing the terminal screen. Actually, this command performs a complete terminal re-initialization. It could take a bit longer than clear command, though.

There are a couple of other complicated ways to clear the screen when you want to clear the screen completely. But since the command is a bit complicated, it’s better to use it as alias in Linux:

You can add this alias to your bash profile so that it is available as command.

I know this was a pretty basic topic and most Linux users probably already knew it but it doesn’t harm in covering the elementary topics for the new Linux users. Isn’t it?

Got some secretive tip on clearing terminal screen? Why not share it with us?

Like what you read? Please share it with others.

Источник

6 команд для очистки терминала Linux

Иногда, когда вы запускаете команды на терминале Linux, вы можете почувствовать, что терминал несколько «заполнен» командами и выводами этих команд.

Таким образом, вы можете очистить терминал, чтобы очистить его и продолжить с вершины еще раз.

В этой статье мы расскажем, как вы можете очистить терминал Linux

1) clear команда

Выполните clear нижней части

Экран терминала очищается, как показано ниже.

2) reset команда

Как и в приведенном выше примере, вам нужно запустить команду reset в нижней части терминала, чтобы очистить экран, как показано.

Есть также команда сброса tput, которая также будет делать этот трюк.

3) Использование the Ctrl + L горячей клавиши

4) Использование команды printf “\033c”

Другой метод, который можно использовать, – напечатать printf “\ 033c” в командной строке терминала и нажать [enter].

Это также будет иметь тот же эффект от повторной инициализации экрана.

Это также можно определить как псевдоним через

5) Очистка терминала Linux для KDE

Для терминала KDE, также называемого Konsole, следующая команда удобна

Это также может быть псевдонимом, как показано

Кроме того, вы можете использовать сочетание клавиш при работе с Yakauke

6) Очистка терминала Linux для GNOME – Ubuntu 18.04

Для терминала GNOME, как и в Ubuntu 18.04, вы можете добавить сочетания клавиш, как показано на рисунке

Shift + ctrl + alt + c

При использовании вышеупомянутых методов для очистки экрана вы заметите, что экран (Putty) по-прежнему прокручивается. Это один вызов, который все еще прокручивается с помощью мыши или клавиши курсора вверх до предыдущих команд и их вывода. Если вы хотите очистить экран без прокрутки, используйте команду clear && clear:

Стоит добавить, что если вы подключаетесь к терминалу из Windows с помощью putty (или kitty), то, например, Ctrl + L не очистит экран, а просто поставит текущую строку в самый верх окна.
При этом вы всё-ещё сможете использовать полосу прокрутки, чтобы увидеть результат выполнения вызванных ранее команд. А в случае, если результат выполнения команды занимает не одну страницу, то вы опять-таки, скорее всего, запутаетесь в том где начало последнего вызова.
А вот команда clear действительно очищает весь этот “мусор”.

По этой теме понятно /
а вот как писать в Телеграм шрифтом Ижица или slav47
Ищу ищу ещё не нашёль (

Читайте также:  Как посмотреть все файлы mac os

Источник

Clear! (clear your terminal screen)

Administrator

When you’re typing a lot in a terminal and want to clear the screen quickly, you can do so easily a couple different ways.

The one most people know about:

Yeah, simply type ‘clear’.

The one you’ll use a lot more:

(hit the ctrl key, then a lowercase L)

It doesn’t make everything go away, you can actually see everything if you scroll up, but its very handy and I can’t tell you how many times I use it each day.

(really — I can’t tell you, because when you type ‘clear’ you’ll see it in your history, but if you use ctrl-l, it doesn’t make it into history)

JasKinasis

Well-Known Member

Rob, this might be a little advanced for a beginners tutorial, but I feel it is worth mentioning:

The Ctrl-l shortcut only works as a shortcut for the «clear» command if you have readline set to use the default emacs input option. But it doesn’t work if you set the vi input mode — at least not when in edit mode.

I use the following line in my .bashrc, which puts readline into vi input mode:

In the vi input mode, the Ctrl+l keybind is only available when in ‘command’ mode. So you have to hit and then Ctrl-l. Which is not really very helpful. It would also be handy to have it available in ‘insert’ mode too.

The good news is — you can easily add a keybind for Ctrl-l for ‘insert’ mode by adding the following line to your .bashrc:

Either method works. I edited .bashrc because it involved less typing and because I pretty much use bash exclusively.

But if you tend to switch between using different shells.
e.g. Bash, zsh, ksh, csh etc.
Then putting the settings into .inputrc will apply those settings to ANY shell that uses readline. In other words — no matter what shell you are using, your keybinds/settings for readline will always be the same.
Whereas .bashrc only applies to bash.

There are many different bits of functionality and options available in readline. So if there are any key-binds/shortcuts to functionality that you feel you are missing in either vi or emacs mode, you can easily set up a new keyboard shortcut — as I have done for clear-screen in the vi insert mode.

The man page for readline contains a lot of information about the functionality/options that are available.

KarlLinux

New Member

NeoBeum

New Member

Abhijit Mohanty

New Member

I tried both, however, I could scroll up and view the entire commands. [just started linux]

Administrator

I tried both, however, I could scroll up and view the entire commands. [just started linux]

Abhijit Mohanty

New Member

atanere

Well-Known Member

If you want to delete the entire command history, see if this works:

TCRatius

Member

Rob, this might be a little advanced for a beginners tutorial, but I feel it is worth mentioning:

The Ctrl-l shortcut only works as a shortcut for the «clear» command if you have readline set to use the default emacs input option. But it doesn’t work if you set the vi input mode — at least not when in edit mode.

I use the following line in my .bashrc, which puts readline into vi input mode:

In the vi input mode, the Ctrl+l keybind is only available when in ‘command’ mode. So you have to hit and then Ctrl-l. Which is not really very helpful. It would also be handy to have it available in ‘insert’ mode too.

The good news is — you can easily add a keybind for Ctrl-l for ‘insert’ mode by adding the following line to your .bashrc:

Either method works. I edited .bashrc because it involved less typing and because I pretty much use bash exclusively.

But if you tend to switch between using different shells.
e.g. Bash, zsh, ksh, csh etc.
Then putting the settings into .inputrc will apply those settings to ANY shell that uses readline. In other words — no matter what shell you are using, your keybinds/settings for readline will always be the same.
Whereas .bashrc only applies to bash.

There are many different bits of functionality and options available in readline. So if there are any key-binds/shortcuts to functionality that you feel you are missing in either vi or emacs mode, you can easily set up a new keyboard shortcut — as I have done for clear-screen in the vi insert mode.

The man page for readline contains a lot of information about the functionality/options that are available.

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

wizardfromoz

Administrator

Hi @TCRatius and a belated welcome to the site.

A search from our home page under «text editor» just on the words yields close to 200 results, but narrowing it down to in the title — less than 2 pages.

Читайте также:  Сеть под microsoft windows

@Rob’s poll here https://www.linux.org/threads/poll-favorite-text-editor.6/ invites comment, I am going there tomorrow I hope

TCRatius

Member

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Administrator

Hey there TCRatius,

Welcome to the forums — sure, we’d love it if you shared a link to us from another forum.

JasKinasis

Well-Known Member

As the saying goes:
«Necessity is the mother of all invention»

I’ve been using Linux for many years — and I’ve always learnt things as and when I’ve needed to. And I’m continuing to learn. I’m always learning new things.

Any time I have a problem, or want to know how to be able to do something new — I’ve always looked to the documentation.

Now, I know telling people to RTFM is a bit of a cliche, but seriously:
RTFM FTW!

There is a LOT of information in the man and info pages. Reading through it can be time well spent. And if you don’t want to read the entire manual — you could always just search for parts of the manual that you are interested in using the search command.
e.g.
In the man-page viewer, you can press / and enter a regex to search for specific text.

If the documentation is incomplete, or unclear — I will look to the internet for answers. And 99% of the time I manage to find an existing solution without having to post a question myself.

Sometimes it takes a bit of time to find exactly what I need, so a bit of patience and persistence is required. But to me — it’s worth it!

To clear up any misunderstanding that you may have:
My original post has nothing to do with the systems default text editor, or anybody’s preferred editor — it is purely about the default shortcut keys available in Bash via GNU readline — which depends on which input-style readline is set-up to use (emacs or vi).

GNU readline is a command-line utility which is used by various command-line tools to get input from users. This includes shells like bash.

So when you are typing commands in bash — whether you know it or not, you are using readline. And whilst editing commands in bash you can use emacs or vi style keyboard shortcuts. Again, the default for readline is emacs, so whether you knew it or not — in Bash, you’ve had emacs style keyboard shortcuts available to you the whole time. Even if you haven’t been using them — they are there.

When you are using nano (or whatever your favourite command line text editor is) you are using nanos keyboard shortcuts. But when typing commands in Bash, depending on how readline is set up, you will either be using emacs style keyboard shortcuts, or vi-style shortcuts.

In my original post, I was pointing out that Robs suggestion to use «ctrl + l» to clear the screen in the terminal only works «out of the box» if your shell has readline set to its default ’emacs’ input mode.

Personally, I’m a vim user — so I quite like using the vi input mode for readline.

If readline is set to use the vi input mode, you have to press — to switch from vi-insert mode to vi-command mode and then press «ctrl +l» to clear the screen. And it’s a little clunky, having to press and then «ctrl+l».

So for the benefit of other users who use readlines vi option — I demonstrated how to set up a custom keybind for readlines vi-insert mode, which would allow «ctrl+l» to be used to clear the screen whilst editing a command (without having to press first).

WRT .bashrc:
You can edit .bashrc with ANY text editor you like. But the edits specified in my post will only set up a new key-bind for readlines vi-input mode.

Readline doesn’t have a nano input mode. It only has emacs or vim input modes. But if you really wanted to, you could create custom keybinds for any of readlines emacs or vi input modes, that will mimic keybinds/functionality from nano or any other editor.

But, many of nano’s keyboard shortcuts are similar to the emacs shortcuts anyway.
e.g.
ctrl+n = next line,
ctrl+p = previous line,
ctrl+f = next character,
ctrl+b = previous character
etc.

So for a nano user, the emacs input method for readline would probably meet most, if not all of your needs anyway!

I hope I explained all of that clearly enough.
If you have any further questions, fire away!

For reference:
Here is the list of the default keyboard shortcuts for Bash — including the emacs-style «cursor movement» and «editing» keybinds:
https://gist.github.com/michaelcoyote/745d8a6cf293c4bf7e31

Switching to the vi mode would change all of the keybinds in the «cursor movement» and «editing» sections to be more vi-like. The other commands (history, process control etc) are mostly the same.

Источник

Оцените статью