Mac Terminal Commands Cheat Sheet – Tutorial, Free Download
Posted On May 22, 2022
(Last Updated On: May 22, 2022)
Mac terminal commands cheat sheet is very useful for technical people. What exactly is a Mac command terminal? macOS X has a Unix shell that lets you run advanced command-line utilities. Staff may connect through SSH and run commands remotely to perform things like installing software or updating Macs, making it easier for IT teams to handle macOS computers.
macOS is a superior operating system that puts the user first. There are times, though, when you need to use the terminal! If you’re a novice or inexperienced user, visiting your macOS terminal could make you nervous. While this may be true in some cases, there’s nothing to worry about if you’re cautious.
Mac has several interesting terminal commands. Learn the basic command-line skills that every Mac user and large business that uses and controls Macs should be familiar with. Let’s look at some terminal commands for the Mac.
What Exactly Is A Mac Terminal?
What are the Mac terminal commands? The terminal, often known as the command-line interface, is considered by many to be the Holy Grail of computer management. The command-line interface was formerly the only method to do anything on a computer; but, as PCs became more common, the command line interface gave way to the graphical user interface. Purists among us usually choose to operate the computer and get it to perform tasks using the command-line interface rather than a mouse.
Although the Mac GUI has changed the way we work overtime, many individuals still prefer the command line for its ability to manage and automate tasks, as well as configure Mac features that are only available through the CLI.
Certain terminal characteristics allow users to execute simple or repetitive tasks faster. Among other things, commands can be chained together to increase their utility. There are several terminal commands available for Mac.
Anyone using a Mac after Mac OS X’s initial release in 2001 may utilize the UNIX-based shell via the command line interface via the Terminal software. Open a Finder window and press Command+Shift+U to find this software in the Applications | Utility folder.
Enter commands on the keyboard and click return to run them in the Terminal. The Terminal will respond with any relevant information available once the command has been executed. Let’s have a look at some useful terminal commands for Mac. The following is a list of Mac terminal commands:
1. How to View a Folder’s Contents
When you first go to the command line, you’re in your home folder. You could be intrigued about what’s inside when you’re there or in any folder (the directory in Unix-speak). This is done with the ls command. You may retrieve a list of the folders in the current directory by typing ls and pressing Return.
The basic ls command just displays the names of files and folders in the current directory as its output. Fortunately, you can extend the ls command with a number of additional parameters to see more data.
Don’t get too caught up in the details just yet—we’re only getting started. The idea is that ls may provide more information about files and directories depending on the settings you choose. That extra information in this case comprises the name of the user who owns each directory item.
The user roman empire, who is a member of the group staff, has the majority of those products above, as shown by the roman empire staff emblem next to them. A visible piece of information next to each file and folder is the date and time it was last modified. Another option is to use ls -a to see files that are hidden.
2. Install Dashboard Widgets on your computer’s desktop
I always forget about the Dashboard on my Mac. In fact, I seldom believe it is necessary. However, I believe this is mostly owing to the fact that the widgets are hidden deep within the operating system. Use the following command to be able to drag Dashboard widgets to your desktop:
Defaults write com.apple.dashboard devmode to drag a widget onto your desktop. YES
Click and hold it, then press F12 to remove it from the Dashboard and drag it to the desktop. Your widgets now float above open apps, similar to the Gadgets feature in Windows 7. Simply replace YES in the previous command with NO to deactivate this feature. Regrettably, you’ll have to log out and then log back in.
3. Deleting DNS Cache
Have you ever visited a website that had been updated or moved servers, but your Mac still sent you to the old site? This is commonly caused by your computer’s DNS cache becoming out of date and failing to update with new domain resolution. Fortunately, you can easily resolve this issue by clearing your Mac’s DNS cache and asking it to request names from a remote DNS provider instead.
To do so, look up your macOS version and perform the appropriate command.
The sudo keyword is used in these instructions, which means you must first supply your macOS user account password before running the program. Enter your password and press return when prompted. These instructions will delete your Mac’s DNS cache and start repopulating it on all subsequent domain lookups after they’ve been done.
4. How to Turn Off
You have more options and flexibility when you shut down your Mac using Terminal than when you use the Apple menu or the power button. This is how it’s done!
To get started, open Terminal. Press Command+Space to open Spotlight Search, then type “terminal” and choose it from the results.
Now that the terminal is open, you may shut down your Mac. Otherwise, you’ll get the error message shown below if you don’t use the “sudo” command.
The sudo command offers you superuser security access by default.
Use the following command to switch off your Mac:
sudo shutdown -h <time>
Replace time> with the desired shutdown time for your Mac. Type now if you want to do it right now. If you want it to shut down in an hour, type +60.
When prompted, enter your password and hit enter.
Your computer will now shut down when you want it to.
5. Caffeinating your Mac to prevent it from shutting off
You may use the Terminal command caffeinate: to stop a long-running procedure on your Mac that cannot be interrupted by putting it to sleep.
caffeinate -u -t 3600
You can set a time in seconds for which you do not want your computer to sleep when you use this software. After that, the command will start counting down the time and prevent your Mac from napping during that time.
6. How to Tell How Long Your Mac Has Been Running
The period of time since a computer was last rebooted or started up is called “uptime.” Mac uptime may be remarkable since Macs are extremely stable and OS X users seldom have to restart their computers. We’ll show you how to find out how to check the uptime and reboot history of any Mac.
Here’s how to use OS X’s Command-Line to check the uptime in days and restarting history, as well as how to use the system Information profiler to get the ‘time since startup’ on a Mac.
7. How to Get the File
Copy the URL to your clipboard the next time you want to download a file, then open a Terminal window and type the ‘curl’ command.
Curl is a simple tool for downloading files, with the following syntax:
curl -O [filenameURL]
The file destination URL for the web should begin with HTTP. By default, this downloads the requested URL to the current working directory, with the saved file having the same name as it did on the remote server. For example, if the file on the remote server is named “filename.zip,” the name will be the same when it downloads.
8. What To Do If Your Mac Totally Freezes
Overworked computers have a tendency to freeze. You may think that throwing enough money at a computer will keep it from freezing, but this is not the case. A system will ultimately freeze if it is subjected to a high number of resource-intensive operations. A system with more capable hardware can definitely perform more activities, but it may also bring the system to a halt.
On the terminal, type the following command. You’ll be prompted for the administrator’s password. If you do this, the system will be set to automatically restart if it freezes.
sudo systemsetup -setrestartfreeze on
To turn this off, open Terminal and type the following command. You’ll need to input the admin password to execute it, just as before. If you use it, your system will no longer automatically restart if it freezes.
sudo systemsetup -setrestartfreeze off
9. Password Protection And Folder Compression
You should utilize password security while compressing a sensitive folder to prevent unwanted access to its contents. This will necessitate the use of a terminal.
To begin, change the Terminal directory to the folder that contains the compressed files. Enter the following if it’s on the desktop, for example:
zip -er <output folder name.zip> <source folder name>
How To Change The Format Of A Screenshot
To change the default file format on a Mac, you must use the Terminal.
Execute the following command in the terminal and press enter to convert from.png to.jpg.
Take a snapshot to confirm the update. To do so, press Command + Shift + 3, which will take a full-screen screenshot and save it in.jpg format to your desktop.
Use the following commands at the terminal to change the file format.
To change to gif
defaults write com.apple.screencapture type gif;killall SystemUIServer
To change to pdf
defaults write com.apple.screencapture type pdf;killall SystemUIServer
Terminal Commands Mac Cheat Sheet
Mac Terminal Commands Ipconfig
Commands at the terminal A network command is mac ipconfig. The ipconfig software is available for both Windows and Mac OS X, however, unlike the Windows version, it is not the ideal tool for changing network settings. List information about your current network configuration, on the other hand, could be useful. Let’s have a look at some network mac terminal commands.
In the terminal, type ipconfig to get a list of all available commands, including:
Use the command ipconfig getifaddr deviceid to see your current network IP address. Replace deviceid with the correct network device id (eg. en0). Use networksetup -listallhardwareports if you’re not sure what this is.
Use the command ipconfig getoption deviceid domain name server to see your current network DNS server.
Commands for the Mac Terminal Cd
Simply locate the folder you want to transfer to in the Finder and double-click it. Instead, use the command line’s cd (or change directory) command. Assume you’re in your Home folder and wish to go through your downloads. To do so, put cd downloads into the search box. The contents of your downloads folder will then be seen by ls. This is a fundamental Mac terminal command.
Mac Terminal Commands To Speed Up
Reducing the amount of superficial visual candy provided by macOS is a common way to improve productivity. The use of animation to shrink the size of an open window so that it fits in the Dock is one example. This type of animation does not require as much computational power as, example, creating a complex effect in Photoshop. If your Mac is busy trying to render new photographs in your favorite image editing software while you’re working in your favorite database app, adding the resources necessary to animate a window might cause your Mac to slow to a crawl. This is a great terminal command for Mac.
The network setup program gives you a lot of information about your current Mac network configuration. It can help you find information such as your computer’s name, IP address, current WiFi network, and other details. You may use it to change settings, as the name suggests, but we still prefer to utilize System Preferences.
You may examine a comprehensive list of potential Mac terminal network commands by typing networksetup -help at the terminal. The help menu will appear, with multiple examples of how to use the tool to see and alter various network settings.
Terminal Commands for Mac Recovery Mode
On a correctly booted Mac, the terminal software is located in the /Applications/Utilities/ folder, and it may be reached directly through the folder hierarchy or by searching for and starting the Terminal app with Spotlight. Recovery mode, on the other hand, loses access to the application directory, as well as Spotlight and Launchpad. Getting to the terminal from recovery boot mode is straightforward.
At startup, hold down the Command and R keys to enter Mac OS Recovery Mode as usual.
Select a language as normal.
On the “macOS Utilities” screen, pull down the “Utilities” option from the top of the screen.
While in Recovery Mode, select “Terminal” to open the Terminal app.
More commonly, we should use the fundamental terminal commands mac. Seriously. It’s a feature of the macOS operating system that’s sometimes overlooked. Mac terminal commands are entertaining. However, there are so many useful MacOS Terminal commands that the capability is quite beneficial. It might be intimidating to try to utilize it if you are a newbie.
Hollywood promotes the idea of brilliant hackers spewing technobabble while shutting down the major power grid while under terrorist assault. It may also be used for more relaxing activities like customizing your Mac and learning how to use time-saving shortcuts.