# Command Line

Before we can begin discussing how to solve problems, we must first talk about how to run and test your code. To do that, we’ll first start off with using the command line.

The command line is just a program that lets you type commands to do things in your computer, like navigate folders, copy files, open and edit documents, run programs, etc. Historically, this was the only way computers were able to be used. There weren’t graphical interfaces yet.

We’ll also use the command line to compile and run our programs.

The great thing about the command line is that you can trust that you will always have access to basic command line tools in almost any contest environment (including the IOI of course). We’ll also go into a way of easily making your code work against data stored in files and saving your output to files.

For this section, we’ll only talk about the most basic operations. There’s much more you can do from the command line, but we’ll get to those in a future section. Right now, we just want to cover the bare minimum to start solving problems.

There are some major differences between using the command line on Windows and on Linux. For Mac users, you can follow along on the Linux path since the differences are minor. So please read the appropriate section based on your operating system.

## Windows

On Windows, you have two main choices of terminals: Command Prompt (cmd.exe) and PowerShell (PowerShell.exe). PowerShell is the newer (and more powerful) one. Command Prompt has a width limit of 80 characters, so it’s kind of annoying. Run them from the Start Menu or the Windows 10 search.

The important commands are as follows:

1. cd - change cirectory, use as cd C:\Users\Public\Downloads.
2. dir - list files in current directory, use as dir
3. copy - copy a file, use as copy a.txt b.txt
4. move - move a file from one place to another, use as move original.txt new.txt. Interestingly, this is also the command used to rename files.
5. del - delete a file, use as del a.txt
6. mkdir - make a new directory, use as mkdir new_directory

We encourage you to try these commands out. Your computer won’t break if you type a command wrong. You can hit the tab key to auto-complete.

## Linux and Mac

For Mac users, you can use the built-in Terminal, just search for it using Spotlight. You can also opt to download something called iTerm2 which is a much improved version of Terminal with lots of useful new features. For Linux users, you’ll most likely be using the Gnome Terminal if you’re on Ubuntu. (And if you’re not, you probably know what you’re doing anyway.)

The important commands are as follows:

1. cd - change cirectory, use as cd ~/Downloads.
2. ls - list files in current directory, use as ls
3. cp - copy a file, use as cp a.txt b.txt
4. mv - move a file from one place to another, use as mv original.txt new.txt. Interestingly, this is also the command used to rename files.
5. rm - delete a file, use as rm a.txt
6. mkdir - make a new directory, use as mkdir new_directory
7. rmdir - delete an empty directory, use as rmdir new_directory

Again, we encourage you to try these commands out. Your computer won’t break if you type a command wrong. You can hit the tab key to auto-complete.

You may have noticed that we did cd ~/Downloads. ~/ is the Linux shorthand for /home/user/ and is the Mac shorthand for /Users/user/. We’ll have a bigger discussion on Unix commands and the environment in the future, but this is enough for now.