EzDevInfo.com

raspbian interview questions

Top raspbian frequently asked interview questions

Running GNU Screen on Raspbian with vertival split spilling content

I am running Screen on a Raspberry Pi. My shell on the Pi is ZSH with OH-MY-ZSH. I have connected to the Pi via SSH from a Mac. When I run certain commands like HTOP or Vim the output spills over to the second screen. You can see it in the screenshot below. How do I stop the content of one window spilling in to the next?

GNU Screen Spilling on to second vertical split.


Source: (StackOverflow)

Stream audio/video over RTSP with VLC?

I have a camera module (noIR) and USB mic attached to my raspberry pi. I'm trying to setup a RTSP streaming video/audio so I can observe the feed from another system on my network.

So far, I've been able to get video streaming working with:

raspivid -h 972 -w 1296 -fps 12 -br 46 -o - -t 0 | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

However, I can't figure out how to add the audio track to the RTSP stream from my USB mic. Thanks for your help!


Source: (StackOverflow)

Advertisements

How to increase range Of Ad-hoc network using Rasberry Pi 3?

I am working on MANET using rasberry pi 3 (micro-controller), I want to make 3 rasberry pi as a router and each of three not in range with them, now if I shuffle these 3 rasberry pi they dont change topology. Now my question is how I can increase range of adhoc network using AODV routing protocol?


Source: (StackOverflow)

Raspberry Pi model B scaling for 3.2" touchscreen

I have bought a 3.2" touchscreen for the Raspberry Pi model B that I have and it comes with a dvd containing a system image of Raspbian compatible with running the screen.

Now my problem is that the Pi is stretching the display way more over than the real resolution of the screen so I get half of the display or a portion of it and the rest is out of frame.

I have tried to change the resolution but there is no option except 320x240 and auto which sets it back to 320x240.

So is there anyway I can rescale the display or force the pi to render on some pixel values for length and width?


Source: (StackOverflow)

Why can I ssh by name to one LAN device, but not another?

I am looking for an explanation on something probably stupid but that I can’t find immediately on Internet.

Situation:

  • Classic home LAN.
  • Network: 192.168.1.0/24
  • No DNS server.
  • I installed 2 Raspberry Pi’s. One is functioning as media player (Kodi/OSMC) the other one as a syslog server (Raspbian OS).

Question:

Why can I ssh by NAME and IP the Raspbian syslog server and only by IP the Kodi mediaplayer?

I start an ssh session via putty on a Windows pc. I know that I can add the Kodi hostname and ip address into my hostfile on my Windows desktop with the direct result that I can also ssh by NAME into that device. But I’d like to know why I need this extra step for the KODI and why this was not necessary for the Raspbian OS.


Source: (StackOverflow)

Raspberry Pi 3 Wifi Connecting Issues

So I've done this a million times and I have no idea why its failing now. Simply trying to setup the wifi for the raspberry pi 3 in the lite command line only version. I've been using the instruction on the pi website found here: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

I put in the info and write to the wpa_supplicant config file, and when I restart the wlan service and use the ifconfig command I see that the pi's ip address is 169.254.232.41 My gateway is 192.168.2.1 so this is way off. It says network unreachable when I try to ping anything on the network I'm trying to connect it to. I saw some weird issues with 169.254.. issues online, but they seem to be happening when the pi is connected to a computer via ethernet. Whereas mine is just the keyboard and monitor, trying to get it to connect. I have another pi, that I have put on the network and all of the modified files are the same between them.

I wondered if I had a corrupt disk image or something, so I redownloaded the latest and tried again with no avail. I wonder if there is a hardware issue, but the pi scans normally, so that doesn't seem to be the problem. After getting 5 pages deep in multiple google searches, I've decided to swallow my pride and ask for help.

Thanks!


Source: (StackOverflow)

Automaticly run xinit from rc.local as different user

I'm working on some tuning of my raspberry pi b+. So I decided that midori should start automaticly after autologin. With startx it works without problems, but X is still to ressource hungry. So I'll start midori with xinit and matchbox.

As test, I use as user "pi" this command "xinit ./home/pi/startmidori.sh" and it works. So I'll put this into my rc.local file.

There is the command "su -l pi -c xinit ./home/pi/startmidori.sh", this doesn't work. I don't know why, but xinit exit immediately after starting. There's no errors or warning in Xorg logfile, but the known one (module g3d_23 not found).

How can I solve this? In guides I found some kind of solution, but all of them don't work. I tryed to run it as root but it doesn't work, too. I've no idea why.


Source: (StackOverflow)

Extract text from journalctl logging facility

I have a system which I can access directly with the keyboard but not by ssh (which is my problem, and which arises the question; a RasPi 3 with OSMC 2016.05-1, which is Debian-based, version: 8.5). I raised the logging level for the ssh demon to DEBUG and got two screens full of lines in the journalctl.

