Useful Command Prompts

In the Java course I am taking our teacher uses the command line to program. I have started to get to grips with entering things in the command line. I have always been very scared of the terminal, but it is not so scary after all. A big hold back was knowing the commands, and what they do. So I have made a very basic list below of commands and described briefly what they do. It is an ongoing list, which I will continue to add to as the course goes on.

This is a list I’ll use for reference, if you happen to stumble upon this list and want to use some of the prompts please do a bit more research first as I am by no means an expert and don’t want to break your computer!

GENERAL

Prompt Short Long
cd [name of directory] change directory change the folder you are in, like clicking on a folder
cd .. go back a directory moves you back one folder, like the back arrow
ls list directory see all the files / folders in the current directory you are in
mv move a file move a file to another directory e.g. mv ~/Desktop/hello.abc /Folder/somewhere_else
mv move a directory move a file to another directory e.g. mv ~/Desktop/myFolder /Folder/somewhere_else
mv + rename move and rename move a file to another directory and rename it e.g. mv ~/Desktop/hello.abc /Folder/somewhere_else/goodbye.abc
mv *many move lots move multiple file to another directory e.g. mv ~/Desktop/*.abc /Folder/somewhere_else
cp copy a file copy a file to another directory e.g. cp ~/Desktop/hello.abc ~/Documents
cp -R copy a directory copy a whole directory to another directory e.g. cp ~/Desktop/myFolder ~/Documents
cp + rename copy and rename copy a file to another directory and rename it e.g. cp ~/Desktop/hello.abc ~/Documents/goodbye.abc
cp *many copy lots copy multiple files into to another directory e.g. cp ~/Desktop/*.abc ~/Documents
mkdir make directory when in directory e.g.  mkdir MyDirectory can make multiple directories e.g. mkdir MyDirectory1 MyDirectory2 MyDirectory3

VIM

vi [name of file] open in vim opens the file with name you insert in vim so that you can edit
(when in vim) i edit in vim like actually opening a file so you can edit
(when in vim) :w save (write) like saving a file
(when in vim) :q quit vim get out of vim and back into the “terminal”

IMAGEMAGICK
Some – – – > resources.

convert = makes new file
mogrify = overwrites file

mogrify resize modify size warning! will overwrite the file, make a copy first! modifies the file in various ways. need to be in the directory e.g. <mogrify -resize 1000 hello.jpg (will make width 1000)
convert convert the file format e.g. convert rose.jpg rose.png

COMPILE / RUN

javac [name of file] compile in java like compile / flash
java [name of file] run java program like running a sketch, need to be in the same directory as the java file
python [name of file] run python program like running a sketch, need to be in the same directory as the python file