Terminal basics

Terminal basics

terminal = text interface to a computer

other names: console, shell, command line

variants:

  • cmd (Windows)
  • powershell (Windows)
  • bash (Unix, Linux, MacOS, [Windows])

Basic commands in bash and powershell

  • get the current directory: pwd (print working directory)
  • list directory content: ls
  • change current directory: cd

Special paths

These paths have special meanings:

  • . = current directory
  • .. = parent directory
  • ~ = user's personal directory

example terminal commands:

pwd
ls .
cd ..
ls .
cd ~
pwd
ls .

Running commands

Commands and programs may be run by typing their name, e.g. ls, explorer, git, node, python, ...

Running commands: arguments

After the command name / program name we can add some arguments

positional arguments:

  • ls .
  • mv a.txt archive/a.txt

Running commands: arguments

options:

  • ls . -a (bash)
  • ls . -Force (powershell)
  • node -h (short option name with single dash)
  • node --help (long option name with double dash)

named arguments via options (separated via a space or equal sign):

  • node --title=playground
  • node --eval "console.log(1);"
  • git commit -m "test_message"

Command history

up arrow (and down arrow) to go through previous commands

ctrl + R to search through previous commands

Auto completion

auto completion via tab key:

  • powershell and cmd: complete with first found option
  • bash: completes unambiguous commands, lists options otherwise

Auto completion

in powershell:

exp + tab → Expand-Archive

expl + tab → explorer.exe

Auto completion

in bash (under Windows):

a + tab + tab → lists all commands starting with a (exit long lists via Q)

  • cd ~/ + tab + tab (all possibilites in personal folder)
  • cd ~/d + tab + tab (all possibilities starting with d)
  • cd ~/de + tab (~/Desktop/)