There must be a way to extract those sshd lines; otherwise I'd need to copy it manually, or to take photos with my camera ... Perhaps I can get the result by ftp.

So, how can I extract the interesting lines (and have hope to get help for my ssh problem)?


Source: (StackOverflow)

Why I can't use wget command in SSH shell?

I have the following problem.

I am using my RaspBerry (with RaspBian installed) by SSH.

My problem is that I can't use wget command because it fails.

For example if I try to execute the following command:

sudo wget http://dietrofuoritempo.files.wordpress.com/2013/02/bla-bla.jpg

I obtain this error message:

--2014-05-29 19:39:11--  http://dietrofuoritempo.files.wordpress.com/2013/02/bla-bla.jpg
Resolving dietrofuoritempo.files.wordpress.com (dietrofuoritempo.files.wordpress.com)... failed: No address associated with hostname.
wget: unable to resolve host address `dietrofuoritempo.files.wordpress.com'
pi@raspberrypi ~/driverWireless $ sudo wget http://dietrofuoritempo.files.wordpress.com/2013/02/bla-bla.jpg

The strange thing is that I can ping it:

pi@raspberrypi ~/driverWireless $ ping dietrofuoritempo.files.wordpress.com
PING dietrofuoritempo.files.wordpress.com (192.0.80.175) 56(84) bytes of data.
64 bytes from dietrofuoritempo.files.wordpress.com (192.0.80.175): icmp_req=1 ttl=41 time=164 ms
64 bytes from dietrofuoritempo.files.wordpress.com (192.0.80.175): icmp_req=2 ttl=41 time=167 ms

Why? What can I do to solve this issue?

(on my Ubuntu Linux system I have no problem to perform wget command)


Source: (StackOverflow)

What are the options of bluetooth-agent?

I found no answer to this simple question: What are the options that bluetooth-agent accepts? I am using raspbian, based on debian wheezy, which uses bluez v 4.99

  • the website of bluez has no information whatsoever
  • the help message is scarce and does not cover all the options!

Source: (StackOverflow)

wvdial can't retrieve modem response, terminal programs communicate without problems

I'm trying to make a GPRS connection with a SIM800L and a PL2303 USB-Serial cable.

If I screen or minicom the modem (at 115200 8N1) I get an immediate response from the modem and I even after setting up the PDP and GPRS context I can successfully ping google servers through AT commands. I'm also able to initiate a PPP connection through AT+CGDATA="PPP" or ATDT*99***1#.

But with wvdial the modem won't respond

--> WvDial: Internet dialer version 1.61
--> Cannot set information for serial port.
--> Initializing modem.
--> Sending: ATZ
--> Sending: ATQ0
--> Re-Sending: ATZ
--> Modem not responding.

If I do a cat /dev/ttyUSB0 and run wvdial at the same time I get this:

ATZ0
OK

OK

OK

After wvdial has ended the command and the first OK appears, one second later the two OK will appear. Also I would like to note that ATZ and ATQ0 commands became overlapped.

I might be hijacking the output through cat and that might be the reason but the behaviour of wvdial is the same with or without cat.

This is my /etc/wvdial.conf

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 115200
Phone = *99***1#
Username = webgprs
Password = webgprs2002
New PPPD = yes

Modem Type = Analog Modem doesn't make any difference. If I put some Init# parameters they won't get any response either. The overlapping of commands will happen with the Init# commands too.

Getting abstraction layers out as noted in 3G and GPRS modems with pppd resulting in using only pppd didn't work either. What's clear is that communication with the serial port by system process aren't being held, only through serial port clients.

sakis3g communicates successfully with the modem but is unable to bring up an interface.

[13751] [11:45:56] Connection command that will be used is: /usr/bin/setsid /usr/sbin/pppd /dev/ttyUSB0 460800 modem crtscts -detach defaultroute dump noipdefault usepeerdns usehostname ktune logfd 2 noauth name sakis3g lock maxfail 3 connect "/usr/sbin/chat -v -f /tmp/pppd.tmp.13751" user "webgprs" password "webgprs2002"
[13751] [11:45:56] Verbosing: 28% Initializing modem
[13751] [11:45:56] Using default INITIALIZE.
[13751] [11:45:56] Command "INITIALIZE" refers to AT commands: ATZ OK 'AT&F' OK 'ATQ0 V1 E1' OK 'AT&D2 &C1' OK AT+FCLASS=0 OK ATS0=0 OK 'AT+CGDCONT=1,"IP","internet.itelcel.com"' OK
[13751] [11:45:56] Will send INITIALIZE commands to tty /dev/ttyUSB0: "" '\pAT' OK ATZ OK 'AT&F' OK 'ATQ0 V1 E1' OK 'AT&D2 &C1' OK AT+FCLASS=0 OK ATS0=0 OK 'AT+CGDCONT=1,"IP","internet.itelcel.com"' OK '\pAT' OK
[13751] [11:45:57] We are root already. Proceeding.
[13751] [11:45:57] Device /dev/ttyUSB0 is not busy.
[13751] [11:45:58] Got response from tty:
AT
OK
ATZ
OK
AT&F
OK
ATQ0 V1 E1
OK
AT&D2 &C1
OK
AT+FCLASS=0
ERROR
[13751] [11:45:58] Unknown command "STAGE7".
[13751] [11:45:58] Unknown command "STAGE8".
[13751] [11:45:58] We are root already. Proceeding.
/-------------------------------------------------------------------------------
[13751] [11:45:58] Will now run command: \'/bin/rm -f "/tmp/sakis3g.3gnet"\'
/-------------------------------------------------------------------------------
\-------------------------------------------------------------------------------
[13751] [11:45:58] Command returned 0.
\-------------------------------------------------------------------------------
[13751] [11:45:58] We are root already. Proceeding.
[13751] [11:45:58] Device /dev/ttyUSB0 is not busy.
[13751] [11:45:58] Verbosing: 35% Connecting
[13751] [11:45:58] PID 15625 is still running.
[13751] [11:45:59] Located "netstat" within PATH (/bin/netstat).
[13751] [11:45:59] Waiting for interface to go up (0 seconds passed).
[13751] [11:46:00] PID 15625 is still running.
[13751] [11:46:00] Waiting for interface to go up (1 seconds passed).
[13751] [11:46:01] PID 15625 is still running.
[13751] [11:46:01] Waiting for interface to go up (2 seconds passed).
... (truncated) ...
[13751] [11:46:56] Waiting for interface to go up (20 seconds passed).
[13751] [11:46:57] Giving up waiting for connection to occur.
[13751] [11:46:57] PID 16179 is still running.
[13751] [11:46:58] PID 16179 is not running any more.
[13751] [11:46:58] PID 16179 is not running any more.
[13751] [11:46:58] Failed to connect.
[13751] [11:46:58] Error: Failed to connect.
[13751] [11:46:58] Aborting execution chain due to actor "connect" returning 95. 

The result it's the same even if I manually set up the PDP context and set the modem in a GPRS active context

AT+CIPSTATUS
IP STATUS

Source: (StackOverflow)

bluez : Can not install bluez-utils

Dose someone try "sudo apt-get install bluez-utils" successfully on raspberry pi ?

and I get this message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package bluez-utils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package bluez-utils has no installation candidate

Source: (StackOverflow)

Cronjob not running script

I've created a script to get my external IP address, check if it's changed and if it has, email it to me letting me know.

Here's the script, aptly named ip.sh (server hostname is "odin"):

#!/bin/sh

# Start by renaming file "current-ip" to "old-ip"
mv -f  /var/www/html/scripts/current-ip  /var/www/html/scripts/old-ip
# Create new "current-ip" with the email's subject line
echo 'Subject: Odin has a new IP address' >> /var/www/html/scripts/current-ip
# Add a blank line
echo '' >> /var/www/html/scripts/current-ip
# Add some text to make the email slightly more readable
echo 'It seems as if a new IP address as been assigned to Odin:' >> /var/www/html/scripts/current-ip
# Get my external IP address and add it to a new line
curl http://ipecho.net/plain -w "\n" >> /var/www/html/scripts/current-ip
# Set permission to make the file readable and writeable
chmod 766 /var/www/html/scripts/current-ip

# Check to see if the newly built "current-ip" matches the old file
if diff /var/www/html/scripts/current-ip /var/www/html/scripts/old-ip >/dev/null ; then
# if it does, do nothing
exit
# Otherwise send that email!
else
  ssmtp -F"Odin" my_emial_address@gmail.com < /var/www/html/scripts/current-ip
fi

So to test this, I go edit the current-ip file to something else and then run the script ./ip.sh and it works like a charm, I get my email from "Odin" telling me what my new IP address is. Fantastic.

So now, I create a symlink:

ln /var/www/html/scripts/ip.sh /sbin/odinip

And test it by running odinip. Works perfectly.

Then I go create the cronjob with crontab -e and enter the following line:

*/5 * * * * /sbin/odinip

I also add the following line to make sure that cron is working:

*/5 * * * * env > /var/www/html/scripts/env.output

I then go edit the current-ip file again to make sure that there will be a difference when the cronjob is run.

Then I wait and wait and wait. The env.output file is created, but no emails are sent.

Checking the syslog (tail -n25 /var/log/syslog) I get:

May  9 13:40:01 odin CRON[7371]: (root) CMD (env > /var/www/html/scripts/env.output)
May  9 13:40:04 odin CRON[7341]: (CRON) info (No MTA installed, discarding output)
May  9 13:40:38 odin crontab[7429]: (root) BEGIN EDIT (root)
May  9 13:40:47 odin crontab[7429]: (root) END EDIT (root)
May  9 13:40:49 odin crontab[7451]: (root) BEGIN EDIT (root)
May  9 13:41:01 odin CRON[7478]: (root) CMD (cd /var/www/html/scripts/ && ./cpuTemp.sh)
May  9 13:41:16 odin rsyslogd-2007: action 'action 17' suspended, next retry is Mon May  9 13:42:46 2016 [try http://www.rsyslog.com/e/2007 ]
May  9 13:41:30 odin crontab[7451]: (root) END EDIT (root)
May  9 13:41:31 odin crontab[7513]: (root) BEGIN EDIT (root)
May  9 13:41:44 odin crontab[7513]: (root) END EDIT (root)
May  9 13:41:46 odin crontab[7548]: (root) BEGIN EDIT (root)
May  9 13:42:01 odin CRON[7587]: (root) CMD (cd /var/www/html/scripts/ && ./cpuTemp.sh)
May  9 13:42:46 odin rsyslogd-2007: action 'action 17' suspended, next retry is Mon May  9 13:44:16 2016 [try http://www.rsyslog.com/e/2007 ]
May  9 13:43:01 odin CRON[7690]: (root) CMD (cd /var/www/html/scripts/ && ./cpuTemp.sh)
May  9 13:43:41 odin crontab[7548]: (root) REPLACE (root)
May  9 13:43:41 odin crontab[7548]: (root) END EDIT (root)
May  9 13:44:01 odin cron[360]: (root) RELOAD (crontabs/root)
May  9 13:44:01 odin CRON[7771]: (root) CMD (cd /var/www/html/scripts/ && ./cpuTemp.sh)
May  9 13:44:18 odin rsyslogd-2007: action 'action 17' suspended, next retry is Mon May  9 13:45:48 2016 [try http://www.rsyslog.com/e/2007 ]
May  9 13:45:01 odin CRON[7849]: (root) CMD (cd /var/www/html/scripts/ && ./cpuTemp.sh)
May  9 13:45:01 odin CRON[7850]: (root) CMD (/home/jim/duckdns/duck.sh >/dev/null 2>&1)
May  9 13:45:01 odin CRON[7851]: (root) CMD (/sbin/odinip)
May  9 13:45:04 odin CRON[7829]: (CRON) info (No MTA installed, discarding output)
May  9 13:45:51 odin rsyslogd-2007: action 'action 17' suspended, next retry is Mon May  9 13:47:21 2016 [try http://www.rsyslog.com/e/2007 ]
May  9 13:46:01 odin CRON[7943]: (root) CMD (cd /var/www/html/scripts/ && ./cpuTemp.sh)

cpuTemp.sh is just another script that I have running there. Maybe something about there being no Mail Transport Agent? But then how does it work when I run it manually?

More info: All commands are run and files edited and crontab edits done as root All of this is happening on a Rasberry Pi 2 running Jessie. VERY recently updated and upgraded.


Source: (StackOverflow)

DHCP failure when rebooting RPI 2

When we start up my Raspberry pi 2, we get the following error:

enter image description here

When the RPI is rebooted, we are getting an IP and we are able to surf on the internet, so we don't know what the error exactly means. We are connected with a WPA2-enterprise network.

This is my interfaces file:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

And this is my wpa_supplicant.conf file:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="Here comes my ssid"
        proto=RSN
        key_mgmt=WPA-EAP
        pairwise=CCMP
        auth_alg=OPEN
        identity="Here comes my identity"
        password="here comes my password"
}

How to solve this issue?


Source: (StackOverflow)

How can I control my minecraft server when I run it at boot with a rc.local script?

I have a question your you guys. I'm running a MC server so far so great. In order to make it autonomous I run it at boot with a bash script load in rc.local, simple.

#!/bin/bash
cd /home/minecraft sudo java -Xms512M -Xmx1008M -jar /home/minecraft/spigot-1.9.jar nogui

Ok, the problem is that when i connect through ssh, i cannot see the server. It is running, because i can play with no problems, but i cannot gain control over it.

When I run the server with the comand from the script, but no at boot, the server keeps on screen, waiting for commands, and showing information, but when run it from the boot script, i cannot see anything.

How can i gain control, or see the server screen if i run it from boot and connect through ssh later?

I hope you understand what i mean. Thanks you in advance, and have a nice day.


Source: (StackOverflow)