Mount NFS Client

Problem:
You need to access to a Shared folder from other server from your raspberry PI, this folder is shared troncut the network using a NFS Server

Solution:
Follow the next commands to setup a NFS client in your Raspberry:


1.- Install the required software


sudo apt-get install nfs-common -y

2.- Create the local folder to associate the link between the current system and the remote folder


sudo mkdir -p /media/MyUSB/

3.- Add permission to NFS folder, change owner and group


sudo chown -R pi:pi /media/MyUSB/


4.- mount the folder

sudo mount serveripaddress:/remotefolder /media/MyUSB/
use "df" command to see if the folder is correctly mounted

5.- setup fstab

sudo nano /etc/fstab

add the next line to fstab file:

remoteserveripaddress:/remote/folder/   /media/MyUSB   nfs    rw  0  0
done, now reboot the system and then you will be able to see the shared content in the mounted drive /media/MyUSB

Notes:
- If you are able to see you NFS folder from other computer but you can't write to it, check that all users have the same ID and SGID than the owner for the shared folder in the server
- If you need to make any change, you can use sudo umount /dev/xxx  to unmount the unit and mount it again with the command sudo mount -a
- to list all mount units in the computer use the command df





Mount USB disk

Problem:
You need to use a USB disk with your Raspberry PI.

Solution:
Raspberry PI OS will recognize automatically your USB disk but you need to follow the next configuration steps to use it correctly.

1.- Check your current OS partitions.
sudo fdisk -l
2.- Create a shared forlder.
 sudo mkdir /media/MyUSB
 sudo chmod 777 /media/MyUSB

2.- Setup fstab file, this file store your mount configuration
sudo nano /etc/fstab
 Add one line to configure your USB disk, somethink like:
/dev/stda       /media/MyUSB    vfat    rw  0   0
/dev/stda    path to the USB sick
/media/MyUSB mount path where files are stored
vfat         FAT32 format



3.- Confirm an apply changes.
sudo mount -a
4.- Check current partition.
sudo df
Additional info:
To Remove the disk in save mode:
umount /dev/stda
Notes:
- Remember to change shared folder authorizations to 777, if not you will not be able to share it trough NFS or similar. 

Hardware:
In my test I use a 128 USB flash disk  from Philips and it works really well to manage file between the raspberry system. 

Remember that this will work not only with flash disk, also with external  USB hard disks.

Headless Installation

Problem:
You don't have any display to run the graphic interface and you need to install OS, configure the wifi and enable the remote ssh connection.

Solution:

1.- Download the OS image and save it into a SD.
from:



https://www.raspberrypi.org/documentation/installation/installing-images/README.md

2.- Burn the image to the SD using a software like balenaEtcher
https://www.balena.io/etcher/


2.- Setup the wifi adding the file “wpa_supplicant.conf” in boot folder.
network={ ssid="<Name of your WiFi>" psk="<Password for your WiFi>"}

3.- Setup SSH.
You only need to create an empty file named "ssh" in the boot file.


4.- Power off and power on your Raspberry and check your firewall to look for the last device connected to your Wireless Network, there you will be able to the the DNS name or IP address. 


5.- Download PuTTY and create a remote connection trough port 22 using SSH, raspbian default access is: pi/raspberry

4.- once you are logged in, you can change the administrator password using the following command:
sudo raspi-config

Source:
https://www.raspberrypi.org/documentation/configuration/wireless/headless.md



zip files

Problem:
You need to create a zip file for example to export a huge amount of files ina single export poroces trough ftp.

Solution:
Zip all files in a sinle one using the next commands:
zip -r filenamename DirectoryToZip
If you face problems like command not found, check if you have zip installed 
sudo apt-get install zip unzip

Default location of the index.html file

Problem:
You have installed a web server inside raspberry pi using Gnginx ( oficial documentation ) and after the setup you can see the default html page and you would like to change it with your own but you don't kwno the location of the file:

Solution:
The Default location of the index.html file is in the next path:
/var/www/html/index.nginx-debian.html

How to create scripting

Problem:
You would like to create and script file to process one or more commands.

Solution:
1.- create a new file:
nano my_script.sh

2.- inside the file add your commands, I create a shorcut to Motion configuration from my current directory
nano /etc/motion//motion.conf

3.- run the script to test it:
sh my_script.sh



motion.log permission denied

Problem:
You try to setup Motion with the option to write the application log into motio-log file, you can do this edition the motion.config file and you can select the path to the file log.
That happens on the standard configuration also if you try to setup motion as a service.
Beside this, you get the error message "motion.log permission denied"

Solution:
The problem is all due to files and folders permissions, if you run motion as a service the system will run motion as a root user, not pi user.
Change files and system folders using chmod

Setup a light web server with NGINX

Problem:

You care running a Raspberry pi zero and you need a fast way to acess your files/pictures or cam.

Why not to crate a light web serve to do it ?

Solution:


1.- Ensure that your system is up.todate.

sudo apt-get update
sudo apt-get upgrade
2.- Install Ngix
sudo apt-get install nginx
3.- start the webserver
sudo systemctl start nginx
4.- Check your hostname or IP to access to the web server:
hostname -i   "show you ip address
hostname  "show your host name
just open it using http://<hostname> or http://<ipaddress>
5.- change Nginx configuration, path, port, etc...
sudo nano /etc/nginx/nginx.conf
6.- start the web server once the system boot edition rc.local.
sudo nano /etc/rc.local
add the next line to the file and save it:  
 sudo systemctl start nginx
Faq's:
What is the defult www folder after nginx installation ?
-> you can find it in /var/www/html/

Source: