Command : df -h
How to check size of directory Ubuntu
du -sh <directory path>
example : du -sh /var/www/html/
Check size of current directory
Go to that directory using cd command and run following command:
du -sh
sh: /usr/bin/rm: Argument list too long
When directory have lots of file and you run rm-Rf ci_session* command. You got this error.
Solution:
find . -name ‘ci_session*’ | xargs rm
RDP connection Ubuntu
Install rdesktop on ubuntu 20.04
sudo apt update
Install ubuntu-desktop if not installed
sudo apt install ubuntu-desktop
Install rdesktop
sudo apt install rdesktop
Connect to server
rdesktop -u <username> -f <hostname OR IP address>
eg. rdesktop -u rudrait -f 192.168.1.128
Bitnami AWS MySql root login
Default login information saves to file : /opt/bitnami/bitnami_credentials
Open the file and get the password.
Connect via SSH
ssh -i /path/of/key.pem bitnami@[IP-ADDRESS]
Login to mysql
mysql -u root -p
Enter the password you got from bitnami_credentials
Now you are logged in as root user into mysql database.
Change ownership of files/direcotry
Change ownership of single file :
sudo chown username:groupname path/to/file/filename
Example : sudo chown developer:www-data /var/www/html/info.php
Change ownership of multiple files of specific extension :
sudo chown -R username:groupname path/to/files/*.ext
Example : sudo chown -R developer:www-data /var/www/html/*.php
Change ownership of a directory:
sudo chown -R username:groupname /path/of/directory
Example : sudo chown -R developer:www-data /var/www/html/laravel
Add IP Address condition in PHP
If you want to run some PHP code on live website and don’t want to show it’s effect to others
if($_SERVER["REMOTE_ADDR"]=='122.123.123.12'){// Your PHP code
}
Eg. :
if($_SERVER["REMOTE_ADDR"]=='122.180.87.84'){
die("Just for testing");
}
Connect to ssh server using terminal
- Connect with username and password :
ssh username@[IP-ADDRESS]
Example : ssh rudra@192.168.12.12
When it is connected it will ask for password. Enter your ssh user password.
2. Connect using ssh-key
Make your file permission 600
sudo chmod 600 /path/to/ssh-key-file
ssh -i [/path/to/ssh-key-file] username@[IP-ADDRESS]
Example : ssh -i /home/rudra/rudraitnetworks.pem rudra@192.168.12.12
You can use domain name instead of [IP-ADDRESS]