1. Launch Disk Utility (Cmd + Shift + U).
2. Select USB device (must be 8 GB or larger) and go to Erase tab.
3. For Format select Mac OS Extended (Journaled).
4. For Name type OSX and press Erase.
5. Wait to complete the process and then close the application.
6. Go to App Store and download a copy of Mac OS X.
7. Launch Terminal app.
8. For Lion, Mountain Lion, Mavericks, Yosemite and El Capitan (for Sierra, see below), copy and paste this comand into Terminal window:
sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia –volume /Volumes/OSX –applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app –nointeraction
9. Type your admin account password when prompted, and then press Return.
10. The Terminal window displays the progress of the process. It will take up to 30 minutes or so, depending on your hardware specifications.
11. Wait until you see the text Copy Complete. Done.
12. Now type exit and press Return
Now you have a bootable OS X 10.11 El Capitan installer drive!
13. For Sierra, copy and paste this comand into Terminal window. The Terminal will tell you that it will erase your drive. To confirm that you want to continue, type Y and hit Return.
sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia –volume /Volumes/OSX –applicationpath /Applications/Install\ macOS\ Sierra.app
If you want to install a fresh copy of the system (well, first you should make a backup of your important files), you have to Restart your Mac, press Option key (Alt) and choose the installer drive.