Intro
Videos
- Intro and Motivation: https://www.youtube.com/watch?v=WfPPBUiTF4k
- Command Line Intro Part 1: https://www.youtube.com/watch?v=yYbxzj1A7QI
- Command Line Intro Part 2: https://www.youtube.com/watch?v=-WCe3th6NyI
Note: if you want quick notes from a video to review what was discussed, just check out the "about" section on the YouTube page.
Command Line Basics
- Change directories to /bin (the "bin" directory in the root of your filesystem).
- List out the files in that directory
- Notice some familiar things -- rm, ls, cp, etc. This is one place where executable "binaries" live.
- List all of the files in your home directory even though you aren't in your home directory. Make sure that you can see hidden files (files that start with a dot). Also, make sure that you can see the size of each file.
- Change directories back to your home.
- Change directories so that you are in the parent of your home.
- Print your current working directory. Where are you in the file system?
- Go back to your home.
- Make a file called hello.py using your text editor. It should have one line: print 'Hello, World!'
- Run that file.
- Make a directory called "code" in your home. Move hello.py into code.
- Look at the manual page for a command called "top". Try running that command. I haven't told you how to quit, but you know one way to get out of it!
- Make a copy of hello.py and call it helloshebang.py. Edit that file and add the following line as your very first line (before the print statement): #!/usr/bin/env python
- Try to run it using ./helloshebang.py. It won't work!
- Run chmod u+x helloshebang.py and try again. Now it should work. To see the change, try running ls -l, and look at the permissions.
- You probably don't need hello.py any more, so remove it.
- Install zsh.
- Close your terminal (using only the keyboard!)
Learn Your Editor
You'll be spending a lot of time using vim or emacs, so you should get familiar with them! You can either choose one, or you can try out both. Remember, you can run the vim tutorial with vimtutor, or you can run the emacs tutorial by starting emacs and typing ctrl+h, t.
Customize Your Shell and Editor
Intro
Although there are already many different types of shells with different features, you can customize your shell even more by creating a configuration file. These files let you change the way your commonly used programs look, feel, and function. Configuration files usually start with a dot (so they're hidden unless you do ls -a) and live in your home directory. The config file for vim is .vimrc, for emacs is .emacs, for zsh is .zshrc, and for bash is .bashrc (and .bash_profile).
Figure out what you want in your config files, and start customizing! Those files might not exist yet, so feel free to create them with your text editor.
Sam's Files
If you're looking for inspiration or if you just want to use someone else's files, Sam has his .vimrc and .zshrc heavily commented and available online at https://github.com/samking/config-files. It is useful to have config files in a repo online so that you can keep them coordinated between different computers. For instance, my Linux install on my work computer and my personal computer both wanted to have the same files, and they all might sometimes update those files.
After you use git to check out the files, you might want to run the setup-startup-scripts.bash file and make the customizations that it tells you to. Since Sam doesn't use bash or emacs, if you want to use those, you'll have to manage for yourself.
If you want to use zsh, you can run zsh on its own by typing zsh at the command line. However, you may also want to change your default login shell to zsh. You can normally use chsh to change your shell; if that doesn't work, you might need to add an exec command (like the .login file in Sam's config files).
Suggestions
In general, poking around to see what's possible is good. If you need some suggestions on things to do, however, try the following to get started with your shell:
- Change the default shell if desired
- Change the shell's default text editor if desired.
- Change the shell prompt to include the directory path, the time, and colors.
- Make an alias. If you accidentally type "sl" instead of "ls" (and you don't want a steam locomotive), you could make an alias to fix those typos.
- Add the directory ~/bin to the PATH environment variable so that you can put executables that you want to run in there.
- Make it so that it saves the command history after you close and re-open your shell.
And your editor:
- Make sure that it formats things how you like
- When you press the tab key, it inserts spaces (useful in Python to avoid mixing tabs and spaces. Also useful to conform to style guides that don't use tabs)
- It has syntax highlighting
- It has line numbers
- It automatically wraps lines at 80 characters
- Make it so the temp files and backup files that are automatically created when you edit a file go a centralized location rather than the project directory
- Make it so that it saves the undo history after you close and re-open your text editor.
- Enable the mouse in the terminal version of your text editor
- Make it easy to paste into the terminal version of your text editor.