#Appunti MAC / Linux

<abstract>
Raccolta di appunti utili su MAC
</abstract>

#compix broken on ubuntu 18:
https://askubuntu.com/questions/1007026/ubuntu-menu-and-launcher-not-showing-after-2-16-2018-update
rm -rf ~/.config/compiz-1/compizconfig/*
sudo reboot

maybe reboot not necessary

#change MAC address in Linux:
<pre>
ifconfig eth0 down
ifconfig eth0 hw ether 00:80:48:BA:d1:30
ifconfig eth0 up
ifconfig eth0 |grep HWaddr
</pre>

# here are some notes on how to access the Yarm serial port onboard the robtest CM3-home
* raspberrypi.local = 192.168.0.7
* login pi
* password raspberry
* This port is visible in Linux as /dev/ttyUSB1 device.
* 

# here are some notes on how to access the Yarm serial port onboard the robtest CM3-home
* cm3panel.local = 192.168.1.90
* login pi
* password cm3panel
* This port is visible in Linux as /dev/??? device.
* GPIO37 c'è l'RxD della Raspberry
* GPIO36 c'è il TxD della Raspberry
* YARM-Rxd è l'Rxd della CM3

---

<h2>cut and paste in nano editor</h2>
ALT-6 to add lines in the buffer
CTRL-U to paste the saved lines

<h2>Systemd: come abilitare i messaggi di console su script che partono alla accensione e 
redirezionare anche l'input</h2>
In /etc/rc.local mettere:<br>
<pre>
sleep 10
cd /root
./testnand.sh 1> /dev/console 2>&1 < /dev/console
</pre>

<h2>accettare input da script:
<pre>
read -n 1 -p "Selezione (1 = halt): " myinput
if [ "$myinput" = "1" ]; then
	printf "\n halt \n"
	halt
else
	printf "\n login \n"
fi	
</pre>

<h2>Colori su script</h2>
<pre>
ERR='\033[0;41m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\0330m'
printf "${ERR} START TEST"
printf "${NC}\n"
</pre>

<h2>Disabilitare messaggi systemd</h2>
in /etc/systemd/system.conf<br>
decommentare le seguenti linee e metterle a:<br>
<pre>
LogLevel=emerg
LogTarget=null
ShowStatus=no
</pre>


<h2>Conoscere IP pubblico da linea comandi Linux</h2>
<pre>
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
</pre>

<h2>utility serial terminal su MAC: screen -a /dev/tty.usbserial-A502CUAM 115200</h2>

<h2>versione di linux: uname -a</h2>

<h2>GREP ricorsivo</h2>
grep --include=\*.{c,h} -rnw . -e "pattern"
questo funziona!!!!!!!

<h2>messaggi continui di sistema</h2>
dmesg --follow
<br>
tail -f /var/log/syslog
Oppure, più modernamente,
journalctl  con varie opzioni....

<h2>Abilitare il PATH di una applicazione (es. minicom)</h2>

editare manualmente il $PATH con:
<pre class="terminal">
$ sudo nano /private/etc/paths
</pre>

e aggiungere la linea seguente alla fine del file:
<pre class="terminal">
/opt/minicom/2.2/bin
</pre>

<h2>Date set</h2>
<pre class="terminal">
$ date -s "04/30/2017 12:21:00" 
</pre>

<h2>How to install a *.deb package</h2>
<pre class="terminal">
sudo dpkg -i DEB_PACKAGE.deb
</pre>

<h2>How to untar tgz files</h2>
<pre class="terminal">
tar -xvzf /path/to/yourfile.tgz
</pre>


<h2>Hot to enable ssh root connection on Acqua</h2>
You need to edit /etc/ssh/sshd_config, and comment out the following line:
<br>
PermitRootLogin without-password<br>
Just below it, add the following line:<br><br>

PermitRootLogin yes<br>
Then restart SSH:<br>
<br>
service ssh restart<br>


<h2>Git maintenance</h2>
https://git-scm.com/book/ca/v1/Git-Internals-Maintenance-and-Data-Recovery
Vedere ultimo paragrafo, provare prima su un clone locale

cd /tmp

Git clone file:///home/tanzilli/repooriginario

<h2>terminal for DPI under MAC</h2>
screen -a /dev/tty.usbserial-A700eqMP 115200<br>
For see the identifier of the serial USB adapter look under /dev<br>

<h2>Appunti su DTS/DTB da Xilinx</h2>
http://www.wiki.xilinx.com/Build+Device+Tree+Blob
<br>
Compiling a Device Tree Blob (.dtb) file from the DTS<br>
A utility called device tree compiler (DTC) is used to compile the DTS file into a DTB file. DTC is part of the Linux source directory. linux-xlnx/scripts/dtc/ contains the source code for DTC and needs to be compiled in order to be used. One way to compile the DTC is to build the Linux tree. The DTC might also be available through your OS's package manager.
<br>
Once the DTC is available, the tool may be invoked to generate the DTB:<br>
./scripts/dtc/dtc -I dts -O dtb -o <devicetree name>.dtb <devicetree name>.dts<br>
DTC may also be used to convert a DTB back into a DTS:<br>
./scripts/dtc/dtc -I dtb -O dts -o <devicetree name>.dts <devicetree name>.dtb<br>
<br>
<br>
<h2>DTS to DTB  Debian Device Tree Compiler</h2>
apt-get install device-tree-compiler
<br><br>
To extract the dts from dtb:<br>
dtc -I dtb -O dts -o test.dts acme-roadrunner.dtb<br><br>
To recompile the dtb from the dts:<br>
dtc -I dts -O dtb -o test.dtb test.dts<br><br>


<h2>ntp client on DEBIAN</h2>
Potete installare il client NTP semplicemente digitando da terminale:<br>
<pre class="terminal">
apt-get install ntpdate
</pre>
a questo punto avete già il client funzionante, per aggiornare l’ora vi basterà eseguite il comando ntpdate seguito dal’indirizzo del server NTP scelto. Il nostro server NTP scelto come riferimento è ntp1.inrim.it ma non è obbligario usare questo. In tal caso il comando da digitare da terminale sarà:

<pre class="terminal">
ntpdate ntp1.inrim.it
</pre>
Naturalmente utilizzato così ha poco significato il protocollo NTP, diventa veramente utile se da solo tiene la data e l’ora aggiornata. In questo caso ci viene in aiuto il demone ntp, instalabile facilmente da terminale mediante il comando:
<pre class="terminal">
apt-get install ntp
</pre>
A questo punto il demone sarebe già utilizzabile, ma noi consigliamo di aggiungere al file /etc/ntp.conf le voci:
<pre class="terminal">
    server 3.it.pool.ntp.org
    server 1.europe.pool.ntp.org
    server 3.europe.pool.ntp.org
</pre>
A questo punto riavviate il servizio relativo ad NTP mediante il comando:
<pre class="terminal">
/etc/init.d/ntp restart
</pre>


<h2>NAND FLASH utilities</h2>
Download:
[mtd-utils download](http://www.linux-mtd.infradead.org/index.html)

<br>
DOC:
[mtd-utils documentation](http://www.linux-mtd.infradead.org/doc/general.html)