10 Must Know Terminal Commands For Mac Devs
Visiting some must know Terminal Commands for Mac Developers
Welcome to another how to article! A lot of you guys are enjoying this format, so today I will go into my top 10 favorite terminal commands for Mac users.
As developers it’s becoming more and more user friendly as newer frameworks and programming languages are introduced every year but we cannot forget our trusty built in command line terminal.
Command: cd "path" or "path/subpath"
By default your terminal will open in your root directory. To change your directory, you simply use the cd command. You can also chain multiple paths with the cd command.
Print Working Directory
This command stands for “Print Working Directory”. This is used to check what directory you are currently in your terminal if you ever change directories too much and forget where you are.
The ls command is used to see what files are in your current directory. This is quite a useful command since you would need to know what files you are working with.
Command: mkdir "path"
The mkdir command is used to make a new directory. Basically when you right click on the desktop and hit “New Folder”, the desktop GUI is just entering this command in the background for you.
Command: rmdir "path"
The rmdir command is used to remove a directory. However, this command cannot remove directories that has files inside. This brings us to the next command.
Remove Directories & -recursive flag
Command: rm -R "path"
The rm command is used to remove a file. When used with the recursive -R flag on a directory, your terminal will delete everything in that directory. This is quite a powerful tool, so use at your own discretion because files deleted this way is irreversible.
Super User Do
Command: sudo "file"
The sudo command stands for “Super User Do”. This command is used to open files but with administrator privileges, your terminal will prompt you for your password to double check your credentials. Due to the nature of this command, please do not use it to open files you acquired from unreliable sources.
Copy file Command: cp "file" "new-file"
Command: cp "file" + "new-file"
The cp command is used to simply copy a file. This command requires two arguments, the first argument is what file you would like to copy and the second argument is what you want to name the new file.
Move file to Directory
Command: mv "file" + "path"
The mv command is used to move a file to another directory. This command is used similarly to the cp command, you will need to specify what file you want as the first argument and the directory path as the second argument.
The clear command is used to clear all commands from your terminal ui to give you a clean slate to work from. This command can also be triggered by simply using the CMD + K shortcut.
That’s it! I hope you’ve enjoyed my little guide on my favorite Mac terminal commands. It is also important to remember you can always use the ../ prefix with your path arguments to point your terminal up one level in your current path.
The terminal is quite a powerful tool and it has a lot more commands but I’m sure if you master the commands in this guide, you can get up and running on any framework or language.
Thank you for reading and please leave a comment if you‘ve enjoyed and please follow for more coding content.