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
Commandand pressSpaceto open the spotlight search. - in the search bar, enter
terminal
- hold
- To open the git-bash terminal in Windows OS
- press the
Windowskey 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
whoamiin 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 terminalcdis 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
pwdto print working directory.- The file path pointing to a directory with your username should be displayed in the terminal’s standard output.

- 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 devfrom the home-directory.mkdiris a command used to create a new directorydevis 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

- 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 devfrom the home directory. - Verify that the command has executed properly by executing
pwdto 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

- 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
Commandand pressSpaceto open the spotlight search. - in the search bar, enter
terminal
- hold
- To open the git-bash terminal in Windows OS
- press the
Windowskey to open windows search. - in the search bar, enter
git bash.
- press the

Part 2 - Change Directory to the dev directory
- Execute
cd ~/devto change the current working directory todev cd ~/devcan be read verbally as “change directory tohome. From herenavigate todirectory nameddev”cdis 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
pwdto display the current working directory to verify that the command has executed properly. - Execute
lsto verify the contents of this directory.
Part 3 - Create a New Project Directory
- Execute
mkdir my-first-projectfrom thedevdirectory to create a new directory namedmy-first-projectin thedevdirectory - Execute
lsto verify that the directory has been created properly. - Execute
cd ./my-first-projectto change the current working directory to the newly created directory. cd ./my-first-projectcan be read verbally as “change directory tocurrent working directory. From here,navigate todirectory namedmy-first-project”cdis 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
pwdto verify that you have navigated to the directory properly.
Part 4 - Create Directory Named empty-directory
- Execute
mkdir empty-directoryfrom themy-first-projectdirectory to create a new directory, namedempty-directory - Execute
lsto verify that the newly created directory, namedempty-directory, has been created in themy-first-projectdirectory. - Execute
cd ./empty-directoryto change the current working directory to the newly created directory - Execute
pwdto verify that you have navigated to the directory properly. - Execute
lsto 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-projectis a child directory of the parent directory nameddev)
- (for example,
- Execute
pwdto verify that you have navigated to the directory properly. - Execute
lsto verify this directory contains a directory namedempty-directory.
Part 7 - Create Directory Named non-empty-directory
- Execute
mkdir non-empty-directoryfrom themy-first-projectdirectory to create a new directory namednon-empty-directory. - Execute
lsto verify that the newly created directory, namednon-empty directoryhas been created in the directory namedmy-first-project. - Execute
cd ./non-empty-directoryfrom themy-first-projectdirectory to change the current working directory tonon-empty-directory. - Execute
pwdto verify that you have navigated to the directory properly.
Part 8 - Create Directories Within non-empty-directory
- Execute
mkdir child-directory-1to create a new directory in thenon-empty-directory - Execute
lsto verify that the newly created directory, namedchild-directory-1has been created in directory namednon-empty-directory.` - Execute
mkdir child-directory-2to create a new directory in thenon-empty-directory - Execute
lsto verify that the newly created directory, namedchild-directory-2has been created in directory namednon-empty-directory.`
Part 9 - Create Files Within non-empty-directory
- Execute
touch some-fileto create a new file in thenon-empty-directory - Execute
touch some-text-file.txtto create a new text file in thenon-empty-directory - Execute
touch some-webpage-file.htmlto create a new webpage file in thenon-empty-directory - Execute
touch some-mp3-file.mp3to create a new mp3 file in thenon-empty-directory -
Execute
lsto 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.txtto open the file namedsome-text-file.txtin the nano-editor. - Enter your name in the nano editor.
- From the keyboard, hold
Ctrland pressXto 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.txtto verify that the contents entered in thenanoeditor have been saved in thesome-text-file.txtfile.
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-directoryis a child directory _ of the _parent directory namedmy-first-project)
- (for example,
- Execute
pwdto verify that you have navigated to the directory properly. - Execute
lsto verify this directory contains a directory namedempty-directoryandnon-empty-directory.
Part 12 - Delete empty-directory
- Execute
rmdir ./empty-directoryto delete the empty directory- Note: - The
rmdircommand cannot delete a non-empty directory
- Note: - The
- Execute
lsto verify that this directory no longer contains a directory namedempty-directory
Part 13 - Delete non-empty-directory
- Execute
rmdir ./non-empty-directoryto verify that a directory that is not empty cannot be deleted via the commandrmdir. - Execute
lsto verify that the current working directory still contains a directory namednon-empty-directory - Execute
rm -rf ./non-empty-directoryto delete the the directory containing the content created inPart 9andPart 10 - Execute
lsto verify that this directory no longer contains a directory namednon-empty-directory
Part 14 - Fetching Command History
- Execute
historyto display the list of all the commands that have been executed in this terminal instance. - Execute
history > submission.txtto pipe the output of thehistorycommand to a file namedsubmission.txt- piping is a mechanism for injecting data from one place to another
- Execute
cat submission.txtto verify that thesubmission.txtfile contains the expected contents.