Labels

Arduino (1) Brainf**k (1) Bugs (3) C (1) HTML (1) Install (3) Linux (27) Maths (1) Python (12) Raspberry Pi (4)

Sunday, 24 January 2016

How to encrypt files on linux using GPG

GPG is part of the group GNU Privacy Guard group. Its a program to encrypt/decrypt files using a key or password, the key being more secure.It can be used to make files with sensitive data in them secure and unreadable without the password or key.

To install GPG run:
sudo apt-get install gnupg

To encrypt a file with a password run:
gpg -c inventorofbitcoin.txt
You will then be promoted to enter a password.
The encrypted file is stored as inventorofbitcoin.txt.gpg note that the original file isn't deleted.

To decrypt a file with a password run:
gpg inventorofbitcoin.txt.gpg
You will then be prompted for the password and after the correct password has entered you will have to original file.

Setting up a apache web server on linux

Apache is a standalone HTTP web server for linux. There are others like nginx but in my opinion apache is the easiest to configure and understand.

To install apache :
sudo apt-get install apache2

Once it's installed you have a web server running that can be accessed on your local network.
To check it's running go to your web browser and type 127.0.0.1 and it should come up with a default page.

To access it from other computers on the network we need to find out your local IP address which can be done with:
ifconfig wlan0 | grep "inet addr"

This will give you a output of
inet addr:192.168.0.18 Bcast:192.168.0.255 Mask:255.255.255.0
With your IP being inet addr:192.168.0.18

Now enter this ip on another device on your local network and it should come up with the same default homepage, if you want to set a static IP have a look at this post.

Wednesday, 20 January 2016

How to use the camera on the Raspberry Pi

The Raspberry pi is capable of taking pictures in 1080p and its quite easy to once you get it connected.
First off you need to connect the camera and enable using the raspi-configraspistill -o image.jpg
This saves a photo as "image.jpg" in the current directory.
If you get an error like

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

Change the quality:
raspistill -q 50 -o image.jpg
This saves a photo as "image.jpg" with 50% quality therefore saving size.

Taking a video for 5 seconds:
raspivid -o video.h264
This takes a video for the default time of 5 seconds and saves it as "video.h264".

Taking a video for a different time:
raspivid -t 120 -o video.h264
This takes a video for 120 seconds or 2 mins. Make sure you have enough space on your sd card as these videos can get large very quickly.

Sunday, 17 January 2016

How to transfer files using SCP

SCP is a secure file transfer that uses SSH for the data transfer which is why it is secure as it uses the same authentication.

To use it the client needs to be running SSH.

Things we need to know:
Username and password for host
IP address for the host box.
Where the file is located i.e /home/pi/file.txt

How to use it:
To copy one file from the remote host use the command:
scp pi@192.168.0.10:/home/pi/file.txt /home/(WHERE YOU WANT THE FILE)

To copy one file to the remote host use the command:
scp /home/(FILE to copy) pi@192.168.0.10:/home/pi/file.txt

Increase security:
scp -c 3des pi@192.168.0.10:/home/pi/file.txt /home/(WHERE YOU WANT THE FILE)

Increase speed using compression:
scp -C pi@192.168.0.10:/home/pi/file.txt /home/(WHERE YOU WANT THE FILE)



How to enable forwarding on linux

Enabling forwarding on linux allows network packets from one interface (eth0) to another interface (wlan0). The use for this would most commonly be for setting up your box as a hotspot or bridge.
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
 

If you want to store this permanently edit the file /etc/sysctl.conf
Add the line net.ipv4.ip_forward = 1 to the end of the file.