How to reset Terminal Command to default state?

Hi,


I have no idea how to use the terminal and I've run a couple of suggested commands which I wish to remove or stop. Is there something I can do to remove or reset the stuff I have typed into the terminal?


[Re-Titled by Moderator]

MacBook Air 13″, macOS 14.0

Posted on Nov 5, 2023 4:00 PM

Reply
4 replies

Nov 7, 2023 1:58 PM in response to u_a04

To provide us with the commands you used, launch the Terminal app. You can use the up arrow key to show the previous commands used one by one, or you can use the following commands to see all the recent history list of the commands used.


If you have a "$" for a prompt, then use this command:

history


If you have a "%" for a prompt, then use this command (note, the last character is the number one):

history  1


If you have the "%" prompt and only use "history", then it will just show about a dozen of the most recent commands (it may be enough), but adding the "1" to the command will show as much history that has been saved which may not be a lot with the default zsh configuration.



As the others have mentioned, you must be extremely careful using the command line since there are no safety nets. Many times the commands you find online may only apply to a very specific case and may need to be modified for someone else or another version of macOS. Some commands may modify a system configuration file, but it may not be immediately obvious what that file may be so even with a backup you may not be able to easily just restore that single file. With some commands, the process can be reversed, but that usually involves knowing the previous value or setting which most sites don't tell you about. If you are making a direct edit to a particular configuration file, then it is best to make a backup copy of that file first since it is very hard to remember its original configuration.


Ideally you should research the command(s) you are using so you can have at least a basic level of confidence it will do what the site tells you. Most times you can use the command line itself to get more information about a particular command and its options. You can do this using the "man" utility which stands for "manual" such as user or instruction manual. For example if you want to know what the "man" command does, you can use the following command:

man  man


If you wanted to understand the "ls" command and its possible options, you would use:

man  ls


Many commands can be be quite technical & very involved containing lots of options. Whenever I find commands online, I will review them and their man pages to make sure I understand exactly what is going to happen with that command and the options suggested. I may not always fully understand, but at least I have a good idea whether it is relatively safe or not. If you are going to use the command line, then I suggest you review a basic tutorial explaining some of the basics which is all you really need to get started.

https://scriptingosx.com/2017/07/first-steps-in-terminal/


Also, with the command line, many times there are multiple ways to perform a task which may all work, but some may be very "dangerous" and frowned upon, while others will be the best & preferred method, plus there may be options in between. Sometimes I will spend an hour reading various articles & forum posts to see the various options....sometimes if you are lucky there will be an actual discussion of the various options so you can learn why some are better than others (I rarely see this with macOS specific commands, but I do see it a lot within the Linux community where command line usage is much higher).

How to reset Terminal Command to default state?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.