Basic Command Line Commands
Let’s talk basic command line commands today! I’ve shared some recent command line articles on Google PageSpeed Insights on Command Line (CLI) and Running Google Lighthouse programmatically, in addition to older posts like Screaming Frog Command Line (CLI) automation. I want to share some more fundamental components of command line and batch scripting: basic command […]
Let’s talk basic command line commands today! I’ve shared some recent command line articles on Google PageSpeed Insights on Command Line (CLI) and Running Google Lighthouse programmatically, in addition to older posts like Screaming Frog Command Line (CLI) automation.
I want to share some more fundamental components of command line and batch scripting: basic command line commands! (Spoiler alert: this article, like the others only covers Windows Command Line, not Mac or Linux.)
Getting Started With Command Line / CMD
To do anything with command line commands, you’ll first need to open up the Command Prompt! This is an easy start: click into your search bar (if you have Windows 10 or recent) and type “CMD.”
The Command Prompt app should pop up as the best match – click it!
I certainly don’t recommend doing this every time. For convenience, you can right click the Command Prompt icon in your taskbar once open, and pin it for quick access. (Similar for Start Menu if that’s your fancy.)
Once Command Prompt is open, you should see some information about the version of Windows you’re running, the copyright statement, and your default current directory below.
Basic Commands & Parameters in CLI / CMD
Surprisingly, I feel there’s a gentle learning curve in using command prompt vs. some other programming languages or settings. One of the first things you can do learn the basic “super user” kind of commands in command line.
What’s Here? Using the “dir” command
The “dir” command in CLI/CMD isn’t far from Hello world! The “dir” command will show you information about the folders and files in your current directory.
You may often find that the default current directory for Command Line is C:\Users\[YOUR USER NAME HERE]
The line containing the single period represents the current directory, and the line containing two periods represents the parent directory above your current. (More often than not, this will be the C:\Users\ directory.)
From left to right, the dates and times should represent when the files or folders were created. If the line is a folder, you’ll see the “<DIR>” notation. If the line is a file, the file size in bytes will be shown, along with the folder or file name on the far right. At bottom, a summary line will be displayed.
I need somebody (Help!) Not just anybody
Like any programming language, there are ton of commands, options, functions – you name it! For command line commands, just add help to your command, and when you run help + command, you should get back instructions and help on parameters for the command.
Helpers: Parameters in Basic Command Line Commands
Parameters are the first building block to doing fun things with basic command line commands. Parameters may also be known as options or arguments, depending on the setting.
Parameters can take the shape of words, symbols or letters, or sometimes a mix of these. Adding parameters can help you customize the output of your commands in command line.