mix
Change folders and subfolders permission through SSH
If you want to change the permission 755 to only directory present under the /home/user/public_html/subfolder then use following command
On shell
root@gunjan[~]#cd /home/user/public_html/subfolder
root@gunjan[/home/user/public_html/subfolder ]#find . -type d -exec chmod 755 {} \;And if you want to change the permission 755 to only files present under the /home/user/public_html/subfolder then use following command
On shell
Do the following:
grep -rnw '/path/to/somewhere/' -e "pattern"-r or -R is recursive,
-n is line number, and
-w stands match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
htaccess redirect to https://www
#Rewrite any request to the domain to use www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]#Force to HTTPS:
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]Creating, checking and removing cookies
Creating:
setcookie('cookie-name', 'cookie-value', 0, '/');Checking:
isset($_COOKIE['cookie-name']);Removing:
setcookie('cookie-name', null, -1, '/');Using Javascript:
Regex - find specific number in string
For our purpose let's say I'm looking for number 1234:
([^0-9]|^)1234([^0-9]|$)Install Calibre from cli
sudo -v && wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"To temporarily set swap to 0
This will empty your swap and transfer all the swap back into memory. First make sure you have enough memory available by viewing the resources tab of gnome-system-monitor, your free memory should be greater than your used swap. This process may take a while, use gnome-system-monitor to monitor and verify the progress.
sudo swapoff -a
To set the new value to 0:
To turn swap back on:
sudo swapon -a
To permanently set swappiness to 0:
sudoedit /etc/sysctl.conf
Add this line vm.swappiness = 0
sudo shutdown -r now # restart system
Un tar in cli
tar -xvf yourfile.tar
How to export/import a MySQL database via SSH
To export a MySQL database, you need to use the mysqldump command. Here is the full command for exporting your database:
mysqldump -uUSERNAME -pPASSWORD DATABASE > backup.sql
To import a MySQl database, you need to use the mysql command. Here is the full command for importing a MySQL dump into a database:
mysql -uUSERNAME -pPASSWORD DATABASE < backup.sql
ssh Permission denied (publickey).
- when testing conection with git@bitbucket.org comes out an isues with Permission denied (publickey).
- eval `ssh-agent -s`; ssh-add-l - show me "The agent has no identities."
- ssh-add /home/atf/.ssh/atf_rsa - to add the new key.
- Then: ssh -vT git@bitbucket.org -> debug1: Authentication succeeded (publickey).
