Work Documentation
This page contains my work troubleshoot nor work documentation
SSH / Linux Commands
How to ZIP Folder
zip -r filename.zip foldername
ZIP Folder exclude a specific subdirectory
zip -r filename.zip foldername -x "fullpath/exclude/foldername1/*" "fullpath/exclude/foldername2/*"
UNZIP Folder to the current directory
unzip filename.zip -d .
Delete All Files starting with 'myfile' and ending in '.txt'
rm myFile*.txt
Delete a whole folder
rm -rf foldername/
Delete all files/folders in the current directory, without deleting the directory itself
rm -rf *
Find a certain file in the whole server
whereis filename `or` which filename
or
which filename
Copy file
cp filename filecopy
Source & Reference :
- https://www.siteground.com/tutorials/ssh/
- https://www.hostinger.com/tutorials/ssh/basic-ssh-commands
- https://cyberciti.biz/faq/linux-howto-unzip-files-in-root-directory/
Print out the last 10 lines
tailif filelog
Source & Reference :
Rename Folder
mv oldfolder newfolder
or use full path
mv /home/oldfolder /home/newfolder
Source & Reference :
Prettify JSON with curl on Terminal Linux or macOS
curl localhost:8080/employees/1 | json_pp
or use full path
curl localhost:8080/employees/1 | python -m json.tool
Source & Reference :
.HTACCESS Tutorials
- Disable Directory Listing Using .htaccess
Options -Indexes
- Enable .htaccess in httpd.conf or apache.conf
Change AllowOverride line
1<Directory "/var/www/htdocs">2 AllowOverride None
to
1<Directory "/var/www/htdocs">2 AllowOverride All
- Forcing HTTPS on All Traffic
One of the many functions you can perform via .htaccess is the 301 redirects, which permanently redirects an old URL to a new one. You can activate the feature to force HTTPS on all incoming traffic by following these steps:
1RewriteEngine On 2RewriteCond %{HTTPS} off 3RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
- Forcing HTTPS on a Specific Domain
Let’s say that you have two domains: http://yourdomain1.com and http://yourdomain2.com. Both domains access the same website, but you only want the first one to be redirected to the HTTPS version. In this case, you need to use the following code:
1RewriteEngine On 2RewriteCond %{HTTP_HOST} ^yourdomain1.com [NC] 3RewriteCond %{HTTPS} off 4RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
- Forcing HTTPS on a Specific Folder
The .htaccess file can also be used to force HTTPS on specific folders. However, the file should be placed in the folder that will have the HTTPS connection.
1RewriteEngine On 2RewriteCond %{HTTPS} off 3RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Source & References :