How can I delete files in recovery mode using Terminal on my OS X main partition? I need to delete a folder otherwise my mac won't boot. How can I do this in recovery mode or whatever it's called using Terminal commands?
Boot into recovery mode, mount volume, and open Terminal


Boot to recovery mode by holding CommandR right after starting your Mac before the Apple logo appears.
Go into Disk Utility and check that your target disk volume is mounted. Mount it if it's not already mounted. 
Close Disk Utility, and open Terminal from Utilities menu.


Removing files from Terminal

Enter cd /Volumes then ls to list all mounted volumes.

Enter, e.g., cd Volume_Name/Users/&lt;username&gt;/path/to/parent_directory with parent_directory being the directory containing the target directory you want to delete.

Be careful, as you have nothing restricting you from deleting required system files! Unless otherwise necessary, you should only delete files from your home directory (/Volumes/&lt;Volume_Name&gt;/Users/&lt;username&gt;/)

Example: If you want to delete a folder "xyz" in "Macintosh HD" (the example name of your main volume) enter cd "Macintosh HD/Users/username", replacing username with your user name.

Then enter ls again to list all files and directories to be sure that you are in the correct working directory.

Then enter rm -r folder_to_delete or rm -rf folder_to_delete


-r: Removes a folder and its content recursively.
-rf: Removes a folder and its content recursively, attempts to remove the files without prompting for confirmation, regardless of the file’s permissions, and ignore any errors.


Example: If you want to delete a folder "xyz" and all containing files and folders enter: rm -r xyz