Before the graphical user interface we are so accustomed to use in our computers existed, the way of interacting with a computer was to use the Command Line to command a program to do what you want it to do by writing your orders “in the form of successive lines of text” or… Command lines :)
Ok, I know what you are thinking:
Why on earth would I want to learn to use this obscure old school thing if I can just point and click stuff in my computer to open folder, files, move them around, save them, rename them or delet them?
Well, it turns out that the Command Line - formally known as Command Line Interface or Command Language Interpeter (CLI) - is more ubiquitous and present than ever if you work with information and software (that’s you):
It may seem confusing at first but when you get the hang of it, it’s like you have superpowers in the tip of your fingers.
The tools of command line are Terminal in Linux and Mac; and Command Prompt or PowerShell, in Windows.
This tutorial will include the most basic commands, and, if you want a more complete and technical tutorial, access this tutorial, by David Baumgold. He called the command line “the ultimate seat of power on your computer”.
For this tutorial you will need:
The following commands are, basically, a way to get around your computer, create files, delete them and move them. You can do this things in the more friendly user interface of your operating system, but it is a good thing to know these basic commands here.
When you start the command line tool, you will generally be within the main user directory. To go to another directory (folder), you have to use the cd
command:
cd MyFolder/MuSubfolder/MuSubfolder2
To come back to the main directory, use just cd
.
To come back one step, for instance MuSubfolder2
to MuSubfolder
, type cd ..
.
To see what is within a foder, use the ls
command when you are inside the folder you want. You can also use a more structured command to see a better organized list:
ls -l ~/MyFolder
in Mac and Linux and dir
in Windows.
Once inside a directory, if you want to create another directory there, the basic command is mkdir
, or make directory, followed by the name you want to give this directory.
mkdir MyNewDirectory
To create more than one directory at once, just use space between the names of the folders you are creating.
To create a new file within a directory, use the touch
command, followed by the file name and extension.
touch ThisIsTextFile.txt
or touch ThisIsDataFile.csv
In Windows, use the copy con
command.
To copy a file you will need to use the cp
command in Mac and Linux and copy
in Windows, and then the directory you want to copy it to.
cp ~/Desktop/ThisIsTextFile.txt ~/Documents
or copy ThisIsTextFile.txt c:/Documents
To move a file or directory, you have to use the mv
command, followed by the directory you can send the object to.
`mv ~/Desktop/MyFile.rtf ~/Documents/MyDocFolder
To remove or delete files, use the rm
command. Be very careful to use this command, as all decisions are final - no second change in the trash bin.
rm MyFile.rtf
in Mac and Linux and del MyFile.rtf
in Windows.
To install some applications on your computer, you will need to use sudo
command in Mac and Linux, of the runas
command in Windows.
In a Mac or Linux, to install or update applications, you have to use the apt-get
command.
sudo apt-get install MySoftware
To update an existing application: sudo apt-get upgrade
When you want to clear your command line of all the messy code, use the clear
command, in Max or Linux, or cls
in Windows.
For the Windows reference and some other tricks, visit Master Ruby website. You can also dig deeper in the Code Academy course, if that is your thing.