Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default defineConfig({
resolve: {
alias: {
'@config': '/src/config',
'@': new URL('./src', import.meta.url).pathname,
},
},
},
Expand Down
20 changes: 20 additions & 0 deletions src/components/Section.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
const { title, id, collapse = false } = Astro.props;
---

<details id={id} open={!collapse}>
<summary>{title}</summary>
<div class="section-body">
<slot />
</div>
</details>

<style>
details {
margin: 1rem 0;
}
summary {
cursor: pointer;
font-weight: bold;
}
</style>
49 changes: 44 additions & 5 deletions src/components/Sidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,28 @@ import Carousel from '../components/Carousel.jsx';
</summary>
<ul>
<li><a href="/en/chromebook/">ChromeBook Installation</a></li>
<li><a href="/en/linux/chapter1/">Chapter 1</a></li>
<!-- more chapters -->
<li><a href="/en/common/01_how_the_internet_works/">How the Internet works</a></li>
<li><a href="/en/linux/02_intro_to_command_line/">Introduction to command line</a></li>
<li><a href="/en/linux/03_python_installation/">Python installation</a></li>
<li><a href="/en/common/04_code_editor/">Code editor</a></li>
<li><a href="/en/linux/05_python_introduction/">Python introduction</a></li>
<li><a href="/en/common/06_django/">What is Django?</a></li>
<li><a href="/en/linux/07_django_installation/">Django installation</a></li>
<li><a href="/en/linux/08_django_start_project/">Your first Django project!</a></li>
<li><a href="/en/linux/09_django_models/">Django models</a></li>
<li><a href="/en/linux/10_django_admin/">Django admin</a></li>
<li><a href="/en/linux/11_deploy/">Deploy!</a></li>
<li><a href="/en/common/12_django_urls/">Django URLs</a></li>
<li><a href="/en/common/13_django_views/">Django views - time to create!</a></li>
<li><a href="/en/common/14_html/">Introduction to HTML</a></li>
<li><a href="/en/common/15_django_orm">Django ORM (Querysets)</a></li>
<li><a href="/en/common/16_dynamic_data_in_templates/">Dynamic data in templates</a></li>
<li><a href="/en/common/17_django_templates/">Django templates</a></li>
<li><a href="/en/common/18_css/">CSS - make it pretty!</a></li>
<li><a href="/en/common/19_template_extending/">Template extending</a></li>
<li><a href="/en/common/20_extend_your_application/">Extend your application</a></li>
<li><a href="/en/common/21_django_forms/">Django forms</a></li>
<li><a href="/en/common/22_whats_next/">What's next?</a></li>
</ul>
</details>

Expand All @@ -29,9 +49,28 @@ import Carousel from '../components/Carousel.jsx';
<a href="/en/macos/">macOS</a>
</summary>
<ul>
<li><a href="/en/macos/chapter1/">Chapter 1</a></li>
<!-- more chapters -->

<li><a href="/en/common/01_how_the_internet_works/">How the Internet works</a></li>
<li><a href="/en/macos/02_intro_to_command_line/">Introduction to command line</a></li>
<li><a href="/en/macos/03_python_installation/">Python installation</a></li>
<li><a href="/en/common/04_code_editor/">Code editor</a></li>
<li><a href="/en/macos/05_python_introduction/">Python introduction</a></li>
<li><a href="/en/common/06_django/">What is Django?</a></li>
<li><a href="/en/macos/07_django_installation/">Django installation</a></li>
<li><a href="/en/macos/08_django_start_project/">Your first Django project!</a></li>
<li><a href="/en/macos/09_django_models/">Django models</a></li>
<li><a href="/en/macos/10_django_admin/">Django admin</a></li>
<li><a href="/en/macos/11_deploy/">Deploy!</a></li>
<li><a href="/en/common/12_django_urls/">Django URLs</a></li>
<li><a href="/en/common/13_django_views/">Django views - time to create!</a></li>
<li><a href="/en/common/14_html/">Introduction to HTML</a></li>
<li><a href="/en/common/15_django_orm">Django ORM (Querysets)</a></li>
<li><a href="/en/common/16_dynamic_data_in_templates/">Dynamic data in templates</a></li>
<li><a href="/en/common/17_django_templates/">Django templates</a></li>
<li><a href="/en/common/18_css/">CSS - make it pretty!</a></li>
<li><a href="/en/common/19_template_extending/">Template extending</a></li>
<li><a href="/en/common/20_extend_your_application/">Extend your application</a></li>
<li><a href="/en/common/21_django_forms/">Django forms</a></li>
<li><a href="/en/common/22_whats_next/">What's next?</a></li>
</ul>
</details>

Expand Down
6 changes: 5 additions & 1 deletion src/config/tutorial.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export const PYTHON_VERSION = "3.12";
export const DJANGO_VERSION = "5.2.8";
export const DJANGO_VERSION = "5.2.8";
export const PYTHON_RELEASE = "3.12.3";
export const PYTHON_MIN_VERSION = "3.10";
export const PYTHON_MIN_RELEASE = "3.10.13";
export const PA_PYTHON_VERSION = "3.10";
251 changes: 251 additions & 0 deletions src/pages/en/linux/02_intro_to_command_line.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
---
layout: ../../../layouts/TutorialLayout.astro
title: Introduction to the command-line interface
currentOS: linux
order: 2
---

# Introduction to the command-line interface

> For readers at home: this chapter is covered in the [Your new friend: Command Line](https://www.youtube.com/watch?v=jvZLWhkzX-8) video.

It's exciting, right?! You'll write your first line of code in just a few minutes! :)

__Let us introduce you to your first new friend: the command line!__

The following steps will show you how to use the black window all hackers use. It might look a bit scary at
first but really it's just a prompt waiting for commands from you.

> **Note** Please note that throughout this book we use the terms 'directory' and 'folder' interchangeably
but they are one and the same thing.

## What is the command line?

The window, which is usually called the __command line__ or __command-line interface__, is a text-based
application for viewing, handling, and manipulating files on your computer. It's much like Windows Explorer
or Finder on the Mac, but without the graphical interface. Other names for the command line are: *cmd*,
*CLI*, *prompt*, *console* or *terminal*.

## Open the command-line interface

To start some experiments we need to open our command-line interface first.

It's probably under Applications → Accessories → Terminal, or Applications → System → Terminal, but that may
depend on your system. If it's not there, you can try to Google it. :)

You now should see a white or black window that is waiting for your commands.

### The command-line Prompt

If you're on Linux, you probably see a `$`, like this:

`command-line`
```
$
```

Each command will be prepended by a `$` and one space, but you should not type it. Your computer will do it
for you. :)

