First Steps

16
First Steps

Transcript of First Steps

First Steps

Working with the Command Line

Open Command Line

● Windows: Enter „cmd“ in your search box → open cmd.exe

● MacOs: open Spotlight-Search by pressing command & empty line → enter „Terminal“

● Linux: Programme → Zubehör → Terminal or:Programme → System → Terminal

Directory Structure

Navigation CommandsMeaning of the command

Windows Linux/MacOS

Show current directory

cd pwd

List all files and subdirectories in the current directory

dir ls

Change directory cd cd

Current directory . .

The directory one above the current directory

.. ..

Create a new directory

Command: mkdir directoryname

Practise:1. Navigate to Desktop2. Create a new directory named Testdir there3. Now you can see this new directory on your desktop!4. You can also test if it has worked by using ls/dir

Creating some files for our Practise

Create a file „test1.txt“ containing „This is a test“

Create a file „test2.txt“ containing „Hello World!“

Copy files Command:

Practise: 1. Copy test1.txt to Desktop2. Copy test2.txt to Desktop and rename it into hello.txt3. Copy test2.txt to Desktop and rename it into hello.txt again → You will be asked, whether you want to overwrite the existing file

Effect Example

Copy test.txt into the Desktop directory

copy C:\Users\user\Documents\test.txt C:\Users\user\Desktop

Windows

cp /Users/user/Documents/test.txt /Users/user/Desktop Linux/MacOS

Copy test.txt into the Desktop directoy and rename it

copy C:\Users\user\Documents\test.txt C:\Users\user\Desktop\new.txt

Windows

cp /Users/user/Documents/test.txt /Users/user/Desktop/new.txt

Linux/MacOS

Move files Command:

Practise: 1. Move test1.txt and hello.txt into the directory Testdir, which you created previously.2. rename hello.txt to test2.txt again using mv

Effect Example

move test.txt into the Desktop directory

move C:\Users\user\Documents\test.txt C:\Users\user\Desktop

Windows

mv /Users/user/Documents/test.txt /Users/user/Desktop

Linux/MacOS

rename test.txt to new.txt move C:\Users\user\Documents\test.txt C:\Users\user\Desktop\new.txt

Windows

mv /Users/user/Documents/test.txt /Users/user/Desktop/new.txt

Linux/MacOS

Delete files and directories

Command

Practise1. Remove test1.txt so that Testdir only contains test2.txt.2. Remove Testdir and the file it contains.

Effect Example

Delete a file del C:\Users\user\Documents\test.txt Windows

rm /Users/user/Documents/test.txt Linux/MacOS

Delete a directory rmdir /S C:\Users\user\Documents\Testdirectory Windows

rm -r /Users/user/Documents/Tesdirectory Linux/MacOS

Summary

Effect Windows Linus/MacOS

Current directory . .

The directory one above the current one

.. ..

Change directory cd cd

Copy copy cp

Delete file del rm

Delete directory rmdir /S rm -r

List all documents and directories of the current directory

dir ls

Move move mv

Show current directory cd pwd

Show user name whoami whoami

Commandline Tutorials

https://tutorial.djangogirls.org/en/intro_to_command_line/

https://www.learnenough.com/command-line-tutorial/basics

https://lerneprogrammieren.de/kommandozeile/ (German)

Install Python

1. Download Python installer here: https://www.python.org/downloads/

2. Open the Python installer and follow it's instructions

Our first python program and how to run it on the command line!

1.Enter IDLE (Integrated Development and Learning Environment) in your search field and open it.

2. Then open a new file:→ File → New File

Our first python program and how to run it on the command line!

3. Write the command you see in the picture in your python file

4. Save your file under your desktop and name it hello.py → File → Save as

5. Open your commandline again and navigate to your Desktop

6. enter python hello.py

Python Tutorials

https://docs.python.org/3/contents.html

https://www.programiz.com/python-programming/tutorial

https://py-tutorial-de.readthedocs.io/de/python-3.3/interpreter.html (German)