Summary: Learning about Rsync and SSH, Tmux basics
How to check CPU/Memory/Disk Space on a server
- CPU:
top
command to check the cpu usage. - Memory:
top
andfree
command can be used to check memory usage. - Disk Space:
df
command can be used to check disk space
# CPU
$ top
# Memory
$ top
# or
$ free
# Disk space in kilobyte
$ df
# Disk space in MB / GB
$ df -h
# Disk space used by specific folder / drive
$ df -h /folder_path
Rsync and SSH basics
Rsync is a very flexible network-enabled syncing tool. Due to its ubiquity on Linux and Unix-like systems and its popularity as a tool for system scripts, it’s included on most Linux distributions by default.
Understanding Rsync Syntax
# empty directory called dir2. To sync the contents of dir1 to dir2
# on the same system, you will run rsync and use the -r flag, which
# stands for “recursive” and is necessary for directory syncing:
$ rsync -r dir1/ dir2
# sample command for local
$ rsync -avzhP <source path> <destination path>
# sample command for remote
$ rsync -avzhP <user@IP:path/in/remote/system> <destination>
SSH basics
SSH stands for Secure Shell. It is a cryptographic network protocol used for secure remote login, remote command execution, and other secure network services between two networked computers. SSH encrypts data transmitted over the network, providing confidentiality and integrity of data exchanged between the client and server machines.
Sample commands
# connect to remote server
$ ssh root@primarydomain.com
# generate new keys
$ ssh-keygen -t rsa -b 4096 -C "user@myPC" -N “” -f ~/.ssh/id_rsa
How to sync one site with other using WP-CLI and rsync
- Run
wp db export filename.sql
from site’s root directory Rsync -avzhp ./filename.sql <destination/site/root/dir>
- From the new site’s root directory
wp db import filename.sql
Tmux basics
Tmux is a terminal multiplexer; it allows you to create several “pseudo terminals” from a single terminal. This is very useful for running multiple programs with a single connection, such as when you’re remotely connecting to a machine using Secure Shell (SSH).
Tmux features:
- Multiplexing: Tmux allows users to split a single terminal window into multiple panes, each running its own command or application.
- Session Management: Users can create and manage multiple Tmux sessions, each containing its own set of windows and panes.
- Window Management: Within a Tmux session, users can create and switch between multiple windows, each containing its own set of panes. This allows for organizing tasks and applications into separate windows for better organization and productivity.
Leave a Reply