Last active
February 3, 2022 23:25
-
-
Save eveevans/6b98783d6050921915ee3751b501192d to your computer and use it in GitHub Desktop.
Common Commands
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
## MYSQL | |
create database db_name character set utf8 collate utf8_general_ci; | |
repair table table_name; | |
drop database db_name; | |
mysql -uroot -p db_name < file.sql | |
grant ALL PRIVILEGES ON dbName.* to 'ironman'@'%'; | |
### describe table: | |
desc table; | |
## SCP | |
scp [email protected]:/home/path/file . | |
## Get the size of a file in bytes: | |
$ stat -c%s FILENAME | |
50000 | |
Copy the last 10% > Calculate 10% of that number, and copy the last ten percent: | |
$ tail -c 5000 FILENAME > DESTINATION | |
## Space on Disk | |
### Summary of all disk | |
df -h --total | |
### Per directory details | |
du -h --max-depth=2 . | |
## Utils | |
### Search on logs | |
grep '/api/request/string_to_search' production.log | |
# 3 lines before: | |
grep -B 3 '/api/request/string_to_search' production.log | |
# 3 lines after: | |
grep -A 3 '/api/request/string_to_search' production.log | |
# System Log | |
sudo tail -f /var/log/syslog | |
## Git | |
### Ignore from local changes but not from gitignore | |
# 1. Add the file to .git/info/exclude | |
# 2. Update Indexes: | |
git update-index --assume-unchanged config/database.yml | |
## Imagemagick | |
### Convert to progressive | |
convert -strip -interlace Plane -quality 80 input-file.jpg output-file.jpg | |
## Zip with password | |
zip -e archive_name.zip target_folder.txt | |
### Compress | |
tar -zcvf destination_name.tgz file_to_zip | |
### Uncompress | |
tar -zxvf myfile.tgz | |
### Execute tar on remote server and save it on local (Run this on local machine) | |
ssh [email protected] tar zcvf - /remote/server/folder > ./local_file.tgz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment