Professional Documents
Culture Documents
The Terminal - Practical Go Lessons-3
The Terminal - Practical Go Lessons-3
com/chap-3-the-terminal
• Shell
• Bash
2 Introduction
The day-to-day life of a Go programmer requires the usage of the terminal. This chapter will explain what the terminal is and how to use it. If
you are already familiar with it, you can skip the chapter.
We say that those programs offer a graphical user interface (GUI). The vast majority of users will use programs that provide these interfaces.
Graphical interfaces are easy to use and intuitive.
The paper and the digital edition of this book are available here. ×
I also filmed a video course to build a real world project with Go.
1 of 7 02/01/2023, 02:00
The terminal - Practical Go Lessons https://www.practical-go-lessons.com/chap-3-the-terminal
is a program that can pass commands to an operating system1. Shell is a generic term that designates such programs. The most famous shell
is bash (Bourne Again Shell). Bash is shipped by default with macOS and a vast majority of Linux Distributions. Windows is also shipped by
default with a shell (but it’s not bash).
5.1 macOS
• Open the Finder application :
Finder Icon
Utilities
Terminal Application
2 of 7 02/01/2023, 02:00
The terminal - Practical Go Lessons https://www.practical-go-lessons.com/chap-3-the-terminal
Terminal Application
Note that I use a customized terminal. Thus you might see a different output; this is perfectly normal.
• You can also launch the terminal with the Ubuntu Dash. Type “Terminal” and the application should appear.
5.3 Windows
• Click on the start button, then in the text box type “cmd” (for command prompt)
3 of 7 02/01/2023, 02:00
The terminal - Practical Go Lessons https://www.practical-go-lessons.com/chap-3-the-terminal
Windows terminal
5.3.1 Cmder
The terminal and the Windows shell is not very practical on a day today basis. I advise you to install cmder2 To make your developer life
easier on windows. Cmder is an emulator that will allow you to use commands available on Linux/MacOS. The installation process is easy
(download the latest release on GitHub) then launch the installation wizard.
After installing cmder, launch the program “Cmder” to open your brand new terminal.
4 of 7 02/01/2023, 02:00
The terminal - Practical Go Lessons https://www.practical-go-lessons.com/chap-3-the-terminal
By default, you cannot use bash on a Windows computer. This is not a problem, but it means that you will have to find the Windows
equivalent for each macOS/Linux command. It can be cumbersome at some point because a lot of examples and tutorials on the web do not
always provide equivalence for Windows.
Microsoft announced that you can now install a “Windows Subsystem for Linux” (WSL) on your Windows computer. This is a piece of good
news because you will use bash. You can find the installation instructions on the Microsoft website: https://docs.microsoft.com/en-
us/windows/wsl/install-win10 (for Windows 10).
I strongly advise you to install this, because it will make your life easier even if I try to give Windows equivalent for basic commands in the
next sections.
• For macOS
$ ls /Users/maximilienandile/Desktop
• For Linux
$ ls /home/maximilienandile/Desktop
Then press enter. You will see a list of files and directories.
$ pwd
/Users/maximilienandile
• pwd: allow you to print the working directory, (print the name of the directory you are into)
5 of 7 02/01/2023, 02:00
The terminal - Practical Go Lessons https://www.practical-go-lessons.com/chap-3-the-terminal
Windows terminal
Each line will represent either a file or a directory. There are “<DIR>” In the third column, if it’s a directory. Nothing if it’s a file.
$ bash
And press enter. Now you are using bash! (congratulations). To list elements in your home directory, simply type :
$ ls /mnt/c/Users/maxou123
7 Test yourself
7.1 Questions
1. What is the command to list the contents of a directory?
2. What is a terminal?
7.2 Answers
1. What is the command to list the contents of a directory?
2. What is a terminal?
1. bash
The paper and the digital edition of this book are available here. ×
I also filmed a video course to build a real world project with Go.
8 Key takeaways
• Graphical User Interfaces have not always existed
• To interact with computers, we can use a Graphical Interface or a Command line Interface. (CLI)
6 of 7 02/01/2023, 02:00
The terminal - Practical Go Lessons https://www.practical-go-lessons.com/chap-3-the-terminal
• To use a CLI, we have to open a terminal application that offers an interface to interact with a shell
• Bash is a shell.
• You can launch commands by typing the command name and eventually options, then press enter.
1. http://www.catb.org/jargon/html/S/shell.html↩
Bibliography
Previous Next
Table of contents
Did you spot an error ? Want to give me feedback ? Here is the feedback page! ×
Newsletter:
Like what you read ? Subscribe to the newsletter.
@ my@email.com
Practical Go Lessons
By Maximilien Andile
Copyright (c) 2023
Follow me Contents
Posts
Book
Support the author Video Tutorial
About
The author
Legal Notice
Feedback
Buy paper or digital copy
Terms and Conditions
7 of 7 02/01/2023, 02:00