Nov 02, 2017 The MacOS terminal can be a bit intimidating, but we're here to help. Here's a guided tour of the four most useful MacOS terminal commands.
- Common Commands For Macos Terminal 7
- Common Commands For Macos Terminal 2
- Macos Command Line Tool
- Common Commands For Macos Terminal 8
- Commands For Terminal Mac
If you’re working in Terminal on your Mac, you need to know the most important UNIX commands: those that work with directories, those that work with files, and miscellaneous but commonly used commands.
Folders are called directories in UNIX. Commands that refer to filenames, as most do, assume that you’re talking about files in the working directory. When you open the Terminal window, the working directory is set to your home directory, abbreviated ~. Bash shows you the current working directory and your username to the left of its prompt. The following table lists common directory-related commands.
Command | What It Does |
---|---|
ls | Lists the names of the files in the working directory. For more complete information, use ls –alF (. |
cd directoryname | Changes the working directory to the one you named. |
cd .. | Brings you up one directory level. |
cd | Returns you to your home directory. |
pwd | Displays the pathname of the current directory. |
mkdir newdirectoryname | Makes a new directory. |
rmdir directoryname | Removes (deletes) an empty directory. |
As in Windows, you can redirect the output of a command to a text file. So if you want a record of the files in a folder, type cd, followed by a space, drag the folder’s icon to the Terminal window, and press Return. Type ls > mydirectorylist.txt and press Return again. A file named mydirectorylist.txt will appear in the folder you chose. You can open the file in TextEdit to see a list of the files in that directory.
This table lists commands commonly used when working with files in the Terminal window.
Command | What It Does |
---|---|
cp filename1 filename2 | Copies a file. |
chmod | Changes permissions for access to a file. Study the man page before using this one. |
diff | Compares two files line by line (assumes text). |
more filename | Displays a text file one page at a time. Press the spacebar to see the next page; press Q to quit. The man command works through more. |
mv filename1 filename2 | Moves a file or changes its name. |
rm filename | Removes (deletes) a file. |
This last table explains other handy commands that anyone getting started in Terminal will likely want to know.
Command | What It Does |
---|---|
Control+C | Terminates most operations. |
date | Displays the current date and time. |
echo | Repeats whatever appears after the command (after expansion). |
help | Displays a partial list of bash commands. |
history | Displays the last commands you typed. You can redo a command by typing an exclamation point (!) followed immediately (no space) by the number of that command in the history list. To repeat the last command, type !!. To repeat the last filename, type !*. |
pico | A simple UNIX text editor. |
ps | Displays a list of running processes. |
sudo | Lets you carry out commands for which the account you are using lacks authority. You will be asked for an administrator’s password. |
When you’re working in Terminal, you don’t have a Trash Can to which deleted files are moved pending ultimate disposal. Delete it, and it’s gone. In general, UNIX has no Undo function.
The MacOS Terminal is an often-neglected and overlooked feature. But there are so many cool Terminal commands you can use that makes the feature insanely useful.
If there is one piece of advice I can give to all macOS users, it is this: Use the Terminal more. Seriously. It is an often-neglected and overlooked feature on the macOS system. But there are so many cool MacOS Terminal commands you can use that makes the feature insanely useful.
It can be quite intimidating trying to use it if you are a newbie. Hollywood keeps pushing the stereotype of the Terminal window being used by hacker geeks spouting techno-babble while shutting down the main power grid, while under heavy gunfire by terrorists. But it can also be used for more peaceful means such as customizing your Mac and using time-saving shortcuts.
![App App](/uploads/1/2/6/5/126567174/807127734.jpg)
After trying out loads of commands, here are the ones I liked the most.
![Macos Macos](/uploads/1/2/6/5/126567174/546316773.jpg)
13 Cool MacOS Terminal Commands To Try Out
I’ve excluded all the really geeky and techie ones. Instead, I am focusing on ones which are straightforward and useful. To open up the Terminal window, go to your Applications folder then “Utilities.” You will then find the Terminal.
View Hidden Files & Folders
As with Windows, macOS hides all folders which are essential to the running of the system. By hiding them, there is no chance of you accidentally deleting a system-critical file and crashing your entire Mac.
But some files and folders do sometimes need to be seen. For example, on a USB stick, caches and thumbnails are usually hidden and they can take up quite a big part of the storage space. The only way to get rid of them, short of reformatting the stick, is to view the hidden files.
In a Terminal window, type :
then type:
Now you will see all of the hidden files. But be careful what you delete. If in doubt, leave it alone.
To hide them again, repeat the command but replace TRUE with FALSE.
Download Files From The Internet Without a Browser
If you need to download a file from the Internet, you don’t always need to open a browser. You can also download it through the Terminal.
We have previously mentioned Homebrew which allows you to download software via the browser. There is also YouTube-DL where you can download YouTube videos via the Terminal as well (I love YouTube-DL).
But you can also download various bits and pieces online if you have the direct download link. First, specify which folder you want it downloaded to. I have set it to the Downloads folder but you can change it to whatever you want.
Then to download the file, type :
Keep Your Mac Awake
There are various apps available for disabling the sleep function on a Mac. The one I use is the highly-rated free app Amphetamine. But if you are averse to installing lots of apps, there is actually a Terminal command you can use instead. Simply type:
This will stop your Mac from going to sleep. When you want it to finally close its digital eyes, you can relieve its suffering by pressing the CTRL + C buttons.
Play Tetris
I absolutely love Tetris. I can spend hours playing it. So I was delighted to learn there is a secret Tetris game hidden away on the Mac.
In the Terminal, type :
Hit enter. Now tap the Fn and F10 keys together at the same time. Press the t button then the g button.
Finally, you will see this. Choose your game and it will start.
Make Your Mac Sound Like An iPhone When Plugged Into Juice
This is not really a useful one. But if you like the sound of your iPhone, you can now have your Mac make iOS beeps when you plug it into the power.
Tell Your MacOS To Check For Updates More Often
It’s common-sense computer security to update your Mac often. But a lot of people frequently overlook it and take forever to download critical patches and updates. If this sounds like you, you can flip the finger to your Swiss cheese brain and instead tell your Mac to check for updates more often.
To tell it to check every day, just type:
Change Where You Get Screenshots Sent To
In this line of work, I do a LOT of screenshots. When I bought my current Macbook a couple of years ago, it started sending all my screenshots to the desktop. It irritates the hell out of me as I like to keep a clean desktop. But there is a way to change the default screenshot location.
Just type the following, replacing /your/location/here with the path to the folder you want to change it to.
then type :
Create a New Default Name For Screenshots
Other cool screenshots one is changing the default name for a screenshot that the Mac makes.
Usually, the Mac writes it like this – Screen Shot 2018-09-11 at 20.00.46.png – but that is so unwieldy and ugly looking. But fear not. You can change it to whatever you want.
then type :
Change What Format You Make Your Screenshots
At this point, you’ve probably decided I’ve declared Holy War on screenshots. But I promise this is the last one I’ll do on it. As well as changing the default name and location, you can also specify what file format you want them in.
Usually, I do them in PNG format but a lot of my clients actually detest PNG. Instead, they want JPG. So since they are paying my bills, they get to decide what format my images are in. You can, of course, change it to whatever you want – GIF, BMP, or God forbid, TIFF.
Common Commands For Macos Terminal 7
Kill The Dashboard
When was the last time you used the Dashboard? Yup, me neither. In my opinion, there is absolutely no use for it and should be scrapped by Apple. But until they do get around to making it extinct, you can disable it instead.
then type:
Add a Gap Between Apps In The Dock
Common Commands For Macos Terminal 2
This is one I really like because it brings a little bit of order to my Dock. It enables you to put blank spaces in the Dock so you can “separate” app icons and look as if they are grouped together.
then type:
View Your Entire Download History – And Wipe It
Privacy enthusiasts (and illegal downloaders) will be horrified to hear this one. Your Mac keeps meticulous records of every file you download. So the next time the Music Police come knocking on your front door, don’t bother protesting your innocence. Your Mac will snitch on you.
Macos Command Line Tool
But you can get the last laugh. To view the entire list, type:
Common Commands For Macos Terminal 8
To delete all the incriminating evidence, type :
If you now type the first command again, the list should be blank.
Shut Down The Mac
Finally, when it’s time to go to bed, do your Mac a favor and let it go to sleep too.
Or if it’s the middle of the day, and you need to restart your Mac, type :
Conclusion
Commands For Terminal Mac
Do you have any favorite Terminal commands that I haven’t covered here? Let us know in the comments.