Server Fault is a question and answer site for system and network administrators. 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

Okay, this is a last attempt to see if I can salvage something I accidentally did.

I accidentally did "command > ~/.profile" instead of "command >> ~/.profile" on my computer.

I didn't have it version controlled (never happening again), and since the .profile wasn't open in an editor at the time, I don't have an existing version in any backup file or Vim buffer.

The only thing I can possibly think of at this point is that I still have a terminal session open running the lines that were in the ~/.profile file prior to my mistake above. My question is: Is there any way to get the currently executed source?

Maybe to be more explicit and generic, if I run

source ~/.profile

Is there any way to see what got executed in that terminal session outside of looking at the file that was sourced?

Lesson learned though, version ALL your dotfiles.

Thanks in advance.


share|improve this question
up vote 1 down vote accepted

Not that i know of, but depending on what was in there, you can get a good portion of back in the terminal that is still open:

This will get your your prompt definition

$ echo $PS1

This will get you all of your shell variables and defined functions. it may be a LOT of stuff because, in Ubuntu for instance, there are all sorts of other macros for completion and whatnot defined, but you can extract what was yours.

$ set

This will give you your aliases

$ alias

These won't give you any logic that was in your .profile that helped decide how or why to define the things above, but they may get you much of what you need.

share|improve this answer
This was really helpful. A large chunk of what I was hoping to retain is in some combination of the three. Thanks. – Hassan Shahid Sep 18 '13 at 19:19
glad to help :) – jerm Sep 28 '13 at 16:57

You could try the history command in the session that ran the script to get a list of commands that have been recently executed.

share|improve this answer
as far as I can see or tell; history doesn't track anything that was run during terminal session startup/initialization. Thanks for trying to help though. – Hassan Shahid Sep 18 '13 at 20:17

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.