Skip to content

Commit 934ba5c

Browse files
authored
Merge pull request #22 from amakarudze/master
Add Linux and Mac OS files, update Windows sections
2 parents d81a9df + f0ab101 commit 934ba5c

27 files changed

Lines changed: 3614 additions & 54 deletions

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default defineConfig({
1919
resolve: {
2020
alias: {
2121
'@config': '/src/config',
22+
'@': new URL('./src', import.meta.url).pathname,
2223
},
2324
},
2425
},

src/components/Section.astro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
const { title, id, collapse = false } = Astro.props;
3+
---
4+
5+
<details id={id} open={!collapse}>
6+
<summary>{title}</summary>
7+
<div class="section-body">
8+
<slot />
9+
</div>
10+
</details>
11+
12+
<style>
13+
details {
14+
margin: 1rem 0;
15+
}
16+
summary {
17+
cursor: pointer;
18+
font-weight: bold;
19+
}
20+
</style>

src/components/Sidebar.astro

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,28 @@ import Carousel from '../components/Carousel.jsx';
1919
</summary>
2020
<ul>
2121
<li><a href="/en/chromebook/">ChromeBook Installation</a></li>
22-
<li><a href="/en/linux/chapter1/">Chapter 1</a></li>
23-
<!-- more chapters -->
22+
<li><a href="/en/common/01_how_the_internet_works/">How the Internet works</a></li>
23+
<li><a href="/en/linux/02_intro_to_command_line/">Introduction to command line</a></li>
24+
<li><a href="/en/linux/03_python_installation/">Python installation</a></li>
25+
<li><a href="/en/common/04_code_editor/">Code editor</a></li>
26+
<li><a href="/en/linux/05_python_introduction/">Python introduction</a></li>
27+
<li><a href="/en/common/06_django/">What is Django?</a></li>
28+
<li><a href="/en/linux/07_django_installation/">Django installation</a></li>
29+
<li><a href="/en/linux/08_django_start_project/">Your first Django project!</a></li>
30+
<li><a href="/en/linux/09_django_models/">Django models</a></li>
31+
<li><a href="/en/linux/10_django_admin/">Django admin</a></li>
32+
<li><a href="/en/linux/11_deploy/">Deploy!</a></li>
33+
<li><a href="/en/common/12_django_urls/">Django URLs</a></li>
34+
<li><a href="/en/common/13_django_views/">Django views - time to create!</a></li>
35+
<li><a href="/en/common/14_html/">Introduction to HTML</a></li>
36+
<li><a href="/en/common/15_django_orm">Django ORM (Querysets)</a></li>
37+
<li><a href="/en/common/16_dynamic_data_in_templates/">Dynamic data in templates</a></li>
38+
<li><a href="/en/common/17_django_templates/">Django templates</a></li>
39+
<li><a href="/en/common/18_css/">CSS - make it pretty!</a></li>
40+
<li><a href="/en/common/19_template_extending/">Template extending</a></li>
41+
<li><a href="/en/common/20_extend_your_application/">Extend your application</a></li>
42+
<li><a href="/en/common/21_django_forms/">Django forms</a></li>
43+
<li><a href="/en/common/22_whats_next/">What's next?</a></li>
2444
</ul>
2545
</details>
2646

@@ -29,9 +49,28 @@ import Carousel from '../components/Carousel.jsx';
2949
<a href="/en/macos/">macOS</a>
3050
</summary>
3151
<ul>
32-
<li><a href="/en/macos/chapter1/">Chapter 1</a></li>
33-
<!-- more chapters -->
34-
52+
<li><a href="/en/common/01_how_the_internet_works/">How the Internet works</a></li>
53+
<li><a href="/en/macos/02_intro_to_command_line/">Introduction to command line</a></li>
54+
<li><a href="/en/macos/03_python_installation/">Python installation</a></li>
55+
<li><a href="/en/common/04_code_editor/">Code editor</a></li>
56+
<li><a href="/en/macos/05_python_introduction/">Python introduction</a></li>
57+
<li><a href="/en/common/06_django/">What is Django?</a></li>
58+
<li><a href="/en/macos/07_django_installation/">Django installation</a></li>
59+
<li><a href="/en/macos/08_django_start_project/">Your first Django project!</a></li>
60+
<li><a href="/en/macos/09_django_models/">Django models</a></li>
61+
<li><a href="/en/macos/10_django_admin/">Django admin</a></li>
62+
<li><a href="/en/macos/11_deploy/">Deploy!</a></li>
63+
<li><a href="/en/common/12_django_urls/">Django URLs</a></li>
64+
<li><a href="/en/common/13_django_views/">Django views - time to create!</a></li>
65+
<li><a href="/en/common/14_html/">Introduction to HTML</a></li>
66+
<li><a href="/en/common/15_django_orm">Django ORM (Querysets)</a></li>
67+
<li><a href="/en/common/16_dynamic_data_in_templates/">Dynamic data in templates</a></li>
68+
<li><a href="/en/common/17_django_templates/">Django templates</a></li>
69+
<li><a href="/en/common/18_css/">CSS - make it pretty!</a></li>
70+
<li><a href="/en/common/19_template_extending/">Template extending</a></li>
71+
<li><a href="/en/common/20_extend_your_application/">Extend your application</a></li>
72+
<li><a href="/en/common/21_django_forms/">Django forms</a></li>
73+
<li><a href="/en/common/22_whats_next/">What's next?</a></li>
3574
</ul>
3675
</details>
3776

src/config/tutorial.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
export const PYTHON_VERSION = "3.12";
2-
export const DJANGO_VERSION = "5.2.8";
2+
export const DJANGO_VERSION = "5.2.8";
3+
export const PYTHON_RELEASE = "3.12.3";
4+
export const PYTHON_MIN_VERSION = "3.10";
5+
export const PYTHON_MIN_RELEASE = "3.10.13";
6+
export const PA_PYTHON_VERSION = "3.10";
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
---
2+
layout: ../../../layouts/TutorialLayout.astro
3+
title: Introduction to the command-line interface
4+
currentOS: linux
5+
order: 2
6+
---
7+
8+
# Introduction to the command-line interface
9+
10+
> For readers at home: this chapter is covered in the [Your new friend: Command Line](https://www.youtube.com/watch?v=jvZLWhkzX-8) video.
11+
12+
It's exciting, right?! You'll write your first line of code in just a few minutes! :)
13+
14+
__Let us introduce you to your first new friend: the command line!__
15+
16+
The following steps will show you how to use the black window all hackers use. It might look a bit scary at
17+
first but really it's just a prompt waiting for commands from you.
18+
19+
> **Note** Please note that throughout this book we use the terms 'directory' and 'folder' interchangeably
20+
but they are one and the same thing.
21+
22+
## What is the command line?
23+
24+
The window, which is usually called the __command line__ or __command-line interface__, is a text-based
25+
application for viewing, handling, and manipulating files on your computer. It's much like Windows Explorer
26+
or Finder on the Mac, but without the graphical interface. Other names for the command line are: *cmd*,
27+
*CLI*, *prompt*, *console* or *terminal*.
28+
29+
## Open the command-line interface
30+
31+
To start some experiments we need to open our command-line interface first.
32+
33+
It's probably under Applications → Accessories → Terminal, or Applications → System → Terminal, but that may
34+
depend on your system. If it's not there, you can try to Google it. :)
35+
36+
You now should see a white or black window that is waiting for your commands.
37+
38+
### The command-line Prompt
39+
40+
If you're on Linux, you probably see a `$`, like this:
41+
42+
`command-line`
43+
```
44+
$
45+
```
46+
47+
Each command will be prepended by a `$` and one space, but you should not type it. Your computer will do it
48+
for you. :)
49+
50+
> Just a small note: in your case there may be something like `ola@Olas-PC:~ $` before the prompt
51+
sign, and this is 100% OK.
52+
53+
The part up to and including the `$` or the `>` is called the *command line prompt*, or *prompt* for short.
54+
It prompts you to input something there.
55+
56+
In the tutorial, when we want you to type in a command, we will include the `$` or `>`, and occasionally
57+
more to the left. Ignore the left part and only type in the command, which starts after the prompt.
58+
59+
## Your first command (YAY!)
60+
61+
Let's start by typing this command:
62+
63+
`command-line`
64+
```
65+
$ whoami
66+
```
67+
68+
And then hit `enter`. This is our result:
69+
70+
`command-line`
71+
```
72+
$ whoami
73+
olasitarska
74+
```
75+
76+
As you can see, the computer has just printed your username. Neat, huh? :)
77+
78+
> Try to type each command; do not copy-paste. You'll remember more this way!
79+
80+
## Basics
81+
82+
Each operating system has a slightly different set of commands for the command line, so make sure to follow instructions for your operating system.
83+
84+
If you make a typo, you can use the left and right arrow keys to move your cursor, backspace and delete to edit the command. Most command lines don't support using the mouse to move the cursor.
85+
86+
Let's try this, shall we?
87+
88+
### Current directory
89+
90+
It'd be nice to know where are we now, right? Let's see. Type this command and hit `enter`:
91+
92+
`command-line`
93+
```
94+
$ pwd
95+
/Users/olasitarska
96+
```
97+
98+
> **Note:** 'pwd' stands for 'print working directory'.
99+
100+
You'll probably see something similar on your machine. Once you open the command line you usually start at
101+
your user's home directory.
102+
103+
---
104+
105+
### Learn more about a command
106+
107+
Many commands you can type at the command prompt have built-in help that you can display and read! For
108+
example, to learn more about the current directory command:
109+
110+
macOS and Linux have a `man` command, which gives you help on commands. Try `man pwd` and see what it says,
111+
or put `man` before other commands to see their help. The output of `man` is normally paged. Use the space
112+
bar to move to the next page, and `q` to quit looking at the help.
113+
114+
### List files and directories
115+
116+
So what's in it? It'd be cool to find out. Let's see:
117+
118+
`command-line`
119+
```
120+
$ ls
121+
Applications
122+
Desktop
123+
Downloads
124+
Music
125+
...
126+
```
127+
128+
### Change current directory
129+
130+
Now, let's go to our Desktop directory:
131+
132+
`command-line`
133+
```
134+
$ cd Desktop
135+
```
136+
137+
Note that the directory name "Desktop" might be translated to the language of your Linux account. If that's
138+
the case, you'll need to replace `Desktop` with the translated name; for example, `Schreibtisch` for German.
139+
140+
Check if it's really changed:
141+
142+
`command-line`
143+
```
144+
$ pwd
145+
/Users/olasitarska/Desktop
146+
```
147+
148+
Here it is!
149+
150+
> PRO tip: if you type `cd D` and then hit `tab` on your keyboard, the command line will automatically fill
151+
in the rest of the name so you can navigate faster. If there is more than one folder starting with "D", hit
152+
the `tab` key twice to get a list of options.
153+
154+
---
155+
156+
### Create directory
157+
158+
How about creating a practice directory on your desktop? You can do it this way:
159+
160+
`command-line`
161+
```
162+
$ mkdir practice
163+
```
164+
165+
`command-line`
166+
```
167+
$ cd practice
168+
$ mkdir test
169+
$ ls
170+
test
171+
```
172+
173+
Congrats! :)
174+
175+
---
176+
177+
### Clean up
178+
179+
We don't want to leave a mess, so let's remove everything we did until that point.
180+
181+
First, we need to get back to Desktop:
182+
183+
`command-line`
184+
```
185+
$ cd ..
186+
```
187+
188+
Using `..` with the `cd` command will change your current directory to the parent directory (that is, the
189+
directory that contains your current directory).
190+
191+
Check where you are:
192+
193+
`command-line`
194+
```
195+
$ pwd
196+
/Users/olasitarska/Desktop
197+
```
198+
199+
Now time to delete the `practice` directory:
200+
201+
> __Attention__: Deleting files using `del`, `rmdir` or `rm` is irrecoverable, meaning _the deleted files
202+
will be gone forever_! So be very careful with this command.
203+
204+
`command-line`
205+
```
206+
$ rm -r practice
207+
```
208+
209+
Done! To be sure it's actually deleted, let's check it:
210+
211+
`command-line`
212+
```
213+
$ ls
214+
```
215+
216+
### Exit
217+
218+
That's it for now! You can safely close the command line now. Let's do it the hacker way, alright? :)
219+
220+
`command-line`
221+
```
222+
$ exit
223+
```
224+
225+
Cool, huh? :)
226+
227+
## Summary
228+
229+
Here is a summary of some useful commands:
230+
231+
Command (Windows) | Command (Mac OS / Linux) | Description | Example
232+
----------------- | ------------------------ | -------------------------- | ---------------------------------------------
233+
exit | exit | close the window | **exit**
234+
cd | cd | change directory | **cd test**
235+
cd | pwd | show the current directory | **cd** (Windows) or **pwd** (Mac OS / Linux)
236+
dir | ls | list directories/files | **dir**
237+
copy | cp | copy file | **copy c:\test\test.txt c:\windows\test.txt**
238+
move | mv | move file | **move c:\test\test.txt c:\windows\test.txt**
239+
mkdir | mkdir | create a new directory | **mkdir testdirectory**
240+
rmdir (or del) | rm | delete a file | **del c:\test\test.txt**
241+
rmdir /S | rm -r | delete a directory | **rm -r testdirectory**
242+
[CMD] /? | man [CMD] | get help for a command | **cd /?** (Windows) or **man cd** (Mac OS / Linux)
243+
244+
These are just a very few of the commands you can run in your command line, but you're not going to use
245+
anything more than that today.
246+
247+
If you're curious, [ss64.com](https://ss64.com) contains a complete reference of commands for all operating systems.
248+
249+
## Ready?
250+
251+
Let's dive into Python!

0 commit comments

Comments
 (0)