Terminal Commands for OS X – Part 2

Continuing from the previous post on.

The way files/folders are renamed is by using the mv command. In the mv command make sure that the destination folder is the same as the source folder for your target, its just the target name that changes.

So if we have a folder called Documents & inside it we have a folder called Files. To rename Files to OfficeFiles we run the following command.

mv Files OfficeFiles

Top modify the basic UNIX or POSIX permissions on a Mac we need to use the chmod command. The standard permissions apply to Users, Group & Everyone else. Each of these entities has 3 flags assigned to it: rwx Read-Write-Execute. Each flag is a boolean flag holding either true or false, indicated by 1 or 0.

So for example if we wanted to modify the permissions of the OfficeFiles folder to be read-write only for the user & read only for group & everyone else then the command would need the following information.
User: rwx = 110 -> 6
Group: rwx = 000 -> 0
Everyone else: rwx = 000 -> 0

So the command would look like: chmod 600 OfficeFiles
A good understanding of the folder structure within a Mac is necessary while dealing with terminal commands.
All folders with the Mac begin at root indicated by ‘/’
Root contains the following folders

rootFolderMost of the work that is done is done within the Users folder. In most cases users would not need to go to the other folders for their day to day work.


As you can see from the screenshots, the terminal shows more folders than are visible through finder.



Within the Users folder all the Home Folders for the different users on the machine are listed. Again, users typically have access only to their own login folder.

Each users Home Folder contains the following Folders

Depending on your usage you may see a different view from the one shown below.

The following are some examples of navigating the File System.

1)Accessing the root folder

cd /

2)Accessing the home folder. Example home folder called admin

cd /Users/<home folder name>

cd /Users/admin

or cd ~/

NOTE: the ‘~/’ is a shortcut for accessing the home folder directly. Using the shortcut access will only be given to the home folder for the user currently logged in.

3)To access the OfficeFiles folder

cd ~/Documents/OfficeFiles


cd /Users/admin/Documents/OfficeFiles
There are a number of built in editors available within the Mac. Apart from TextEdit, which is a GUI based editor, there are many editors available for direct use from the terminal too.

Emacs is a basic text editor that is built into the mac. There are various versions available but those may not be built in. You may need to download them manually.

Here are some common emacs commands to perform operations. For an even bigger list visit http://www.cse.iitb.ac.in/~br/courses/cs699-autumn2013/refs/emacs-commands2.html


This is yet another editor that is built into most UNIX like OS. This is the editor that is used when running the less or more commands.

Here are some common commands used in Vi.

Apart from this there are other editors such as gedit & xemacs which has a GUI interface.

Used to test connectivity to a particular IP address
ping http://www.google.com

Used to check the hop trace between your machine & destination
traceroute http://www.google.com

Used to get network interface related information
ipconfig getoption en1 <option>
There is a lot more information that can be gleaned using ipconfig. For a full list run the man command for ipconfig

Used to configure ifnormation related to network interface
ifconfig en0 inet <ip address> netmask <subnet mask>

There are different ways to get the forward & reverse lookup to happen
nslookup <domain name>
nslookup <ip address>

dig <domain name>
dig -x <ip address>
NOTE: Please use the man command to get more information.


9 thoughts on “Terminal Commands for OS X – Part 2

  1. Pingback: Terminal Commands – Part 3 | Arun Patwardhan's Blog

  2. Pingback: Configuring an SVN Server on OS X on your Local Network | Arun Patwardhan's Blog

  3. Pingback: Configuring/Troubleshooting OS X Using Command Line | Arun Patwardhan's Blog

  4. Pingback: Automation on the Mac | Arun Patwardhan's Blog

  5. Pingback: UPDATE: Swift on Linux | Arun Patwardhan's Blog

  6. Pingback: Automation on the Mac | Arun Patwardhan's Blog

  7. Pingback: Useful scripts for macOS | Arun Patwardhan's Blog

  8. Pingback: List of macOS Terminal commands | Arun Patwardhan's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s