How to find a directory by name
- find / -type d -iname 'dir_name'
How to find a line of text in a directory (-r for recursive and l to just show the file name)
- grep -rl "text-to-search" /path/to/dir/from/root/li>
MySQL Login (-p with no spaces)
- mysql -u username -pPASSWORD -h hostname
MySQL dump to another database (-p with no spaces, databases could be on same machine or could be a remote transfer, can also transfer to a file using >)
- mysqldump -uUSERNAME -pPASSOWRD DatabaseToExport| mysql -uUSERNAME -pPASSOWRD DatabaseNameToImportInto
Edit cron jobs (-l instead of -e for viewing the cron file, add sudo to edit the system jobs)
- sudo crontab -e
Vim controls
- vim
- x to delete
- to insert text:
- a, then chars to insert, esc when done
- shift-v to copy a whole line
- p to paste
- zero to get to the end of line, $ to get to the beginning (can use k and j also like in more)
- :wq to save and exit
- to delete whitespace (newlines, and fill with ~), use insert and press backspace
User management
- to add a user: useradd <name>
- to add a group: groupadd <name>
- to add a user an existing user to a new group: usermod -g <groupname> <username>
- to swith login status to root: sudo bash
- to switch users: su - <username>
- to allow certain binaries to be ran without root password: edit /etc/sudoers file using something like vim