{"id":60830,"date":"2022-03-25T11:00:00","date_gmt":"2022-03-25T15:00:00","guid":{"rendered":"https:\/\/jumpcloud.com\/?p=60830"},"modified":"2024-12-19T12:25:34","modified_gmt":"2024-12-19T17:25:34","slug":"five-helpful-mac-commands-for-it-admins","status":"publish","type":"post","link":"https:\/\/jumpcloud.com\/blog\/five-helpful-mac-commands-for-it-admins","title":{"rendered":"What Is the Mac Command Line & Why Is It Important for IT Admins?"},"content":{"rendered":"\n

Jump to Commands<\/a><\/p>\n\n\n\n

As a Mac admin, or an IT admin overseeing a cross-OS fleet, your role revolves around managing your company\u2019s Apple system infrastructure. To carry out your role efficiently, it is helpful to understand how to use the common Unix commands. <\/p>\n\n\n\n

Additionally, while most users of macOS are more familiar with the graphical user interface (GUI), the command line interface (CLI) is more powerful and saves time. In fact, there are some tasks that cannot be accomplished by any other method except the command line.<\/p>\n\n\n\n

In this article we will explore the command line, plus its applications and key benefits for IT admins.<\/p>\n\n\n\n

What Is the Command Line?<\/strong><\/h2>\n\n\n\n

A command line, accessed with Terminal.app, empowers you to work on Macs remotely or locally and control a macOS system through a series of text-based commands and scripts. <\/p>\n\n\n\n

With an admin account, you can make a tweak to almost everything on your Mac via the Terminal.app. You can also leverage the app to securely connect to servers and workstations remotely and to create simple or complex scripts for automating actions.<\/p>\n\n\n\n

When a command is successful, the command line does not display any indicator to notify you of the success. Instead, you will get a new line with your username as shown in Figure 1. It\u2019s important to note that the command and arguments you type in Terminal are case sensitive. <\/p>\n\n\n\n

\"\"
Figure 1<\/figcaption><\/figure>\n\n\n\n

Launching the Terminal.app<\/strong><\/h2>\n\n\n\n

To open Terminal on your Mac, you can search \u201cterminal\u201d in Spotlight as shown in Figure 2 or navigate through Applications > Utilities > Terminal<\/strong>. <\/strong>Once you launch the app, a small window with a command prompt will appear; this is the powerful command line (Figure 3).<\/p>\n\n\n\n

\"\"
Figure 2<\/figcaption><\/figure>\n\n\n\n
\"\"
Figure 3<\/figcaption><\/figure>\n\n\n\n

What Is Possible with Terminal?<\/strong><\/h2>\n\n\n\n

You can accomplish many tasks via the CLI, both easy and difficult. From showing hidden files, to getting a list of actively running computer processes, to rebooting a remote workstation, to automating workflows, the number of tasks you can achieve with the terminal app is impressive. <\/p>\n\n\n\n

In this section, we will introduce five common commands that every Mac admin should know, but first, let\u2019s learn how to gain admin level privileges.<\/p>\n\n\n\n

How to Get Admin Privileges on macOS<\/strong><\/h2>\n\n\n\n

Executing many commands in the command line will require you to have admin level privileges, i.e., you are expected to be a superuser. For instance, if you do not have the correct privileges and you attempt to run the shutdown<\/kbd> command, the command line will return an error saying you are not a superuser (as seen in Figure 4).<\/p>\n\n\n\n

\"\"
Figure 4<\/figcaption><\/figure>\n\n\n\n

Therefore, to run commands as a superuser, you need to add the sudo<\/kbd> command; sudo stands for superuser do<\/em>. This can be done in two ways: <\/p>\n\n\n\n

    \n
  1. Add sudo<\/kbd> to every command you run (as demonstrated in the next part of this article).<\/li>\n\n\n\n
  2. Execute a sudo command at the beginning of each terminal session so you don\u2019t have to add sudo<\/kbd> to every command you run (refer to Figure 5). <\/li>\n<\/ol>\n\n\n\n

    To gain admin level privileges via the second method, simply run the following command:<\/p>\n\n\n\n

    sudo -s<\/code><\/p>\n\n\n\n

    \"\"
    Figure 5<\/figcaption><\/figure>\n\n\n\n

    10 Helpful Mac Terminal Commands Every IT Admin Should Know<\/strong><\/h2>\n\n\n\n

    We\u2019ve put together a full tutorial series on the common commands every Mac admin must know. We will briefly discuss the commands here and provide a link to the associated article (wherever possible) if you would like to learn more.<\/p>\n\n\n\n

    1. Enable SSH for Accessing a Remote Mac’s Shell Securely<\/h3>\n\n\n\n

    SSH \u2014 also known as Secure Socket Shell or Secure Shell \u2014 is a secure network protocol that allows users, especially system admins, to securely access remote devices. To enable SSH, enter and execute the \u2011setremotelogin<\/kbd> command as follows:<\/p>\n\n\n\n

    sudo systemsetup -setremotelogin on<\/code><\/p>\n\n\n\n

    To know if SSH has been successfully enabled, simply run and execute the following:<\/p>\n\n\n\n

    sudo systemsetup -getremotelogin<\/code><\/p>\n\n\n\n

    Read our full tutorial on how to enable SSH for accessing a remote Mac’s shell securely<\/a>.<\/p>\n\n\n\n

    2. Rename Computer Name, Hostname, and Bonjour on macOS<\/h3>\n\n\n\n

    The ability to name each computer in your Mac fleet will allow you to identify and distinguish between them. Using the scutil<\/kbd> command, you can rename your computer name, hostname, and local hostname via the Terminal app. <\/p>\n\n\n\n