> Just a small note: in your case there may be something like `ola@Olas-PC:~ $` before the prompt
sign, and this is 100% OK.

The part up to and including the `$` or the `>` is called the *command line prompt*, or *prompt* for short.
It prompts you to input something there.

In the tutorial, when we want you to type in a command, we will include the `$` or `>`, and occasionally
more to the left. Ignore the left part and only type in the command, which starts after the prompt.

## Your first command (YAY!)

Let's start by typing this command:

`command-line`
```
$ whoami
```

And then hit `enter`. This is our result:

`command-line`
```
$ whoami
olasitarska
```

As you can see, the computer has just printed your username. Neat, huh? :)

> Try to type each command; do not copy-paste. You'll remember more this way!

## Basics

Each operating system has a slightly different set of commands for the command line, so make sure to follow instructions for your operating system.

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.

Let's try this, shall we?

### Current directory

It'd be nice to know where are we now, right? Let's see. Type this command and hit `enter`:

`command-line`
```
$ pwd
/Users/olasitarska
```

> **Note:** 'pwd' stands for 'print working directory'.

You'll probably see something similar on your machine. Once you open the command line you usually start at
your user's home directory.

---

### Learn more about a command

Many commands you can type at the command prompt have built-in help that you can display and read! For
example, to learn more about the current directory command:

macOS and Linux have a `man` command, which gives you help on commands. Try `man pwd` and see what it says,
or put `man` before other commands to see their help. The output of `man` is normally paged. Use the space
bar to move to the next page, and `q` to quit looking at the help.

### List files and directories

So what's in it? It'd be cool to find out. Let's see:

`command-line`
```
$ ls
Applications
Desktop
Downloads
Music
...
```

### Change current directory

Now, let's go to our Desktop directory:

`command-line`
```
$ cd Desktop
```

Note that the directory name "Desktop" might be translated to the language of your Linux account. If that's
the case, you'll need to replace `Desktop` with the translated name; for example, `Schreibtisch` for German.

Check if it's really changed:

`command-line`
```
$ pwd
/Users/olasitarska/Desktop
```

Here it is!

> PRO tip: if you type `cd D` and then hit `tab` on your keyboard, the command line will automatically fill
in the rest of the name so you can navigate faster. If there is more than one folder starting with "D", hit
the `tab` key twice to get a list of options.

---

### Create directory

How about creating a practice directory on your desktop? You can do it this way:

`command-line`
```
$ mkdir practice
```

`command-line`
```
$ cd practice
$ mkdir test
$ ls
test
```

Congrats! :)

---

### Clean up

We don't want to leave a mess, so let's remove everything we did until that point.

First, we need to get back to Desktop:

`command-line`
```
$ cd ..
```

Using `..` with the `cd` command will change your current directory to the parent directory (that is, the
directory that contains your current directory).

Check where you are:

`command-line`
```
$ pwd
/Users/olasitarska/Desktop
```

Now time to delete the `practice` directory:

> __Attention__: Deleting files using `del`, `rmdir` or `rm` is irrecoverable, meaning _the deleted files
will be gone forever_! So be very careful with this command.

`command-line`
```
$ rm -r practice
```

Done! To be sure it's actually deleted, let's check it:

`command-line`
```
$ ls
```

### Exit

That's it for now! You can safely close the command line now. Let's do it the hacker way, alright? :)

`command-line`
```
$ exit
```

Cool, huh? :)

## Summary

Here is a summary of some useful commands:

Command (Windows) | Command (Mac OS / Linux) | Description | Example
----------------- | ------------------------ | -------------------------- | ---------------------------------------------
exit | exit | close the window | **exit**
cd | cd | change directory | **cd test**
cd | pwd | show the current directory | **cd** (Windows) or **pwd** (Mac OS / Linux)
dir | ls | list directories/files | **dir**
copy | cp | copy file | **copy c:\test\test.txt c:\windows\test.txt**
move | mv | move file | **move c:\test\test.txt c:\windows\test.txt**
mkdir | mkdir | create a new directory | **mkdir testdirectory**
rmdir (or del) | rm | delete a file | **del c:\test\test.txt**
rmdir /S | rm -r | delete a directory | **rm -r testdirectory**
[CMD] /? | man [CMD] | get help for a command | **cd /?** (Windows) or **man cd** (Mac OS / Linux)

These are just a very few of the commands you can run in your command line, but you're not going to use
anything more than that today.

If you're curious, [ss64.com](https://ss64.com) contains a complete reference of commands for all operating systems.

## Ready?

Let's dive into Python!
Loading