Last active
March 5, 2019 05:49
-
-
Save GideonBabu/55a4a1b6f7e1e27790cd3260272bef41 to your computer and use it in GitHub Desktop.
Useful Shell Commands for Web Development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compress: tar -czvf name-of-archive.tar.gz /path/to/directory-or-file | |
Extract: tar -xzvf archive.tar.gz | |
compress with exclusion of some folders: | |
tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz . | |
To find the files using it's name: | |
find <path> -name "filename-with-extension" | |
Unzip a ZIP file: | |
unzip file.zip -d destination_folder | |
+++ | |
chown | |
chown owner-user file | |
chown owner-user:owner-group file | |
chown owner-user:owner-group directory | |
chown options owner-user:owner-group file | |
+++ | |
Tail command | |
tail -n 10 error.log - Shows the last 10 lines from an error log. | |
tail -f error.log - Shows all newly added lines from a log file in real-time on the shell. | |
tail -n 100 error.log | more | |
- Shows the last 100 lines a single line at a time using the "more" command. | |
Useful for showing more lines than will fit in your shell window. | |
Press the space bar to view the next line. | |
ctrl + c - Quits tail and returns to the command line. | |
+++ | |
MySQL import and export: | |
mysqldump -u USERNAME -p DATABASE > backup.sql --- export to the file | |
mysqldump -u USERNAME -p DATABASE < backup.sql -- import the db from file | |
If it's an entire DB, then: | |
$ mysqldump -u [uname] -p db_name > db_backup.sql -- you will be asked to enter password next | |
If it's all DBs, then: | |
$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql | |
If it's specific tables within a DB, then: | |
$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql | |
You can even go as far as auto-compressing the output using gzip (if your DB is very big): | |
$ mysqldump -u [uname] -p[pass] db_name | gzip > db_backup.sql.gz | |
If you want to do this remotely and you have the access to the server in question, then the following would work (presuming the MySQL server is on port 3306): | |
$ mysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name > db_backup.sql | |
It should drop the .sql file in the folder you run the command-line from. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment