echo issues on my raspberry pi

Discussion in 'Other Operating Systems' started by mibberz, Dec 23, 2015.

  1. mibberz

    mibberz Member

    Joined:
    Jun 28, 2001
    Messages:
    2,790
    Location:
    Kalgoorlie
    hey i have tried this

    Code:
    pi@raspberrypi:~ $ sudo echo "p1165757" >> /etc/openvpn/PIA/auth.txt
    bash: /etc/openvpn/PIA/auth.txt: Permission denied
    
    any advice?
     
  2. OP
    OP
    mibberz

    mibberz Member

    Joined:
    Jun 28, 2001
    Messages:
    2,790
    Location:
    Kalgoorlie
  3. @kernelhack

    @kernelhack Member

    Joined:
    Feb 9, 2013
    Messages:
    60
    Location:
    Brisbane, QLD
    Have you tried it without using sudo, instead as root?
     
  4. elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    43,136
    Location:
    Brisbane
    So there's two things going on here:

    1) The echo command

    2) The redirect of stdout to a file via the ">>" notation

    In UNIX-like operating systems and shells, we don't run big complex commands. We do lots of little commands, and take the output from each and pass it along to the next. The problem occurs sometimes when you need to do some of the commands in the middle as a super user.

    Your "sudo" (short for "Super User Do", which is a privilege escalation command similar to "run as" in other operating systems) applies only to (1). So you've become a super user for the "echo" command, but the redirect is still being done as your regular non-privileged user.

    A few options on how to work around this.

    * Become root, and re-run your command. i.e.:
    Code:
    sudo su -
    [enter password]
    echo "p1165757" >> /etc/openvpn/PIA/auth.txt
    
    * Edit the file directly instead of echoing information to it, so
    Code:
    sudo vi /etc/openvpn/PIA/auth.txt
    [or]
    sudo nano /etc/openvpn/PIA/auth.txt
    
    * Use the "tee" command, which will redirect for you and take the sudo command (making sure you append, and not overwrite). i.e.:
    Code:
    echo "p1165757" | sudo tee --append /etc/openvpn/PIA/auth.txt
    [or]
    echo "p1165757" | sudo tee -a /etc/openvpn/PIA/auth.txt
    
     
    Last edited: Dec 23, 2015
  5. OP
    OP
    mibberz

    mibberz Member

    Joined:
    Jun 28, 2001
    Messages:
    2,790
    Location:
    Kalgoorlie
    ok you guys are a wealth of knowledge, back in Melbourne i had so many people to help omce i went to the military my skills dropped and then kalgoorlie i only ever had to fix peoples wifi and delete ad ware,

    now in belgium i cant even speak the same language as the 2 gurus near me so you guys are being very helpful

    my next issue

    Code:
    pi@raspberrypi:~ $ sudo service isc-dhcp-server status
    ‚óŹ isc-dhcp-server.service - LSB: DHCP server
       Loaded: loaded (/etc/init.d/isc-dhcp-server)
       Active: failed (Result: exit-code) since Wed 2015-12-23 08:08:20 UTC; 2min 5s ago
      Process: 456 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)
    
    Dec 23 08:08:17 raspberrypi dhcpd[506]: you want, please write a subnet declaration
    Dec 23 08:08:17 raspberrypi dhcpd[506]: in your dhcpd.conf file for the network segment
    Dec 23 08:08:17 raspberrypi dhcpd[506]: to which interface eth0 is attached. **
    Dec 23 08:08:17 raspberrypi dhcpd[506]:
    Dec 23 08:08:17 raspberrypi dhcpd[506]:
    Dec 23 08:08:20 raspberrypi isc-dhcp-server[456]: Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
    Dec 23 08:08:20 raspberrypi systemd[1]: isc-dhcp-server.service: control process exited, code=exited status=1
    Dec 23 08:08:20 raspberrypi systemd[1]: Failed to start LSB: DHCP server.
    Dec 23 08:08:20 raspberrypi systemd[1]: Unit isc-dhcp-server.service entered failed state.
    Dec 23 08:08:20 raspberrypi isc-dhcp-server[456]: failed!
    pi@raspberrypi:~ $
    
    i feel retarded editing these files, one thing i have noticed is no ip address
    Code:
    pi@raspberrypi:~ $ ifconfig -a
    eth0      Link encap:Ethernet  HWaddr b8:27:eb:62:db:05
              inet6 addr: fe80::3fd6:2b82:7e39:6301/64 Scope:Link
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:224 errors:0 dropped:0 overruns:0 frame:0
              TX packets:224 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:19020 (18.5 KiB)  TX bytes:19020 (18.5 KiB)
    
    tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
              inet addr:10.100.1.6  P-t-P:10.100.1.5  Mask:255.255.255.255
              UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
              RX packets:34 errors:0 dropped:0 overruns:0 frame:0
              TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:100
              RX bytes:2584 (2.5 KiB)  TX bytes:4764 (4.6 KiB)
    
    wlan0     Link encap:Ethernet  HWaddr 54:2a:a2:4d:ce:44
              inet addr:192.168.1.23  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::b289:ded3:a844:2697/64 Scope:Link
              inet6 addr: 2a02:a03f:10f3:7a00:ae49:75:3691:5346/64 Scope:Global
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1196 errors:0 dropped:4 overruns:0 frame:0
              TX packets:284 errors:0 dropped:2 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:152039 (148.4 KiB)  TX bytes:50680 (49.4 KiB)
    
    pi@raspberrypi:~ $
    
     
  6. elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    43,136
    Location:
    Brisbane
    According to that output, you are starting a DHCP server, not a DHCP client.

    The server distributes IPs to a subnet, and requires configuration (yours is unconfigured, according to the logs).

    The DHCP client is the bit of software that asks your network to provide IP details to the host, which is what you want (I see maybe you've got this working now in your other thread?).
     
  7. OP
    OP
    mibberz

    mibberz Member

    Joined:
    Jun 28, 2001
    Messages:
    2,790
    Location:
    Kalgoorlie
    It is a dhcp server on the Eth0

    For some reason all my routing was listed twice after deleting a heap of my duplicate route tables it all sorted it's self out
     

Share This Page

Advertisement: