Command Lines For Mac Terminal



The command line is a text interface for your computer. It’s a program that takes in commands, which it passes on to the computer’s operating system to run. From the command line, you can navigate through files and folders on your computer, just as you would with Windows Explorer on Windows or Finder on Mac. The commands you enter during a session are saved so you can repeat a previously used command without retyping it. In the Terminal app on your Mac, press the Up Arrow key. The last command you entered appears on the command line. Continue pressing the Up Arrow key until you see the command you want, then press Return.

Command Lines For Mac Terminal
  1. Terminal 101: Using the Find Command By MacLife 02 April 2012 Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application.
  2. Restart computers using Terminal on Mac. To restart a computer now or at a specific time using Terminal, you can use the shutdown command or the systemsetup command. The following examples show some ways to use these commands, but for complete information about them, see the shutdown command man page and the systemsetup command man page.

In my previous guide, I have shared four methods of renaming a file or a folder, in that guide I have discussed a little bit about renaming via command line. In this guide, we will discuss it in detail. The command we will use for this is: mv. The mv command not only renames your file/folder, it can change the location of your renamed file if you wish to do so.

Let’s get familiar with the syntax of mv command first:
If the file or folder you want to rename is in the current working directory(to check your current working directory just type pwd on terminal and hit return):

If the file or folder you wish to rename is not in the current working directory then you need to provide the full file name.

Renaming a file via command line

Command lines for mac terminal download

Steps are as follows:

1. Type mv then open Finder and drag the file on terminal (this is to copy the full path of file to the terminal)
Note: Please do note that while dragging the file to terminal, make sure that the finder window and terminal window don’t overlap else this trick won’t work.

2. Now you need to give the new file name, here you have two options based on where you want your new file to be. If you want your new file at the same location then type the same full path (or you can drag the file again and just edit the file name) with the new file name. The full command will look like this:

If you want your renamed file at different location then instead of copying the same full path again just type the new file path with file name. This operation will change the file name as well as change the location of your file.
For example:

Now the renamed file would be moved from TheMacBeginner folder to the Documents folder.

Terminal is a built-in tool for macOS, but not all Mac users are aware of its usefulness. It is a powerful command-line interface and can be used to do a lot of things on your Mac device without stress. With Terminal, all you have to do is simply input a command to get the desired output on your Mac.

Terminal Commands

Contents

Terminal
  • 2 Commands for Terminal
  • 3 Final Verdict

Setting up Terminal Commands on Mac

Before you can start using Terminal commands, you need to first locate the command prompt on your Mac device. Locate the prompt by taking the following steps:

  1. Open a Finder window or double click on the Macintosh HD icon.
  2. Find and open the Applications folder.
  3. After that, double click on Utilities.
  4. Here, you will find the Terminal. Click on Open the Terminal.

After doing this, it will take you to a window that shows the name of your PC, your username, and a dollar sign ($). All the terminal commands discussed below can be typed into the command prompt. Press the return key to go back to the command prompt.

Commands for Terminal

Mac users who do know about the built-in feature are occasionally hesitant to use Terminal. Any typo in your command could cause damage to your macOS. As long as you are careful and double-check your work, however, you should have no problem.

Here are some basic Terminal commands that you can use on your Mac device.

Check The Server Response

Ping is one of the most useful Terminal commands with which every Mac user should be familiar. This command will help you check the server response speed of domains and IP addresses. To perform this command, type into the command terminal ping [insert URL or IP address].

Keep Your Mac From Falling Asleep

Many Mac users do not know that there is a command you can use to keep your Mac awake or “caffeinated” for a certain amount of time before it goes into sleep or screensaver. To set this command type caffeinate –t 200000 into the command terminal. The command means that your Mac will stay awake for 200,000 seconds.

Command Lines For Mac Terminal Linux

Show or Hide Files

Sometimes you might be looking for a file that is hidden on your Mac. You can use the following command to find their location on your system. To show all hidden files on your Mac device, type as follows: defaults Write com.apple.finder AppleShowAllFiles –bool TRUE. Directly underneath, type killall Finder.

This command will bring out all hidden files on your Mac and allow you to either edit or delete them. You can also decide to hide these files again by simply replacing the TRUE with FALSE.

Command Lines For Mac Terminal

Duplicate Files Between Folders on Your Mac

The can avoid the stress of copying and pasting files between folders on your Mac by merely using the duplicate files between folders command. This is achieved by using the Ditto terminal command on your Mac device. In the Terminal command prompt, type in Ditto [Original Folder] [New Folder].

Note: if you have folders in different locations with the same name, you have to include -v after Ditto to be able to achieve the right result.

Check For MacOS Updates

Your Mac device is customarily configured to check for macOS updates on a weekly basis, but a simple Terminal command can change this setting: defaults write com.apple.softwareUpdate ScheduleFrequency –int 1. Change the integer (the number seen in the command) to any number of your choice. The number represents the number of days that your device will wait before checking for updates.

You can return to the default weekly check for updates with defaults write com.apple.softwareUpdate ScheduleFrequency –int 7. With this, you can be notified of your app updates or macOS updates more frequently.

Improve Your Mac’s Screenshots

Normally, when you take screenshots on your Mac device, you will notice that it usually adds a drop shadow. These shadows can lower the quality of your screenshots. You might want to turn off these shadows by using the Terminal command defaults write com.apple.screencapture disable-shadow –bool TRUE. Underneath what you just typed, include Killall SystemUIServer. After entering this command, there should be no drop shadows added to your screenshots again.

Final Verdict

Many Mac users depend on various app preferences to have total control over their system. Terminal commands allow you to have total control without having to do this. You can use any of the terminal commands above, and many more, to customize your Mac device.

Related Posts: