Cron - schedule jobs
FFMPEG
Lossless H.264
From https://trac.ffmpeg.org/wiki/Encode/H.264.
You can use -crf 0
to encode a lossless output. Two useful presets for this are ultrafast
or veryslow
since either a fast encoding speed or best compression are usually the most important factors.
Lossless example (decent)
ffmpeg -i BalconyToTable.mov -vcodec h264 -acodec aac -strict -2 BalconyToTable.mp4
Lossless example (fastest)
ffmpeg -i input -c:v libx264 -preset ultrafast -crf 0 output.mkv
ffmpeg -i BalconyToTable.MOV -c:v libx264 -preset ultrafast -crf 0 BalconyToTable.mkv
Lossless example (best compression)
ffmpeg -i input -c:v libx264 -preset veryslow -crf 0 output.mkv
Apache Webserver
Install Apache web server by
sudo apt-get install apache2 -y
Default web page is just a HTML file on the filesystem. It is located at /var/www/html/index.html
.
Note: The directory was /var/www
in Raspbian Wheezy but is now /var/www/html
in Raspbian Jessie
Commands
$ sudo /etc/init.d/apache2 start
$ sudo /etc/init.d/apache2 stop
$ sudo /etc/init.d/apache2 restart
Config file
sudo nano /etc/apache2/httpd.conf
Virtual host
Check guide of virtual hosting multiple webpages in one server
folders and access
sudo apt-get update
sudo apt-get install apache2
sudo mkdir -p /var/www/verkkovadelma.com/public_html
sudo mkdir -p /var/www/blog.verkkovadelma.com/public_html
sudo chown -R $USER:$USER /var/www/verkkovadelma.com/public_html
sudo chown -R $USER:$USER /var/www/blog.verkkovadelma.com/public_html
sudo chmod -R 755 /var/www
verkkovadelma.com configure
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/verkkovadelma.com.conf
sudo nano /etc/apache2/sites-available/verkkovadelma.com.conf
Copy paste this to file
<VirtualHost *:80>
ServerAdmin admin@verkkovadelma.com
ServerName verkkovadelma.com
ServerAlias www.verkkovadelma.com
DocumentRoot /var/www/verkkovadelma.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Upload html files to corresponding folders and then run:
sudo a2ensite verkkovadelma.com.conf
sudo a2ensite blog.verkkovadelma.com.conf
sudo service apache2 restart
Extra, fake forwarding locally
define your host
sudo nano /etc/hosts
If server ip is 192.168.2.70
, add this:
127.0.0.1 localhost
127.0.1.1 guest-desktop
192.168.2.70 verkkovadelma.com
192.168.2.70 blog.verkkovadelma.com
MariaDB
Install mariadb by command
sudo apt-get install mariadb-server
If you already have MySQL installed, it is likely that the package manager notifies you of a conflict and asks if it needs to uninstall MySQL. In this case, answer yes.
During the installation, MariaDB will configure itself. It’s up to you to provide the administrator account for the database.
This done, it should ask you if you are sure to want to go under MariaDB. Again, answer yes.
Once the installation is complete, you will be able to access MariaDB as you did with MySQL, simply with the following command:
mysql -u user -p
Basic usage
Create new database
CREATE DATABASE testi-db;
Tell the shell to use in future operations in this session
USE testidb;
Create new user with password and give full privileges to database.
CREATE USER 'user_test'@'localhost' IDENTIFIED BY 'uusisalkkusana';
GRANT ALL PRIVILEGES ON testidb.* TO 'user_test'@'localhost';
GRANT ALL PRIVILEGES ON STATTLESHIP.* TO 'NBADMIN'@'%' IDENTIFIED BY 'greatpasswords';
FLUSH PRIVILEGES;
quit
Now you can log in with credentials
mysql -u user_test -p
Create new datatable
CREATE TABLE tempdat (tdate DATE, ttime TIME, zone TEXT, temperature NUMERIC);
Change pw
SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
SET PASSWORD FOR 'user_test'@'localhost' = PASSWORD('mypw');
Users
Check what columns are available for ‘users’
DESC mysql.user; -- columns to select
Show users, hosts and passwords:
SELECT user, host, password FROM mysql.user;
Show grants for
show grants for 'root'@'localhost';
show grants for 'user_test'@'localhost';
Drop user IF
DROP USER IF EXISTS bob;
R
First install compound
sudo apt-get install libmariadb-client-lgpl-dev
and then mariadb package to R
install.packages("RMariaDB")
Backup and restore
Backup database by command
mysql -u root -p DBNAME > bck_db.sql
and restore it to NEWDB by command
mysql -u root -p NEWDB < bck_db.sql
Top10
ps aux | grep apache2
How to check Kernel version?
uname -a
uname -v
How to check ip address?
ifconfig
ip addr show
ip addr show wlan0
How to check disk space used?
df -ah
How to check process status?
service udev status
systemctl status udev
How to check folder size?
du -sh brootbot/
How to check what ports are being used?
netstat
netstat -tulpn
How to check CPU usage of certain process?
ps aux | grep apache2
htop
top
How to mount drive?
ls /mnt
mount /dev/sd2 /mnt/ab
How to check existing mounts?
mount
Mount file in boot, what file you would looking?
less /etc/fstab
How to find answer for commands?
man <command>
man ps