<<

Carnegie Mellon

Unix Boot Camp (fun fact the plural of is Unices) (really)

Jenna MacCarley, Peter Pearson, Shashank Goyal 9/19/2015 (edited for PyLing by Reed Armstrong, 10/13/2015) Carnegie Mellon Connecting SSH Windows users: PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) Mac/ users: Use ‘ssh’ terminal ssh [email protected]

Files Windows: WinSCP (simple) or Tectia ( complicated) Mac/Linux: FileZilla, or ‘scp’ command at terminal: scp –r [email protected]:~myfolder /some/local/folder scp myfile.c [email protected]:~myfolder Carnegie Mellon Editing with emacs

■ Open: emacs [] ■ without a name, you get an page ■ to edit ■ Save: Control+x followed by Control+s ■ Undo: Control+x followed by u ■ : Control+x followed by Control+c ■ if you forget to save, it’ll ask you ■ Let’s edit our .bashrc files to set up Python! Carnegie Mellon Copying the corpus

a directory for the corpus files to go in ■ ■ Copy the files from the shared directory ■ ~naraehan/authorship/* ./ ■ * is a wildcard: lets us grab everything

Running Python scripts: ■ (Python 2) python2 myscript.py [] ■ (Python 3) python myscript.py [] Carnegie Mellon Some Nice Terminal Shortcuts

■ Pressing tab will autocomplete file and folder names! ■ Control+c will stop execution of your current program! ■ To exit IDLE: exit() ■ Control+r will let you search your command ! ■ Control+l will your screen! ■ Use the up and down arrow keys to scroll through your command history! Carnegie Mellon Linux file pathing

■ ~ is your HOME DIRECTORY ■ This is where you start from after you SSH in ■ On bash, you can also use $HOME ■ . is an for your PRESENT WORKING DIRECTORY! ■ .. is the file path for the PARENT DIRECTORY of your present working directory! ■ / is the file path for the -LEVEL DIRECTORY ■ You probably won’t use this too much on PSC Carnegie Mellon

- LiSt

■ Lists the files in the present working directory, or, if specified, dir. ■ tells you your Present Working Directory. Carnegie Mellon - Change Directory

■ Changes your present working directory to directory ■ Your main tool for navigating a Unix file system Carnegie Mellon mkdir - MaKe DIRectory

■ Makes a directory dirname in your present working directory. ■ Directories and folders are the same thing! Carnegie Mellon - MoVe

■ cp works similarly, but copies instead ■ for copying folders, use cp -r ■ dest can be into an existing folder (preserves name), or a file/folder of a different name ■ Also used to re-name files without moving them ■ src can be either a file or a folder Carnegie Mellon

■ Change permissions of a file or directory ■ u (owner), g (group), o (others), a (all) ■ + (add permissions), - (remove) ■ r (read), (), x (eXecute) Carnegie Mellon - ReMove

■ Essentially the delete utility ■ To remove an (empty) directory, use ■ To remove a folder and its contents, use rm -rf ▪ Please be careful. Don’t delete your project. ▪ There is no “Trash” here. It’s gone. Carnegie Mellon What’s in a file? (using )

■ less will give you a scrollable interface for viewing large files without editing them. ■ To something, use / ▪ To view the next occurrence, press n ▪ To view previous occurrence, press N ■ To quit, use q Carnegie Mellon

■ Compare files ■ file1 is < in the output; file2 is > ■ Could for qualitative technique comparisons or version differencing Carnegie Mellon man

■ What is that command? What are its arguments? What does this library do? Check to see if it has a ! ■ Pages viewed with less ■ Try it! ■ man ■ man ■ man ■ man man ■ etc. Carnegie Mellon