HEAD
Unit 02: Command Line
This week's stuff:
As we learn the core concepts of programming, we tend to avoid working with GUI (graphical user interface) creation so as to not distract from the primary concepts. Additionally, every business is going to use different libraries and tools for interfaces, but the underlying language (C++, or C#, or Java) remains the same.
Additionally, while most average users only interact with their computers and phones through GUIs, there are still lots of command-line-based tools, especially used in software development, IT, and computer configuration.
My goal in teaching you some basics about the command line is so that you can explore it at your own pace in this class and see that it's not so scary to get around and run basic commands. In the professional world, I'm worked with both GUI (Graphical User Interface) tools and CLI (Command Line Interface) tools at the same time.
Example: Ping program
Command line programs take this form: PROGRAM OPTIONS
The program name always comes first, and then zero, one, or more options follow.
For example, the ping
command is used to send data-packets to a web address you
provide, and is often used to test to see if your computer is online, or the
intended URL is online.
ping google.com -i 5
This command means the following:
ping
programgoogle.com
5
seconds (the -i
stands for "intervals")Example: g++
The g++
program is a C++ compiler, which allows us to turn our C++ source code
into an executable program.
g++ test.cpp -o MyProgram.exe
This command means the following:
g++
programtest.cpp
fileMyProgram.exe
(-o
stands for "output")
After building the program, I then run ./MyProgram.exe
to start my program.
Navigating folders with the command line
When you're browsing a folder on your computer, you can open up the terminal from that directory. You can see the same files from the command line as well.
ls
- (lower case L and S) - This command LISTS the files and folders where you are currently at.
ls
by itself for a simple list,ls -l
for a more detailed listNavigating folders with the command line
When you're browsing a folder on your computer, you can open up the terminal from that directory. You can see the same files from the command line as well.
cd FOLDERNAME
- This is the Change Directory command, you can move between folders with this.
cd FOLDERNAME
will move you deeper into a folder. cd ../
is like the "up" arrow in your file browser, it will move you BACK OUT one folder. CLI command | What it does |
---|---|
cd FOLDERNAME | Change Directory into the FOLDERNAME given. |
cd ../ | Move back or "out" one folder. |
ls | View a simple list of files and folders in this directory. |
g++ FILENAME.cpp | Build a C++ file into an executable (a.out or a.exe is the default name). |
g++ FILENAME.cpp -o PROGRAM.exe | Build a C++ file into an executable with the given PROGRAM name. |
./PROGRAM.exe | Run the program. |
Unit 02: Command Line
This week's stuff:
As we learn the core concepts of programming, we tend to avoid working with GUI (graphical user interface) creation so as to not distract from the primary concepts. Additionally, every business is going to use different libraries and tools for interfaces, but the underlying language (C++, or C#, or Java) remains the same.
Additionally, while most average users only interact with their computers and phones through GUIs, there are still lots of command-line-based tools, especially used in software development, IT, and computer configuration.
My goal in teaching you some basics about the command line is so that you can explore it at your own pace in this class and see that it's not so scary to get around and run basic commands. In the professional world, I'm worked with both GUI (Graphical User Interface) tools and CLI (Command Line Interface) tools at the same time.
Example: Ping program
Command line programs take this form: PROGRAM OPTIONS
The program name always comes first, and then zero, one, or more options follow.
For example, the ping
command is used to send data-packets to a web address you
provide, and is often used to test to see if your computer is online, or the
intended URL is online.
ping google.com -i 5
This command means the following:
ping
programgoogle.com
5
seconds (the -i
stands for "intervals")Example: g++
The g++
program is a C++ compiler, which allows us to turn our C++ source code
into an executable program.
g++ test.cpp -o MyProgram.exe
This command means the following:
g++
programtest.cpp
fileMyProgram.exe
(-o
stands for "output")
After building the program, I then run ./MyProgram.exe
to start my program.
Navigating folders with the command line
When you're browsing a folder on your computer, you can open up the terminal from that directory. You can see the same files from the command line as well.
ls
- (lower case L and S) - This command LISTS the files and folders where you are currently at.
ls
by itself for a simple list,ls -l
for a more detailed listNavigating folders with the command line
When you're browsing a folder on your computer, you can open up the terminal from that directory. You can see the same files from the command line as well.
cd FOLDERNAME
- This is the Change Directory command, you can move between folders with this.
cd FOLDERNAME
will move you deeper into a folder. cd ../
is like the "up" arrow in your file browser, it will move you BACK OUT one folder. CLI command | What it does |
---|---|
cd FOLDERNAME | Change Directory into the FOLDERNAME given. |
cd ../ | Move back or "out" one folder. |
ls | View a simple list of files and folders in this directory. |
g++ FILENAME.cpp | Build a C++ file into an executable (a.out or a.exe is the default name). |
g++ FILENAME.cpp -o PROGRAM.exe | Build a C++ file into an executable with the given PROGRAM name. |
./PROGRAM.exe | Run the program. |