Computers, Laptops & Tablets > Apple How to Save Terminal Commands on a Mac Stop typing the same commands every time you need them By Jennifer Allen Jennifer Allen Writer Swansea University, Staffordshire University Jennifer Allen has been writing about technology since 2010. Her work has appeared in Mashable, TechRadar, and many more publications. lifewire's editorial guidelines Updated on August 22, 2021 Reviewed by Ryan Perian Reviewed by Ryan Perian Western Governors University Ryan Perian is a certified IT specialist who holds numerous IT certifications and has 12+ years' experience working in the IT industry support and management positions. lifewire's editorial guidelines Apple Macs iPad Trending Videos Close this video player What to Know Save a one-off command by copying and pasting it to a different document.Create a script by saving the command in TextEdit and using the file extension .command.Terminal automatically saves your recent history within the Terminal window. This article teaches you different ways to save Terminal commands on a Mac so you don't need to retype them frequently and any caveats you need to know about the process. How Do I Save in Terminal Mac? If you want to save a quick command in Terminal for future reference or to put it somewhere else, there's a straightforward, if not particularly technical method, for doing so: the copy and paste commands. Here's how to do so via Terminal. In Terminal, type the command you need to save. Drag your cursor to highlight the command. Right-click on it and click Copy. The command you entered has now been saved to your clipboard and can be pasted elsewhere. How Do You Save a Command in Terminal? If you regularly enter the same set of commands in Terminal, it can be helpful to save them as a script instead so you can initiate it at a click of a file. The process can be a little fiddly at first, but it's a time-saver. Here's how to do so. Terminal commands can be very powerful. Make sure to enter the correct command, so you don't break anything. Open TextEdit on your Mac. Click File > New to create a new file. Enter the command you wish to create a script from. Click File > Save then enter the name as the name of the script followed by .command for the file extension. Click Save. Click Use both. Find the file on your Mac, then press Enter on the file and remove the RTF part of the file name. Open Terminal and type chmod u+x followed by the name of the file location to give the script file permission to run correctly. Double-click the script file to initiate it. The command will now run without you needing to type the command manually. How Do You Save and Exit in Terminal? If you've been entering commands in Terminal and want a quick way to save them for later reference, Terminal already has the functionality built into it. Here's what to do. Open Terminal. Enter the commands you need to use. Close Terminal. Reopen Terminal to find your previous work and commands remain on screen for future reference. How Do I Save Changes in Terminal? Your Terminal session will save anything you've recently entered on the screen, but it's also possible to save a record of everything. Here's how to do so. Open Terminal. Click Shell. Click Export Text As... The contents of your Terminal window have now been saved to your chosen location so that you can consult it at a later date. FAQ How do you open Terminal on a Mac? Select the Launchpad icon from the Dock to open Terminal on a Mac, then type Terminal in the search box. Select Terminal to open the application. Or, type Terminal into Spotlight Search. How do you exit Terminal on a Mac? To exit Terminal, go to the top menu and select Terminal > Quit Terminal. Or, press the keyboard combination Command + Terminal to quit out of Terminal. How do you navigate to a folder in Terminal on a Mac? To access another folder in Terminal, you'll use the cd command. By default, when you open a Terminal window, you're in your Home folder. Let's say you want to move to your Downloads folder. Type cd Downloads (with a space after Downloads) and press Return or Enter. You're now in your Downloads folder. Type ls and press Return or Enter to view the contents of your Downloads folder. Can you find your administrator password in Terminal on a Mac? No, you can't find your admin password, but you can reset it using Terminal. Power down your Mac and then restart the Mac in Recovery Mode. Select Utilities > Terminal, then type reset password. Choose the drive with the administrator account, choose the account, then enter a new password. Enter a password hint, select Save, then power down your Mac and restart it again. Was this page helpful? Thanks for letting us know! Get the Latest Tech News Delivered Every Day Subscribe Tell us why! Other Not enough details Hard to understand Submit