Delete terminal history mac os x

To do this, you can either close the Terminal windows and then remove the history file, or in what is a simpler approach, run "history -c" in the Terminal to clear the history, followed by entering "history -w" to write the now empty history file. These steps will clear the entire history, which may not always be desired, especially if you only wish to remove a single command that perhaps shows the location of a private file or is one you would perhaps not wish to inadvertently run again. To do this, you can remove the history line by number.

All replies

First use the history command by itself to list the entire history or at least enough lines of it to reveal the unwanted command , and then note the identifier number for the command and run the following to remove it from the history:. Have a fix? Post them below or e-mail us! Be respectful, keep it civil and stay on topic. We delete comments that violate our policy , which we encourage you to read.

Discussion threads can be closed at any time at our discretion. Don't show this again. By Topher Kessler. Listing the history The Terminal history will reveal all commands entered in the current session and those from any prior but now closed sessions. These files can be opened with the following two commands among others in a fresh Terminal window: open. Rerunning commands You can rerun prior commands by referencing them from the history. In this example command number 3 ls was rerun.

Mac OSX Terminal (command-line tips and tricks) – Index

For example, if you've tried to open a deeply buried system file only to realize you forgot to include "sudo" to edit it with administrative privileges, then you can rerun the edit command in the following way: sudo!! For example, in the history output you will see a number next to each command that identifies it, and you can run a desired command again by its number:! For example, if you have run a command that begins with "pico" to invoke this editor on a document but since then have changed directory or listed directory contents a few times, you can immediately repeat the command that began with "pico" by the following command:!

Transferring commands The Terminal history will not be written to the history file until you close the current Terminal session, so this approach can be useful for transfering commands from one Terminal session to another.

Switch among programs

To clear out command history, you just need to attach a -c flag to the familiar history command, looking like so:. That command when executed will manually wipe the.

Keyboard shortcuts for Terminal on Mac

The brief video below demonstrates this entire process of clearing command history, the video shows the procedure on Mac OS with the Terminal app, but everything would be the same in other operating systems that support clearing of command line history as well. This should work the same at any bash shell, zsh shell, tcsh, and most other shells, regardless of whether the command line is in Mac OS X or linux, or even Windows linux shell but not a DOS prompt.

Thanks to Ado for the tip idea. If you have any other helpful tips or tricks regarding clearing command history from a Terminal, share them in the comments! Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:. Bash has an instant reverse search function. To search through old commands, press cmd-R and then start typing any part of a command previously used. If the name has an asterisk I highly recommend that you should quote or escape it to make sure there is no ambiguity.

  • half life 2 console commands mac.
  • programa para crear posters en mac.
  • compare mac and windows 8!
  • Using and managing the Terminal history in OS X;
  • wd my cloud slow transfer mac.
  • Terminal Keeps Restoring - Apple Community.

Hi Scott, thanks for the information. Does it maybe get cleared out after an upgrade even a point upgrade?

How To Clear Down Terminal Mac OS X [HD][Guide][Tutorial] 2017

There is a timestamp column in the table that contains numbers that look like Also, if I understood your comment correctly, you could try this command in order to see timestamps of each download entry:. Adding the of days in-between allows datetime to return a valid value. There we go, thank you. Really enjoying the more power user-oriented articles.

Any idea why that might be the case?