sudo wget https://repo.mysql.com/mysql-apt-config_0.8.29-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server -y
sudo rm mysql-apt-config_0.8.29-1_all.deb
mysqldump -u root -p --all-databases > all_data.sql
mysql -u root -p < all_data.sql
ssh-keygen
ssh-keygen -R <host>
systemctl --type=service --state=running
ps -A
certbot certonly --manual --preferred-challenges=dns
firewall-cmd --list-all
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --remove-port=80/tcp --permanent
firewall-cmd --list-ports
git checkout -b <branch-name>
git push origin -u <branch-name>
tar -cvf <archive-name.tar> folder-name/ #c - create, v - verbose, f - file
mongosh "mongodb://<user-name>:<password>@localhost:27017" # Connect to DB
use <db-name> # Use DB
db.<collection-name>.find() # Show all data in collection
db.<collection-name>.drop() # Drop collection
use admin
db.auth("username", "password") # Authenticate
db.<collection-name>.find({<field-name>: <value>}) # Show data with condition
db.<collection-name>.insertOne({<field-name>: <value>}) # Insert data
db.<collection-name>.updateOne({<field-name>: <value>}, {$set: {<field-name>: <value>}}) # Update data
db.<collection-name>.deleteOne({<field-name>: <value>}) # Delete data
mongodump --db <db-name> --username <user-name> --password <password> --authenticationDatabase=admin # Backup DB
mongorestore --db <db-name> --username <user-name> --password <password> --authenticationDatabase=admin <path-to-backup> # Restore DB
The CSV file have headers, for example:
name,age,city
Alice,25,New York
Bob,30,San Francisco
Charlie,28,Los Angeles
Let's assume the file is named data.csv
.
mongoimport
Run the command:
mongoimport --uri="mongodb://localhost:27017" --db mydatabase --collection users --type csv --file data.csv --headerline
Explanation:
--uri="mongodb://localhost:27017"
: Connects to MongoDB locally.--db mydatabase
: Specifies the database.--collection users
: Defines the collection to import into.--type csv
: Specifies the file type.--file data.csv
: Points to the CSV file.--headerline
: Uses the first line as field names (headers).Open MongoDB shell:
mongosh
Check your imported data:
use mydatabase
db.users.find().pretty()
Flag | Description |
---|---|
-X / --request |
Specify the HTTP method (e.g., GET, POST, PUT, DELETE). |
-d / --data |
Send data in a POST request. |
-H / --header |
Pass custom headers with the request. |
-o / --output |
Save the response to a file. |
-O |
Save the response to a file using the remote name. |
-L / --location |
Follow redirects. |
-i / --include |
Include HTTP response headers in the output. |
-s / --silent |
Silent mode (no progress bar or error messages). |
-S / --show-error |
Show error messages when -s is used. |
-f / --fail |
Fail silently (no output) on HTTP errors. |
-u / --user |
Specify user credentials for authentication. |
-k / --insecure |
Allow connections to SSL sites without certificates. |
readlink <pod-name> # follow the symbolic link and see where it point
> <file-name> # Delete all content of a file
wc -l <file-name> # Count number of lines in a file
md5sum $<file-name> # Checksum of a file on Linux
certutil -hashfile <file-name> MD5 # Checksum of a file on Windows
Ctrl A : Về đầu dòng
Ctrl Space ~ : Đổi input source
Click 3 lần: Bôi đen dòng
Ctrl Click dùng 1 ngón : Right click (Không dùng được khi chạy 1 số chương trình)
Click dùng 2 ngón : Right click
Ctrl + : Insert equation
Ctrl I : In nghiêng phần text trong trường hợp đang bôi đen text, bật tắt in nghiêng trong trường hợp không bôi đen
Ctrl Shift ~ : Tạo terminal mới
Command P : Mở file
Command Shift P : Mở Command Palette
Command Shift N : Mở cửa sổ VSCode mới
Command P : Tìm file
Command W : Đóng file đang mở
Option ↑ : Di chuyển code giữa các dòng
Command ← : Về đầu dòng
Command \ : Split Terminal
Check diff giữa 2 fileCtrl W : Text search
h
→ Move leftl
→ Move rightj
→ Move downk
→ Move up0
→ Move to the beginning of the line^
→ Move to the first non-blank character of the line$
→ Move to the end of the linew
→ Move to the beginning of the next worde
→ Move to the end of the current/next wordb
→ Move to the beginning of the previous wordgg
→ Move to the beginning of the fileG
→ Move to the end of the file:n
→ Move to line n
(e.g., :10
goes to line 10)/pattern
→ Search for pattern
forward?pattern
→ Search for pattern
backwardn
→ Repeat the last search forwardN
→ Repeat the last search backward:%s/old/new/g
→ Replace all occurrences of old
with new
in the file:s/old/new/
→ Replace the first occurrence of old
with new
in the current line:w
→ Save (write) the file:wq
or ZZ
→ Save and quit:q
→ Quit (fails if unsaved changes):q!
→ Quit without saving changes:e filename
→ Open filename
:r filename
→ Read the contents of filename
into the current file:n
→ Open the next file in the argument list:prev
→ Open the previous file in the argument list.
→ Repeat the last command:%!cmd
→ Run the file through an external command (e.g., :%!sort
to sort the file)Ctrl-g
→ Show the file name and current line/column information:set number
→ Show line numbers:set nonumber
→ Hide line numbers:x,y
→ Delete from line x to line y (including y)