PHP read file or folder outside www!

<img SRC="data:image/gif;base64,<?php echo base64_encode(file_get_contents("/home/pfs/uploads/Aa.png"));?>">

Run / Execute Command Using SSH

ssh user1@server1 date
Find out remote server disk space usage:
ssh user1@server1 'df -H'
Find out remote server kernel version and Linux distro names:
ssh root@nas01 uname -mrs

Bash file for getting cpu speed and temp of RaspberryPi

#!/bin/bash
clear
free && sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq && cat /sys/class/thermal/thermal_zone0/temp
ssh slaveNodeOne@192.168.0.201 free && sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq && cat /sys/class/thermal/thermal_zone0/temp
ssh slaveNodeTwo@192.168.0.202 free && sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq && cat /sys/class/thermal/thermal_zone0/temp
ssh slaveNodeThree@192.168.0.203 free && sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq && cat /sys/class/thermal/thermal_zone0/temp



# different cpu speed command:
#cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
#cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
#cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

Bash Shell

#!/bin/bash
clear
if [[  -z "$pn" ]]
then    
    echo "Not enough input, try again"
else
    scp -r $pn /home/masterNode/programming/MPI/
    scp -r $pn slaveNodeOne@192.168.0.201:/home/masterNode/programming/MPI/
    scp -r $pn slaveNodeTwo@192.168.0.202:/home/masterNode/programming/MPI/
    scp -r $pn slaveNodeThree@192.168.0.203:/home/masterNode/programming/MPI/
fi

RaspberryPi auto mount

To find a user's UID or GID in Unix, use the id command. To find a specific user's UID, at the Unix prompt, enter:
id -u username
Replace username with the appropriate user's username. To find a user's GID, at the Unix prompt, enter:
id -g username 
UUID=D9B8-B25E  /var/www/hdd    vfat  defaults,noatime,rw,auto,user,users,uid=1002,gid=1005  0   0

save and restart the system


change MYSQL localhost to your server IP address

open terminal
    ->vi /etc/mysql/my.cnf
   ->change bind-address    = 127.0.0.1 to bind-address    = *
   ->save it.
   ->/etc/init.d/mysql restart
   ->mysql u- root -p
   -> put your password

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' WITH GRANT OPTION;

mysql>FLUSH PRIVILEGES;
See user list:
   ->select host, user from mysql.user;

Delete user MYSQL:
DROP USER ‘demo’@‘localhost’;

Change location of MySQL databases phpmyadmin

NOTE: The following methods work for both Ubuntu Lucid LTS and Debian Squeeze versions of TurnKey FileServer. AppArmor seems disabled by default in the TKL version of Ubuntu, so no changes to AppArmor are needed

To change default location (/var/lib/mysql) of mysql databases using datadir in my.cnf (preferred method):
- /etc/init.d/mysql stop
- cd /var/lib/mysql
- ls -l (to check which databases are present in folder)
- mkdir /srv/storage/mysqldata
- chown -R mysql:mysql /srv/storage/mysqldata
- IMPORTANT: *Only* the databases need to be copied over to new location (i.e. do not copy over ib* files etc); therefore if we have 2 databases in /var/lib/mysql called 'mysql' and 'phpmyadmin' then we do:
- 'cp -r mysql /srv/storage/mysqldata/' and 'cp -r phpmyadmin /srv/storage/mysqldata/'
- chown -R mysql:mysql /srv/storage/mysqldata/*
- in /etc/mysql/my.cnf, *only* the 'datadir' line needs to be changed to: datadir = /srv/storage/mysqldata
- /etc/mysql/debian.cnf file should not be touched
- /etc/init.d/mysql start

To change default location (/var/lib/mysql) of mysql databases using mount-bind (alternative method):
- /etc/init.d/mysql stop
- mv /var/lib/mysql /var/lib/mysql_original (backup first for safety)
- mkdir /srv/storage/mysqldata
- cp -R /var/lib/mysql_original/* /srv/storage/mysqldata/
- mkdir /var/lib/mysql
- mount -o bind /srv/storage/mysqldata /var/lib/mysql
- chown -R mysql:mysql /var/lib/mysql
- /etc/init.d/mysql start

Is /etc/sudoers file only suppose to have read only permissions?

Yes, /etc/sudoers is supposed to have those permissions, being read-only for user and group, nothing else. The reason being that you aren't supposed to edit the sudoers file directly, but by using the visudo wrapper, which provides some sanity checking before writing a new sudoers file.

You can control what editor visudo uses by setting the VISUAL alt. EDITOR environment variable.

$ sudo EDITOR=vi visudo

Linux: Delete / Remove User Account

userdel userName

Howto: Linux Add User To Group

 useradd -G {group-name} username

How can I add a new user as sudoer using the command line?

 sudo adduser <username> sudo
sudo deluser pi to delete just the user account
You don’t have to, but if you want to remove the /home/pi directory as well, use…
sudo deluser -remove-home pi
 
Group membership is only evaluated upon login, so if the user is already logged in they'll have to log out and in before they can use their new permissions.
This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):
# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL

 

How do I change pi's password?

At the very least, you should change the password for the pi account, as anybody with a RPi will be able to log onto yours. To do this, run passwd from the command line and follow the prompts.

How do I change pi's username?

If, like me, you want to use your own name, you want to use usermod like this:
usermod -l newname -d newname -m oldname