Intro to Terminal Interactions
- Purpose - To learn basic command line skills to later be leveraged when using other command line tools.
Glossary of Terms
Shell
- a program used to interpret input from, and send output to, the terminalTerminal
- a text-based interface used to interact with the shellResource
- an allocation of memory which has the propencity to be occupied by a file.File
- a particular instance of allocated memory used for recording data on a storage device.File System
- a relational structure (hierarchical relations) of files and directories.File Explorer
- a graphical representation of a file system.File Path
- the uniquely named location for a particular file.Directory
- a special type of file which has reference to other files, and possibly other directoriesFolder
- a graphical representation of a directoryHome Directory
- the directory containing files for a given user on a multiuser operating systemCurrent Working Directory
- the directory presently referenced in the terminal, thus referenced by the shell.Parent Directory
- a directory containing another directory; the directory “above” another directoryChild Directory
- a directory contained by another directory; the directory “below” another directoryDev Directory
- a child directory of the home directory that is used to store application-development-projects and local-code-basesRoot Directory
- the parent directory of a particular file system or subsystemCommand
- a key word that is executed in the terminal, thus executed by the shell, to access and interact with a particularly program or service.Alias
- a symbol used to refer to a particular filepath.
Instructions
Section A - Configuring File System for Application Development
- The purpose of the following section is to familiarize with basic commands while also creating the conventional file-system structure for application-development.
Part 1 - Opening The Terminal
- To open the terminal in OSX
- hold
Command
and pressSpace
to open the spotlight search. - in the search bar, enter
terminal
- hold
- To open the git-bash terminal in Windows OS
- press the
Windows
key to open windows search. - in the search bar, enter
git bash
.
- press the
Part 2 - Displaying your Username
- Upon opening the terminal, verify what your username is.
- execute
whoami
in the terminal. - The name of the account that is currently signed in should be displayed in the terminal’s standard output.
- execute
- In the examples below, the name of the user-account is
hunte
Part 3 - Home Directory
- To navigate to the home directory execute
cd ~
in the terminalcd
is a command used to change directories~
is an alias recognized by the shell to reference the home directory
- Verify that you are in your home directory by executing
pwd
to print working directory.- The file path pointing to a directory with your username should be displayed in the terminal’s standard output.
Part 4 - Listing Files in the Current Directory
- To list all of the files in the current directory, execute
ls
Part 5 - Opening the File Explorer
- To get a graphical representation of the file system, open the file explorer.
- execute
explorer .
from the Windows git-bash terminal - execute
open .
from the OSX terminal
- execute
Part 6 - Creating an Application-Development directory
- To create a new directory, named
dev
, executemkdir dev
from the home-directory.mkdir
is a command used to create a new directorydev
is the name of the directory to be created
- Verify that newly created directory is visible in the terminal, by executing
ls
.- The name of the directory,
dev
, should be displayed in the standard output.
- The name of the directory,
- Verify that newly created directory is visible in the project explorer, by executing
explorer .
oropen .
respectively- The directory should be displayed as a folder in the project explorer
Part 7 - Change Directory to the dev
directory
- To change the current working directory to
dev
, executecd dev
from the home directory. - Verify that the command has executed properly by executing
pwd
to display the current working directory.- The name of the current working directory,
~/dev
, should be displayed in the standard output.
- The name of the current working directory,
- Verify that this directory is empty by executing
ls
- The standard output should not display anything
Section B - Creating A New Project Directory in dev
directory
- The purpose of the following section is to re-familiarize with the aforementioned skills by creating a directory which contains files and other directories.
Part 1 - Opening The Terminal
- To open the terminal in OSX
- hold
Command
and pressSpace
to open the spotlight search. - in the search bar, enter
terminal
- hold
- To open the git-bash terminal in Windows OS
- press the
Windows
key to open windows search. - in the search bar, enter
git bash
.
- press the
Part 2 - Change Directory to the dev
directory
- Execute
cd ~/dev
to change the current working directory todev
cd ~/dev
can be read verbally as “change directory tohome
. From herenavigate to
directory nameddev
”cd
is a command used to change directories~
is an alias recognized by the shell to reference the home directory/
is a symbol used to expressnavigate to
- Execute
pwd
to display the current working directory to verify that the command has executed properly. - Execute
ls
to verify the contents of this directory.
Part 3 - Create a New Project Directory
- Execute
mkdir my-first-project
from thedev
directory to create a new directory namedmy-first-project
in thedev
directory - Execute
ls
to verify that the directory has been created properly. - Execute
cd ./my-first-project
to change the current working directory to the newly created directory. cd ./my-first-project
can be read verbally as “change directory tocurrent working directory
. From here,navigate to
directory namedmy-first-project
”cd
is a command used to change directories.
is an alias recognized by the shell to reference thecurrent working directory
/
is a symbol used to express “from here, navigate to”
- Execute
pwd
to verify that you have navigated to the directory properly.
Part 4 - Create Directory Named empty-directory
- Execute
mkdir empty-directory
from themy-first-project
directory to create a new directory, namedempty-directory
- Execute
ls
to verify that the newly created directory, namedempty-directory
, has been created in themy-first-project
directory. - Execute
cd ./empty-directory
to change the current working directory to the newly created directory - Execute
pwd
to verify that you have navigated to the directory properly. - Execute
ls
to verify that this directory is empty.
Part 5 - Navigate Back to my-first-project
directory
- Execute
cd ..
to navigate to the parent directory of the current working directory...
is an alias recognized by the shell to reference theparent directory
.- A parent directory is a directory which contains another directory.
- (for example,
my-first-project
is a child directory of the parent directory nameddev
)
- (for example,
- Execute
pwd
to verify that you have navigated to the directory properly. - Execute
ls
to verify this directory contains a directory namedempty-directory
.
Part 7 - Create Directory Named non-empty-directory
- Execute
mkdir non-empty-directory
from themy-first-project
directory to create a new directory namednon-empty-directory
. - Execute
ls
to verify that the newly created directory, namednon-empty directory
has been created in the directory namedmy-first-project
. - Execute
cd ./non-empty-directory
from themy-first-project
directory to change the current working directory tonon-empty-directory
. - Execute
pwd
to verify that you have navigated to the directory properly.
Part 8 - Create Directories Within non-empty-directory
- Execute
mkdir child-directory-1
to create a new directory in thenon-empty-directory
- Execute
ls
to verify that the newly created directory, namedchild-directory-1
has been created in directory namednon-empty-directory
.` - Execute
mkdir child-directory-2
to create a new directory in thenon-empty-directory
- Execute
ls
to verify that the newly created directory, namedchild-directory-2
has been created in directory namednon-empty-directory
.`
Part 9 - Create Files Within non-empty-directory
- Execute
touch some-file
to create a new file in thenon-empty-directory
- Execute
touch some-text-file.txt
to create a new text file in thenon-empty-directory
- Execute
touch some-webpage-file.html
to create a new webpage file in thenon-empty-directory
- Execute
touch some-mp3-file.mp3
to create a new mp3 file in thenon-empty-directory
-
Execute
ls
to verify that each of the child-resources are displayedchild-directory-1 child-directory-2 some-file some-mp3-file.mp3 some-text-file.txt some-webpage-file.html
Part 10 - Open File in nano
editor
- Execute
nano some-text-file.txt
to open the file namedsome-text-file.txt
in the nano-editor. - Enter your name in the nano editor.
- From the keyboard, hold
Ctrl
and pressX
to exit the editor - From the keyboard, press
Y
, when prompted toSave modified buffer
. - From the keyboard, press
Enter
, when prompted toSave File Name
. - Execute
cat some-text-file.txt
to verify that the contents entered in thenano
editor have been saved in thesome-text-file.txt
file.
Part 11 - Navigate Back to my-first-project
directory
- Execute
cd ..
to change to the parent directory of the current working directory...
is an alias recognized by the shell to reference theparent directory
.- A parent directory is the directory which contains another directory.
- (for example,
non-empty-directory
is a child directory _ of the _parent directory namedmy-first-project
)
- (for example,
- Execute
pwd
to verify that you have navigated to the directory properly. - Execute
ls
to verify this directory contains a directory namedempty-directory
andnon-empty-directory
.
Part 12 - Delete empty-directory
- Execute
rmdir ./empty-directory
to delete the empty directory- Note: - The
rmdir
command cannot delete a non-empty directory
- Note: - The
- Execute
ls
to verify that this directory no longer contains a directory namedempty-directory
Part 13 - Delete non-empty-directory
- Execute
rmdir ./non-empty-directory
to verify that a directory that is not empty cannot be deleted via the commandrmdir
. - Execute
ls
to verify that the current working directory still contains a directory namednon-empty-directory
- Execute
rm -rf ./non-empty-directory
to delete the the directory containing the content created inPart 9
andPart 10
- Execute
ls
to verify that this directory no longer contains a directory namednon-empty-directory
Part 14 - Fetching Command History
- Execute
history
to display the list of all the commands that have been executed in this terminal instance. - Execute
history > submission.txt
to pipe the output of thehistory
command to a file namedsubmission.txt
- piping is a mechanism for injecting data from one place to another
- Execute
cat submission.txt
to verify that thesubmission.txt
file contains the expected contents.