Operating System 2nd Year Bachelor TP - Discovery of The Shell and CLI
Operating System 2nd Year Bachelor TP - Discovery of The Shell and CLI
Another way to interact with the system is to use a terminal (or console) where you can type
commands (which are nothing other than programs). The program you interact with to run the
commands is called the shell in Linux and CLI (Command Line Interpreter) in windows.
It just waits for you to ask it to execute a command to do so. You tell him that you have finished typing
a command by pressing the Enter key.
The shell or CLI tells you that it is ready by displaying a prompt (or prompt), usually the
dollar character ($) for LINUX or higher (>) for WINDOWS, at the beginning of the line.
The general form of a command line is often (but not always) the following:
Options
- "simple" commands often allowing to manipulate files on the hard disk and which display their
result directly in the shell (ls, cp,…). These commands, since they use the shell for their
interactions, cannot be executed outside of a terminal,
- “more sophisticated” commands that do not use the shell ou CLI (konqueror, gedit,
etc.). These programs can also be run using a GUI icon,
- “internal “ commands (built-in commands) which allow you to use certain facilities offered by
the shell ou CLI (alias, exit, etc.).
Exercise 2 - Directories:
o Create an OP folder in your homedir, then a TP1 and TP2 folders inside it?
o Display the contents of this folder OP?
o Move to the TP1 folder?
o Create an Exercise 1 folder in the TP1 folder? What's going on? Correct the error?
o Delete the TP2 folder?
o Create two files presentation1.txt and presentation2.txt in the Exercise1 folder?
o Write inside the presentation1.txt file this text: "this is a test"
o Give a command that displays the content of the presentation1.txt file?
o Copy the presentation1.txt file into the OP folder?
o Add a text of your choice to the presentation2.txt file?
o Give a command that displays the first three lines of the presentation2.txt file and Give
a command that displays the second to last line of the same file?
o Rename presentation2.txt file with presentation3.txt file?
o Add the phrase "Thank you for everything" in the presentation3.txt file.
Ex – 1)
a) ls C: \
b) Pwd
c) absolute path specifies the location from the root directory whereas a relative path is
related to the current directory
d) man Command Displays the User manual of any Command that we can run on the
terminal
f) Recycle Bin is the storage of all the deleted files from everywhere on your computer, on
the other hand, the $Recycle.Bin folder is the storage of the deletions from the specific
drive only.
g) No we cannot retrieve because it don’t use recyclbin
h) cat filename.
Displays the contents of the file "filename" on your terminal.
i) tilde is used to reference our home directory
j) No, but most of them
2
Ex- 2)
1) mkdir op
mkdir op\TP1,TP2
mkdir op\TP2
2) cat op
3) mv op\TP1 TP2
4) mkdir op\TP1\ Exercise 1
mkdir op\TP1\ “Exercise 1”
5) rm op\TP2
6) New-Item op\TP1\ Exercise 1\ presentation1.txt, presentation2.txt,
7) Set-Content op\TP1\ Exercise 1\ presentation1.txt ‘this is a test’
8) Cat op\TP1\ Exercise 1\ presentation1.txt
9) Copy-Item "C:\op\TP1\ Exercise1 presentation1.txt " -Destination "C:\op"
10) Set-Content op\TP1\ Exercise 1\ presentation2.txt ‘Hello’
11) Cat op\TP1\ Exercise 1\ presentation1.txt -Head 3
Cat op\TP1\ Exercise 1\ presentation1.txt -Tail 2
12) Mv op\TP1\ Exercise 1\ presentation2.txt presentation3.txt
13)Add-Content c: \op\TP1\ Exercise 1\ presentation2.txt "Thank you for
everything"