After the week 1 lecture there are some shorter videos (shorts) explaining specific topics that were mentioned in the previous lecture. Doug Lloyd is the speaker.
The shorts discuss the following topics:
- CS50 IDE (integrated developer environment)
- Command Line
- Data Types
- Conditional Statements
The CS50 IDE is an amazon/cloud 9 web application allowing each student to run a dedicated “computer.” Because everything runs on CS50’s platform, every environment is the same, and any updates can be applied to every student. Imagine if every student had a different kind of computer, trying to install the right programs, the right versions and keeping everyone on the same page would be very difficult.
One of the new things I learned from this short is the outline menu on the right hand side of the interface. It will collect a list of all the functions in your program, so you can click from there to jump to a function. Pretty handy.
Another thing I didn’t realize was the collaboration feature, which allows you to send a link to another user and pair program allowing that person read/write access. I haven’t tried it but from what i’ve read once you share with another user it acts like a google doc where you see everything being typed in realtime. Also there are ways to indicate which pieces of code were written by the collaborator(s). Very cool!
Some other features are dragging windows to create different arrangements on the screen. The above image has a text editor with a terminal below it, and maybe you want them side by side instead. This is possible by dragging them with the mouse. Finally there is a cloud 9 command to create new files more quickly than using the mouse. Just type “c9 open” followed by the name you want to call the file, it will open up a tab named already, and once you save you’ll be prompted to confirm saving within the current directory. Also if you want to learn about the other c9 commands just type “c9“ in the terminal, which will give you a list of available commands.
The CS50 IDE is a cloud application that runs the Ubuntu operating system. This is a version of Linux, which means we can use Linux/Unix style terminal commands.
When I first started using the terminal, I didn’t understand how it could be more efficient than using a mouse and graphical interface. I now realize it can be faster if you know what you’re doing. I still feel more inclined to use the mouse and GUI.
This short goes through some common commands you would use to navigate around your files and folders:
- ls – displays a listing of the files and folders in the directory you are in
- pwd – will display the path name to the directory you are in
- cd – cd will take you to another directory by typing cd “directory path.”
- “cd ~” will take you back to your user’s home directory
- “cd ..” will take you into the parent directory
- If there is a folder foo in the current directory you are in you just type “cd foo” to jump into that folder.
- mkdir – this command is like creating a new folder. Just add the name of the folder afterwards to create it, as in “mkdir mynewfolder“
- cp – cp means copy, and allows you to copy a file and even copy entire directories. Here are some examples:
- cp myfile.txt mycopy.txt – this will take myfile.txt and make a copy called mycopy.txt
- cp -r myfolder myfoldercopy – this will take the folder and recursively copy, so you’ll end up with a duplicate of the entire directory including the files within.
- rm – this is the remove command which allows you to delete both single files, and entire directories. Be careful with this command, it can do a lot of damage if you delete something by accident. In the terminal, there is no trash can.
- rm myfile.txt – permanently deletes myfile.txt
- rm -r myfolder – remove with the recursive flag. I should note in this case if there are files within myfolder, the terminal will ask you if you are sure you want to delete each file. If you do not want to be asked for every file, maybe because there are many files, you can add another flag.
- rm -rf myfolder – adding the f flag means force, so there is no prompt asking for permission to delete. It will recursively delete everything right away. As a note you can write flags in different ways so “rm -f -r” or “rm -r -f” both work as well as “rm -rf.”
- mv – this is the move command and works for both moving files and renaming them.
- mv myfile.txt newname.txt – this will take myfile.txt and rename it newname.txt
- mv myfile.txt ../myfile.txt – this will move myfile to the parent directory, or one folder up in the hierarchy.
- mv myfile.txt /absolute/path/myfolder/myfile.txt – this will move the file to an absolute path that i’ve given the command.
Doug says there are a few more commands coming up in later lessons which might be worth exploring so i’m more prepared. There isn’t a lesson here just a list.
TBH I kind of have an idea of what each of these already does…
- chmod – means change mode, and when run will affects the permissions of files or directories, or both.
- rmdir – wasn’t sure on this one, just googled it and apparently removes directories that are empty.
- sudo – pretty sure it means super user do. Gives temporary super user rights, which means you have permissions over everything.
- ln – I think it means link. Kind of like adding a shortcut to a file.
- man – this can be used before more commands to bring up some documentation about the command. Example “man chmod” will give tou some information about the command and all the flags it comes with.
- clear – clears out the terminal window of all the previous text, giving you a nice clean blank window.
- touch – touch is the command to create a new file
- diff – I am pretty sure this is a program that takes 2 files and compares them for any differences. Helpful when comparing versions of a file.
- telnet – had to google this one, apparently is a way to talk with other computers over a network. Telnet is the client and you can connect to a host like myhost.com for example. It is not encrypted however, which is why ssh has become the more common way of making these types of connections.
And that’s all for now!