Last active
May 4, 2024 00:34
-
-
Save devwax/7e6a0018337e6670df194be0b4804f87 to your computer and use it in GitHub Desktop.
Bash Terminal 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
# copy dir contents to another dir | |
# https://askubuntu.com/a/86891 | |
cp -a source/. dest/ | |
# https://docs.gitlab.com/ee/user/ssh.html | |
ssh-keygen -t ed25519 -C "<comment>" | |
# SSH Public Key Setup | |
Copy public key to clipboard | |
pbcopy < ~/.ssh/id_rsa.pub | |
On Remote server add public key to .ssh/authorized_keys | |
chmod 600 .ssh/authorized_keys | |
chmod 700 .ssh/ | |
# Copy local file to remote dir | |
scp file.php user@255.255.255.255:/home/.../public_html/ | |
# (reverse order for remote to local) | |
scp user@255.255.255.255:/home/.../public_html/file.php . | |
# Watch all files in current dir | |
sass --watch . | |
# Find directories with large disk usage | |
du -hs * | sort -h | |
# Disk inodes, etc | |
df -i | |
# Tar gzip files and folders | |
# Preview tar | |
tar c public_html | tar t | |
# Compress a directory | |
tar -pczf wp-admin.tar.gz wp-admin | |
# Exclude patterns while compressing a directory | |
tar -pczf wp-content.tar.gz wp-content --exclude="*/plugins" --exclude="*/uploads" --exclude="*/themes" | |
# Extract | |
# https://linuxize.com/post/how-to-extract-unzip-tar-gz-file/ | |
tar -xvf filename.tar.gz | |
# Server-to-server file transfer | |
wget https://domain.com/wp-content/filename.tar.gz | |
# Search all PHP files containing string recursively | |
# https://superuser.com/a/584432/699121 | |
grep -r --include=*.php "search string" /path/to/dir | |
# find files by name recursively | |
find . -name "*file*" | |
# Watch debug.log for changes in real-time | |
tail -f debug.log | |
# Delete debug.log from CLI w/ PHP | |
# (sometimes necessary if ftp or ssh user doens't have permission to do so) | |
php -r 'unlink("./debug.log");' | |
# htaccess to display remote /uploads/ images and assets on a local server to avoid having to download them all. | |
# Note: Place in dir: /wp-contnet/uploads/ and ignore in git | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule (.*) https://www.domain.org/wp-content/uploads/$1 | |
# wp-cli garbage collection and other useful commands | |
wp elementor flush_css; | |
wp elementor update db; | |
wp cache flush; | |
wp plugin install "[plugin-name]" --activate; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment