Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have rdist set up to push out some of my dot files to all the remote machines that I need to ssh into. I also have zsh as my default shell on all of those machines.

When I ssh into a machine and then exit, the screen is cleared. I find this behavior bothersome. My attempt to prevent this behavior was to comment out the /usr/bin/clear line in my .logout file. I then dist'd this updated file out to all the remote machines.

The trouble is, that didn't work. I am unsure about this, but I thought .logout was for csh, but I don't have a .zlogout (or .bash_logout either, for that matter). There's nothing in any of my other dot files (e.g., .zshrc, .zshenv) that seems like it would cause the screen to clear. When I ssh into a remote machine, then exec zsh (in order to get a "fresh" shell session), then the terminal will not clear upon exiting the ssh session. But otherwise, the problem persists - on any machine that I connect to, the screen clears upon exiting.

For what it's worth, I don't appear to have the same problem when I set my default shell on the remote machines to bash. So I assume the problem is with zsh.

I checked the dot files to make sure they got dist'd correctly (they did). Aside from this, I'm running out of ideas... why does my terminal keep getting cleared when exiting ssh?

edit: I found the source of the problem: There is a /etc/zlogout file on many of the remote machines. I don't have sudo privileges on many of these machines and I don't want to globally affect users; is there a way to override the functionality in /etc/zlogout? Simply making a $HOME/.zlogout file doesn't seem to work.

share|improve this question
I found kind of a hackish way to do what I want. I simply made clear an alias to "" in my .zlogout file. That way when the clear command in /etc/zlogout is called, nothing happens. – jayhendren Apr 2 '13 at 22:38
Sorry, totally missed the part about your ~/.zlogout file. I'll delete my answer and you can add your own. – depquid Apr 3 '13 at 16:15
If you turned your "edit" into an answer I would accept it, this has bothered me for a long time too. – Ken Williams Aug 20 '13 at 17:21
up vote 3 down vote accepted

Zsh on RHEL 7 behaves the same a way, i.e. during ssh logout the terminal is cleared.

(Depending on the terminal the last terminal output is lost, or it is just scrolled out of view.)

This is because of /etc/zlogout - which is part of the zsh package - is containing:


(it does not contain other commands)

You can override this clearing in your own .zlogout file via completely disabling the reading of /etc/zlogout during logout:

$ cat ~/.zlogout
setopt norcs

Disabling the rcs option disables the sourcing of certain run control files - probably hence the name: no Run Control Sourcing

share|improve this answer
You can also alias clear="" in ~/.zlogout, though I think your solution is much cleaner. – jayhendren Dec 8 '14 at 20:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.