Lab 0: Intro, Setup¶
Vim Basics¶
vim
is a text editor included on the hive machines and many UNIX-based distributions.
Note: We'll be using Vim in most of our examples and documentation, but we have no hard requirement on which text editor you use; you're welcome to pick whatever you're comfortable with, but you should know how to use at least one terminal-based text editor.
To open a file from your current directory, pass the file name to Vim:
Bash | |
---|---|
1 |
|
To open a file from another directory, use a relative or absolute path:
Bash | |
---|---|
1 |
|
Some useful Vim commands:
Note: these commands are preceded by Esc because you'll need to press the escape key on your keyboard to switch you out of your current mode. For example, if I'm inserting (typing) into a file and want to save, I'd have to hit Esc to get out of insert mode, then type :w to save my file. If you aren't in a mode (i.e. you've just opened your file) you don't need to hit escape first, but it won't hurt :)
By default, Vim doesn't enable mouse support or line numbers. If you want these:
Open up ~/.vimrc
(vim ~/.vimrc
)
To enable your mouse, add a new line containing set mouse=a
To enable line numbers, add a new line containing set number
Save and quit. Try opening your vimrc file again
Vim has many more configuration options available -- feel free to experiment with Vim resources you find online!
We also have a Vim for CS61C guide that you can reference.
CLI Keyboard Shortcuts¶
scp - "Secure Copy"¶
The scp program is used for copying files between computers using the SSH protocol.
Sometimes, you may want to get individual files or entire folders from the hive machines onto your local system, or vice versa. You can do this by using scp:
Bash | |
---|---|
1 |
|
To specify a remote source or destination, use username@host:path
. To specify a local destination, just use path. As an example:
Bash | |
---|---|
1 |
|
Assuming my username is cs61c-???
, the above command would connect to s275-1 and copy ~/some-folder/example.txt
on my instructional account to ~/Downloads/example.txt
on my local machine.
If I wanted to copy the other direction (from my local machine to a hive machine) I would use:
Bash | |
---|---|
1 |
|
scp by default only works with files.
To copy folders, you need to tell scp to "recursively" copy the folder and all its contents, which you can do with the -r
flag:
Bash | |
---|---|
1 |
|
Pay attention to the slashes: writing some-folder
will copy the folder itself and files inside, while some-folder/
will only copy the files inside.