Continuing from the previous post on.
RENAMING FILES & FOLDERS
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
MODIFYING PERMISSIONS
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
FOLDER PATHS & NAVIGATING FOLDERS
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
Applications
Library
Systems
Users
Most 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
Documents
Downloads
Music
Pictures
Public
Desktop
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
or
cd /Users/admin/Documents/OfficeFiles
EDITORS
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:
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
http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Commands
Vi:
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.
http://www.tutorialspoint.com/unix/unix-vi-editor.htm
Apart from this there are other editors such as gedit & xemacs which has a GUI interface.
NETWORKING RELATED TERMINAL COMMANDS
1)ping
Used to test connectivity to a particular IP address
ping http://www.google.com
2)traceroute
Used to check the hop trace between your machine & destination
traceroute http://www.google.com
3)ipconfig
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
4)ifconfig
Used to configure ifnormation related to network interface
ifconfig en0 inet <ip address> netmask <subnet mask>
5)lookup
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.
Pingback: Terminal Commands – Part 3 | Arun Patwardhan's Blog
Pingback: Configuring an SVN Server on OS X on your Local Network | Arun Patwardhan's Blog
Pingback: Configuring/Troubleshooting OS X Using Command Line | Arun Patwardhan's Blog
Pingback: Automation on the Mac | Arun Patwardhan's Blog
Pingback: UPDATE: Swift on Linux | Arun Patwardhan's Blog
Pingback: Automation on the Mac | Arun Patwardhan's Blog
Pingback: Useful scripts for macOS | Arun Patwardhan's Blog
Pingback: List of macOS Terminal commands | Arun Patwardhan's Blog
Here is another article for your reference: https://arunpatwardhan.com/2020/07/29/list-of-macos-terminal-commands/