Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SciProg2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cprutean
SciProg2024
Commits
3fcd7f78
Commit
3fcd7f78
authored
1 year ago
by
cprutean
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
4d76fbd0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CourseNotes/TerminalWindow.ipynb
+197
-0
197 additions, 0 deletions
CourseNotes/TerminalWindow.ipynb
with
197 additions
and
0 deletions
CourseNotes/TerminalWindow.ipynb
0 → 100644
+
197
−
0
View file @
3fcd7f78
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"tt When developing programs in Linux it is easier to use the Terminal\n",
"window rather than windows interface, to do this either:\n",
"\n",
"1. click on the Terminal icon in the lower menu-bar, or,\n",
"\n",
"2. from the Menu select the Terminal icon from the left hand column of\n",
" icons.\n",
"\n",
"This will create a Terminal or Command Line window into which you can\n",
"type commands.\n",
"\n",
"webonly\n",
"\n",
"Old fashioned This looks like a very *old-fashioned* way to use a\n",
"computer, but it gives you an easier interface and by typing commands to\n",
"get to understand what you are *really* doing.\n",
"\n",
"Almost all programmers use the simple command interface, it is therefore\n",
"worth doing and the best place for novice programmers to start. It is\n",
"also the basis of the Jupyter-Notebook environment which is based on\n",
"command lines,\n",
"\n",
"Programmer is large scale projets frequenctly use an Indegrated\n",
"Development Environment (IDE) for example PyCharm or Eclipse. These give\n",
"an windows programming environment with integrated editor, debugger,\n",
"code checker and code version management system. There are useful, but\n",
"there is a signifiacnt overhead in learning to use the IDE which for\n",
"novice programmers obscures the actually programming task so in this\n",
"course we shall use:\n",
"\n",
"The Linux file system is a *tree* as shown below:\n",
"\n",
"It is divided into two parts, the *system* under the node and the *user*\n",
"files under the node.\n",
"\n",
"hone Under you each have directory (or folder) called\n",
"\n",
"/Home/s\\<yyxxxxx>\n",
"\n",
"where is your username. This is your directory and where you start when\n",
"you start the file browser or create a Terminal.\n",
"\n",
"All files in your directory and in the tree below belong to you, you can\n",
"create, move, copy and delete files as you wish. They are private to you\n",
"so cannot be read or modified by other users.\n",
"\n",
"webonly\n",
"\n",
"You can navigate your part of the file system starting from your\n",
"directory with the file browser as on any windows interface, but you\n",
"will need to so this from the Terminal Window.\n",
"\n",
"Here the important commands are:\n",
"\n",
"- $\\hookleftarrow$ will shown the *<u>p</u>resent <u>w</u>orking\n",
" <u>d</u>irectory*, so the directory that the Terminal Window is\n",
" looking at.\n",
"\n",
"- $\\hookleftarrow$ will *<u>l</u>i<u>s</u>t* the files in the *present\n",
" working director*\n",
"\n",
" more information The command $\\hookleftarrow$ will give you a *long\n",
" list* with more details about each file.\n",
"\n",
"- $\\hookleftarrow$ which will *<u>c</u>hange <u>d</u>irectory* into\n",
" the new directory .\n",
"\n",
"- $\\hookleftarrow$ will *move up* to the directory above. \n",
"\n",
"- $\\hookleftarrow$ will create a *<u>m</u>a<u>k</u>e a\n",
" <u>directory</u>* with the specified name.\n",
"\n",
"You should *play* wth these commands and make youself a sensible\n",
"directory structure and ensure you can *move about* in in without\n",
"getting lost.\n",
"\n",
"Remember to type $\\hookleftarrow$ (the return key) after every command\n",
"to execte it.\n",
"\n",
"Once you have started create file there are also a range of useful\n",
"commands to manipulate files, these are\n",
"\n",
"- $\\hookleftarrow$ will type the contents of the file to the screen\n",
" *screen at a time*, press for the next screen, to *quit*.\n",
"\n",
"- $\\hookleftarrow$ will make a *<u>c</u>o<u>p</u>y* od called\n",
"\n",
"- $\\hookleftarrow$ will *<u>m</u>o<u>v</u>e* to , so it does a\n",
" *rename*\n",
"\n",
"- $\\hookleftarrow$ will *<u>r</u>e<u>m</u>ove* or *delete* .\n",
"\n",
" **Note:** if you , is *really gone*, there is no safety *Trash\n",
" Basket* that you can fish your mistakes out-off, so *be careful!*\n",
"\n",
"webonly\n",
"\n",
"terse and obscure Yes Terminal commands are terse and obscure, but once\n",
"you have learnt them it is the fastest way to access your computer…you\n",
"are really learning a scripting language and once you do this you will\n",
"see the benefit.\n",
"\n",
"This is the way that progarmmers *actually* use their machines!\n",
"\n",
"To delete a files in a Windows system you have to\n",
"\n",
"1. find the file(s) in the window,\n",
"\n",
"2. click on them and drag it to the *Trash Basket*\n",
"\n",
"3. empty the *Teash basket*…,\n",
"\n",
"In the Terminal your type and it is *gone* and *really gone*.\n",
"\n",
"The process you will follow to develop your programs is:\n",
"\n",
"- Write the code is a text editor, here we will use `emacs`,\n",
"\n",
"- save the code to a file,\n",
"\n",
"- run the code from the command line,\n",
"\n",
"- update code in the editor as require and re-save,\n",
"\n",
"- re-run from the command line\n",
"\n",
"To edit the file you type in the Terminal Window\n",
"\n",
"emacs MyProgram.py &\n",
"\n",
"followed the Return, the $\\hookleftarrow$ key.\n",
"\n",
"1. The filename *must* have a extension, this tells the system and the\n",
" editor that is contains code.\n",
"\n",
"2. If the file exits, it will be edited, if not a new blank file will\n",
" be created.\n",
"\n",
"3. The is *essential*, it means run the editor in a new separate window\n",
" in the *background* so you can type additional commands to the\n",
" Terminal Window\n",
"\n",
"4. Note the command will *not* be executed intil you type Return\n",
"\n",
"To run the program you type in the Terminal Window:\n",
"\n",
"python3 MyProgram.py\n",
"\n",
"again followed by Return, the $\\hookleftarrow$ key.\n",
"\n",
"This will run the program, it will prompt you for any input you have\n",
"asked for via the calls in , display any output from statements, and\n",
"also from the *Traceback* if your program crashed, see\n",
"\n",
"- Download the programs from\n",
"\n",
"- run the program with $\\hookleftarrow$\n",
"\n",
"- Edit the program and *personalise it* by making in your name. (You\n",
" should be able to guess what to edit).\n",
"\n",
"Well done, you have just written you *first* program!!\n",
"\n",
"save Remember when you re-edit the file (to fix a bug!) you **MUST** do\n",
"a *Save Buffer* in to save the new version to disc before you try and\n",
"re-run the program."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id: tags:
tt When developing programs in Linux it is easier to use the Terminal
window rather than windows interface, to do this either:
1.
click on the Terminal icon in the lower menu-bar, or,
2.
from the Menu select the Terminal icon from the left hand column of
icons.
This will create a Terminal or Command Line window into which you can
type commands.
webonly
Old fashioned This looks like a very
*old-fashioned*
way to use a
computer, but it gives you an easier interface and by typing commands to
get to understand what you are
*really*
doing.
Almost all programmers use the simple command interface, it is therefore
worth doing and the best place for novice programmers to start. It is
also the basis of the Jupyter-Notebook environment which is based on
command lines,
Programmer is large scale projets frequenctly use an Indegrated
Development Environment (IDE) for example PyCharm or Eclipse. These give
an windows programming environment with integrated editor, debugger,
code checker and code version management system. There are useful, but
there is a signifiacnt overhead in learning to use the IDE which for
novice programmers obscures the actually programming task so in this
course we shall use:
The Linux file system is a
*tree*
as shown below:
It is divided into two parts, the
*system*
under the node and the
*user*
files under the node.
hone Under you each have directory (or folder) called
/Home/s
\<
yyxxxxx>
where is your username. This is your directory and where you start when
you start the file browser or create a Terminal.
All files in your directory and in the tree below belong to you, you can
create, move, copy and delete files as you wish. They are private to you
so cannot be read or modified by other users.
webonly
You can navigate your part of the file system starting from your
directory with the file browser as on any windows interface, but you
will need to so this from the Terminal Window.
Here the important commands are:
-
$
\h
ookleftarrow$ will shown the
*
<u>
p
</u>
resent
<u>
w
</u>
orking
<u>
d
</u>
irectory
*
, so the directory that the Terminal Window is
looking at.
-
$
\h
ookleftarrow$ will
*<u>l</u>i<u>s</u>t*
the files in the
*
present
working director
*
more information The command $\hookleftarrow$ will give you a *long
list* with more details about each file.
-
$
\h
ookleftarrow$ which will
*<u>c</u>hange <u>d</u>irectory*
into
the new directory .
-
$
\h
ookleftarrow$ will
*move up*
to the directory above.
-
$
\h
ookleftarrow$ will create a
*
<u>
m
</u>
a
<u>
k
</u>
e a
<u>
directory
</u>
*
with the specified name.
You should
*play*
wth these commands and make youself a sensible
directory structure and ensure you can
*move about*
in in without
getting lost.
Remember to type $
\h
ookleftarrow$ (the return key) after every command
to execte it.
Once you have started create file there are also a range of useful
commands to manipulate files, these are
-
$
\h
ookleftarrow$ will type the contents of the file to the screen
*screen at a time*
, press for the next screen, to
*quit*
.
-
$
\h
ookleftarrow$ will make a
*<u>c</u>o<u>p</u>y*
od called
-
$
\h
ookleftarrow$ will
*<u>m</u>o<u>v</u>e*
to , so it does a
*rename*
-
$
\h
ookleftarrow$ will
*<u>r</u>e<u>m</u>ove*
or
*delete*
.
**Note:** if you , is *really gone*, there is no safety *Trash
Basket* that you can fish your mistakes out-off, so *be careful!*
webonly
terse and obscure Yes Terminal commands are terse and obscure, but once
you have learnt them it is the fastest way to access your computer…you
are really learning a scripting language and once you do this you will
see the benefit.
This is the way that progarmmers
*actually*
use their machines!
To delete a files in a Windows system you have to
1.
find the file(s) in the window,
2.
click on them and drag it to the
*Trash Basket*
3.
empty the
*Teash basket*
…,
In the Terminal your type and it is
*gone*
and
*really gone*
.
The process you will follow to develop your programs is:
-
Write the code is a text editor, here we will use
`emacs`
,
-
save the code to a file,
-
run the code from the command line,
-
update code in the editor as require and re-save,
-
re-run from the command line
To edit the file you type in the Terminal Window
emacs MyProgram.py &
followed the Return, the $
\h
ookleftarrow$ key.
1.
The filename
*must*
have a extension, this tells the system and the
editor that is contains code.
2.
If the file exits, it will be edited, if not a new blank file will
be created.
3.
The is
*essential*
, it means run the editor in a new separate window
in the
*background*
so you can type additional commands to the
Terminal Window
4.
Note the command will
*not*
be executed intil you type Return
To run the program you type in the Terminal Window:
python3 MyProgram.py
again followed by Return, the $
\h
ookleftarrow$ key.
This will run the program, it will prompt you for any input you have
asked for via the calls in , display any output from statements, and
also from the
*Traceback*
if your program crashed, see
-
Download the programs from
-
run the program with $
\h
ookleftarrow$
-
Edit the program and
*personalise it*
by making in your name. (You
should be able to guess what to edit).
Well done, you have just written you
*first*
program!!
save Remember when you re-edit the file (to fix a bug!) you
**MUST**
do
a
*Save Buffer*
in to save the new version to disc before you try and
re-run the program.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment