For the macOS platform, you can install the Azure CLI with homebrew package manager. Homebrew makes it easy to keep your installation of the CLI update to date. The CLI package has been tested on macOS versions 10.9 and later. Homebrew is the easiest way to manage your CLI install. ASSOC: Fix File Associations. One of the most powerful tools in the CMD command library is the. 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. Beneath the surface of the operating system is an entire world that you can access only from the command line. Terminal (in your /Applications/Utilities folder) is the default gateway to that. Open the Command Palette (Ctrl+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command. Restart the terminal for the new $PATH value to take effect. You'll be able to type 'code.' In any folder to start editing files in that folder.
-->The following tips and control equivalents should help you in your transition between a Mac and Windows (or WSL/Linux) development environment.
For app development, the nearest equivalent to Xcode would be Visual Studio. There is also a version of Visual Studio for Mac, if you ever feel the need to go back. For cross-platform source code editing (and a huge number of plug-ins) Visual Studio Code is the most popular choice.
Keyboard shortcuts
Operation | Mac | Windows |
---|---|---|
Copy | Command+C | Ctrl+C |
Cut | Command+X | Ctrl+X |
Paste | Command+V | Ctrl+V |
Undo | Command+Z | Ctrl+Z |
Save | Command+S | Ctrl+S |
Open | Command+O | Ctrl+O |
Lock computer | Command+Control+Q | WindowsKey+L |
Show desktop | Command+F3 | WindowsKey+D |
Open file browser | Command+N | WindowsKey+E |
Minimize windows | Command+M | WindowsKey+M |
Search | Command+Space | WindowsKey |
Close active window | Command+W | Control+W |
Switch current task | Command+Tab | Alt+Tab |
Maximize a window to full screen | Control+Command+F | WindowsKey+Up |
Save screen (Screenshot) | Command+Shift+3 | WindowsKey+Shift+S |
Save window | Command+Shift+4 | WindowsKey+Shift+S |
View item information or properties | Command+I | Alt+Enter |
Select all items | Command+A | Ctrl+A |
Select more than one item in a list (noncontiguous) | Command, then click each item | Control, then click each item |
Type special characters | Option+ character key | Alt+ character key |
Trackpad shortcuts
Note: Some of these shortcuts require a “Precision Trackpad”, such as the trackpad on Surface devices and some other third party laptops.
Operation | Mac | Windows |
---|---|---|
Scroll | Two finger vertical swipe | Two finger vertical swipe |
Zoom | Two finger pinch in and out | Two finger pinch in and out |
Swipe back and forward between views | Two finger sideways swipe | Two finger sideways swipe |
Switch virtual workspaces | Four fingers sideways swipe | Four fingers sideways swipe |
Display currently open apps | Four fingers upward swipe | Three fingers upward swipe |
Switch between apps | N/A | Slow three finger sideways swipe |
Go to desktop | Spread out four fingers | Three finger swipe downwards |
Open Cortana / Action center | Two finger slide from right | Three finger tap |
Open extra information | Three finger tap | N/A |
Show launchpad / start an app | Pinch with four fingers | Tap with four fingers |
Note: Trackpad options are configurable on both platforms.
Command-line shells and terminals
Windows supports several command-line shells and terminals which sometimes work a little differently to the Mac's BASH shell and terminal emulator apps like Terminal and iTerm.
Windows shells
Windows has two primary command-line shells:
PowerShell - PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and scripting language built on .NET. Using PowerShell, administrators, developers, and power-users can rapidly control and automate tasks that manage complex processes and various aspects of the environment and operating system upon which it is run. PowerShell is fully open-source, and because it is cross-platform, also available for Mac and Linux.
Mac and Linux BASH shell users: PowerShell also supports many command-aliases that you are already familiar with. For example:
- List the contents of the current directory, using:
ls
- Move files with:
mv
- Move to a new directory with:
cd <path>
Some commands and arguments are different in PowerShell vs. BASH. Learn more by entering:
get-help
in PowerShell or checkout the compatibility aliases in the docs.To run PowerShell as an Administrator, enter 'PowerShell' in your Windows start menu, then select 'Run as Administrator.'
- List the contents of the current directory, using:
Windows Command Line (Cmd): Windows still ships the traditional Command Prompt (and Console – see below), providing compatibility with current and legacy MS-DOS-compatible commands and batch files. Cmd is useful when running existing/older batch files or command-line operations, but in general, users are recommended to learn and use PowerShell since Cmd is now in maintenance, and will not be receiving any improvements or new features in the future.
Linux shells
Windows Subsystem for Linux (WSL) can now be installed to support running a Linux shell within Windows. This means that you can run bash, with whichever specific Linux distribution you choose, integrated right inside Windows. Using WSL will provide the kind of environment most familiar to Mac users. For example, you will ls to list the files in a current directory, not dir as you would with the traditional Windows Cmd Shell. To learn about installing and using WSL, see the Windows Subsystem for Linux Installation Guide for Windows 10. Linux distributions that can be installed on Windows with WSL include:
Just to name a few. Find more in the WSL install docs and install them directly from the Microsoft Store.
Windows Terminals
In addition to many 3rd party offerings, Microsoft provides two “terminals” – GUI applications that provide access to command-line shells and applications.
Windows Terminal: Windows Terminal is a new, modern, highly configurable command-line terminal application that provides very high performance, low-latency command-line user experience, multiple tabs, split window panes, custom themes and styles, multiple “profiles” for different shells or command-line apps, and considerable opportunities for you to configure and personalize many aspects of your command-line user experience.
You can use Windows Terminal to open tabs connected to PowerShell, WSL shells (like Ubuntu or Debian), the traditional Windows Command Prompt, or any other command-line app (e.g. SSH, Azure CLI, Git Bash).
Console: On Mac and Linux, users usually start their preferred terminal application which then creates and connects to the user’s default shell (e.g. BASH).
However, due to a quirk of history, Windows users traditionally start their shell, and Windows automatically starts and connects a GUI Console app.
While one can still launch shells directly and use the legacy Windows Console, it’s highly recommended that users instead install and use Windows Terminal to experience the best, fastest, most productive command-line experience.
Apps and utilities
App | Mac | Windows |
---|---|---|
Settings and Preferences | System Preferences | Settings |
Task manager | Activity Monitor | Task Manager |
Disk formatting | Disk Utility | Disk Management |
Text editing | TextEdit | Notepad |
Event viewing | Console | Event Viewer |
Find files/apps | Command+Space | Windows key |
Introduction
Feeling scared of the command line? You’re not alone. We have this image of developers staring intently at a black screen with white or green text flashing across as they wildly enter incomprehensible commands to hack into the corporate mainframe (no doubt while guzzling soda and wiping neon orange Cheetos dust off their keyboard).
That black screen or window is the command line interface (CLI), where you’re able to enter commands that your computer will run for you. While there’s no need for you to reenact the scene above, working with the command line is a critical skill for you to learn as a developer. The command line is like our base of operations, from which we can launch other programs and interact with them. It has a syntax of its own to learn, but since you’ll be entering the same commands dozens of times, you’ll quickly pick up the commands you need most.
In this introductory lesson to the command line, you’ll learn how to navigate around your computer and how to manipulate files and directories (also known as folders) directly from the comfort of the command line. You’ll soon see that this isn’t as difficult as you may think. The commands you will learn in this lesson are very straightforward, so don’t be intimidated by the prospect of using the command line for the first time.
Test Drive Your Terminal
Open a terminal on your computer. - Linux: open the programs menu and search for “Terminal”. You can also open the terminal by pressing CTRL + ALT + T
on your keyboard. - MacOS: Open your Applications > Utilities folder and find “Terminal”.
Before we do anything, take a look at the following text:$ whoami
This is a terminal command because it begins with a $
. The $
is saying “Hey! Enter what follows in your terminal.” This means that we must exclude the $
when entering any command. In the example above, we would only enter whoami
in our terminal. This is a common indicator so make sure that you aren’t entering $
before a command. Now that you are aware of what $
does, take your terminal for a test run! Make sure your terminal is open, type the command mentioned above, and press enter on your keyboard.
It returns your username. Cool!
Why learn this now?
You will be making heavy use of the command line throughout this curriculum, and the upcoming installations project will require you to install many different software programs using the command line. Additionally, you will primarily be using Git within the command line (more on this later). As part of the bigger picture, you may well be using the command line on a daily basis in your career as a software developer, making it an indispensable skill in your toolset.
Learning Outcomes
By the end of this lesson, you should be able to do the following:
- Describe what the command line is.
- Open the command line on your computer.
- Use the command line to navigate directories and display directory contents.
- Use the command line to create a new directory and a new file.
- Use the command line to rename or destroy a directory and a file.
- Use the command line to open a file or folder in a program.
Assignment
Note: Many of these resources assume you’re using a Mac or Linux environment. If you did our previous installation lesson, you should already have Linux installed in dual-boot, a virtual machine, or Windows Subsystem for Linux. Or, you might be using MacOS. If you don’t have MacOS, or any version of Linux installed, please return to the operating system installation guide.
- Before diving into the command line lesson, you’ll want to know how to create a file. You can do so with the
touch
command. Open your terminal and enterls
(thel
is a lowercaseL
).ls
will show you the files and folders in the current directory (or will show nothing if the current directory is empty). Create a file calledtest.txt
by entering this in your terminal:touch test.txt
. Now enterls
once again. You should seetest.txt
listed in the output. You can also create more than one file at once using thetouch
command. Entertouch index.html script.js style.css
and press the enter. Then enterls
once more. You should see the files in the output. Here is a small way that the terminal reveals its power. How long would it have taken to create all three of those files with your mouse? Thanks, terminal. - Read through chapter 1 of Conquering the Command Line.
Use the Command Line Like a Pro
There’s something important that you need to know about programmers. Programmers are lazy. Like, really lazy. If they are forced to do something over and over again, odds are good that they’ll figure out a way to automate it instead. The good news is that you get to benefit from the many shortcuts they’ve created along the way. It’s time to learn how to use the command line like a pro (which is to say, in a really lazy way).
First, you might have already noticed that copying and pasting inside the command line doesn’t work the way that you’d expect. When you’re inside the command line, you’ll need to use Ctrl+Shift+C
(Mac: Cmd+C
) to copy and Ctrl+Shift+V
(Mac: Cmd+V
) to paste. For example, to copy and paste commands from your browser into the command line, you’ll highlight the command text and use Ctrl+C
as usual and then paste it in your terminal using Ctrl+Shift+V
. Test it out!
Second, you need to learn about tab completion. Seriously, this tip will save you so much time and frustration. Let’s say that you’re in the command line and that you need to move into a folder that’s far away, something like ~/Documents/Odin-Project/Web-Development-101/javascript/calculator/
. That’s a long command to type out, and everything needs to be exactly right in order for it to work. Nope, we’re way too lazy for that! Basically, by hitting Tab
, the command line will automatically complete commands that you’ve started typing once there’s only one option. For example, it’s pretty common to have a Documents
folder and a Downloads
folder in the home directory. If you’ve typed cd D
and then press Tab
, the command line will let you know that it’s not sure which one you want by showing you the different options that match what you’ve typed so far:bash$ cd DDocuments/ Downloads/$ cd D
But once you’ve typed in a little bit more, it will complete the name for you, making it possible to write out the full file path above by typing as little as cd Doc[tab]O[tab]W[tab]j[tab]cal[tab]
(depending on what other folders exist on your computer). Test it out, and get comfortable with how this works. You’re gonna love it.
Third, there’s a really handy shortcut for opening everything within a project directory: .
Once you’ve installed a text editor, you can use this shortcut to open up an entire project and all of its files in one go. This shortcut is also commonly used with Git (which is covered in detail later on) with commands like git add .
to add all of the files inside of a directory into Git’s staging area. For example, if you have VS Code installed, you can cd
into the project directory and then type code .
(with the period) to open up all of the project files. See the next section of this lesson for a more detailed example.
Opening files in VSCode from the Command Line
On Windows and Linux, you can open VSCode from the command line by typing code
, and you can open folders or files by adding the name of the location after it: code my_awesome_project/
.
MacOS Users:
MacOS can do this too, but you need to set it up. After installing VSCode, launch it any way you’re comfortable with. Once it’s running, open the Command palette with CMD + Shift + P
. In the little dialog that appears, type shell command
. One of the choices that appears will be Shell Command: Install 'code' command in PATH
. Select that option, and restart the terminal if you have it open.
Regarding Security Warning:
A message may show, warning the user that VSCode is not trusted software. This is an expected message. VSCode can be trusted, therefore it is safe to ignore this warning.
WSL Users:
Although you just installed Ubuntu on your computer, you should still install the Windows version of the code editor you choose. You will edit the files in your Projects directory with the code editor, and WSL will be able to read these files. If you are using VSCode, be sure to install the “Remote - WSL” extension when prompted. This extension will allow you to directly access your Linux files. Once installed, select the green icon in the lower left corner to connect to WSL.
Command Prompt In Macbook
Exercise
In this exercise, you will practice creating files and directories and deleting them. You’ll need to enter the commands for this exercise in your terminal. If you can’t recall how to open a terminal, scroll up for a reminder.
- Create a new directory in your home directory with the name
test
. - Navigate to the
test
directory. - Create a new file called
test.txt
. Hint: use thetouch
orecho
command. - Open your newly created file in VSCode and make some changes, save the file, and close it.
- Navigate back out of the
test
directory. - Delete the
test
directory.
That’s it–you’re done with command line basics! If you commit to doing most things from the command line from here on out, these commands will become second nature to you. Moving and copying files is much more efficiently done through the command line, even if it feels like more of a hassle at this point.
Additional Resources
This section contains helpful links to other content. It isn’t required, so consider it supplemental material for if you want to dive deeper into something.
- The online book Learn Enough Command Line to Be Dangerous is a great resource for mastering the command line. Chapter 1 is free and provides a good introduction to command line tools. The rest of the book is not free and goes into more depth than you really need at this point, but feel free to purchase and read the rest of the book if you like.
- ExplainShell.com is a great resource for if you want to deconstruct a particularly strange shell command or learn how Bash works through guess-and-check.
- Unix/Linux Command Cheat Sheet contains a list of important commands that you can refer to regularly as you become familiar with using Linux. You can print it out so you can have a physical copy with you when you’re not at your computer.
- Command Line Flashcards by flashcards.github.io.
- Video Series from LearnLinuxTv contains 24 videos explaining the basics of the command line. Videos are brief enough for beginners but, at the same time, are detailed enough to get started and light your inner curiosity.
Knowledge Check
This section contains questions for you to check your understanding of this lesson. If you’re having trouble answering the questions below on your own, clicking the small arrow to the left of the question will reveal the answers.
- The command line is a way to interact with the computer using specific words called 'commands'.
Command Line For Mac Address From Ip
- On Linux: Open the programs menu and search for 'Terminal'. You can also open the terminal by pressing
CTRL
+ALT
+T
. - On Mac: Open your applications folder and find 'Terminal'.
- You can use the
cd
command to change directories.
cd
on its own navigate you to?- On Linux and Mac, it will navigate you home.
cd ..
navigate you to?- It will navigate you 'up' one folder, that is, into the parent of the current directory.
Command Line For Mac
- On Linux and Mac, use the
pwd
(print working directory) command.
- On Linux and Mac, use the
ls
command. Usels -l
to display the files in a list.
- You can do this using the
mkdir
command.
- On Linux and Mac, use the
touch
command, e.g.,touch new-file.txt
.
- On Linux and Mac, use the
rm
command. To destroy folders, userm -r
orrmdir
.
- On Linux and Mac, use the
mv
command, e.g.,mv folder/old-file.txt folder/new-file.txt
.