0

When the sudo command is typed and pressed on the terminal, it's getting hanged. Background: I tried to establish the CAN link on the Raspberry PI board. Added CAN link connection command/script upon boot-up. For that, in /etc/network/interface I added the script below:

auto can0
  iface can0 inet manual
  pre-up /sbin/ip link set can0 type can bitrate 1000000
  up /sbin/ifconfig can0 up
  down /sbin/ifconfig can0 down

After this everything is not working. When I reboot the RPi board, it takes serveral minutes to boot up and the wifi doesn't work. Terminal works but stucks after sudo command. Please help!

Note: Any command run with sudo doesn't work, for example sudo nano <file>.

9
  • 1
    sudo is never just run without at least ONE argument - what exactly is the command you are running - also, can you see any errors in dmesg that may indicate why the pi is taking longer to boot?
    – Bravo
    Nov 21, 2021 at 23:06
  • so, all you did was add those five lines to /etc/network/interface and this has caused network failure and breaks sudo? You did nothing else?
    – Bravo
    Nov 21, 2021 at 23:44
  • yes, nothing else. Before editing interfaces file, just upgrade the installed packages (sudo apt-get update followed by upgrade). Also, after sudo command freezed every time, I tried to delete the added script from the file. Since it is root file, I couldn't delete it as root user is blocked/freezed/hanged(sudo) Nov 21, 2021 at 23:51
  • put the sd card in another computer, edit the cmdline.txt file, adding init=/bin/bash to the end of the single line in that file - then put it back in your pi, boot, and issue the command mount -o remount,rw / –target / - now you can edit that file that's causing the problem, remove the init=/bin/bash from cmdline.txt and reboot - at least you'll now be back to a functional pi
    – Bravo
    Nov 22, 2021 at 0:55
  • DO NOT put anything into /etc/network/interface (unless you disable interface in dhcpcd)
    – Milliways
    Nov 22, 2021 at 1:24

1 Answer 1

1

Your question is confusing to me. You do not explain what you mean by the CAN link - is this a Controller Area Network? If so, why are you provisioning an IP address for it? Did you get the "script" in your question from a tutorial or manufacturer's instructions? If so, you should supply a link (edit your question).

Assuming you're following competent instructions, and you do actually need to provision an IP address for this CAN link, please read on as you have apparently made one or more of the errors below. Otherwise please edit your question to explain your use case & we'll try to help.

  1. Your question says you have edited the file /etc/network/interface, but this file does not exist in a default RPi OS image. You may have this confused with the file: /etc/network/interfaces (note the 's') which is included in default RPi OS images.

  2. The file /etc/network/interfaces contains the following line:

# Please note that this file is written to be used with dhcpcd.

Which is an awkward way of saying that you are not supposed to manually edit this file if you use the default network management tool dhcpcd. Instead, you should use /etc/dhcpcd.conf, and follow the syntax defined in man dhcpcd.conf to declare your interface.

  1. You may be using the incorrect Network Manager. If /etc/network/interfaces is to be used as you've shown in your question, you will need to disable dhcpcd, and install or use another network manager; e.g. network-manager, systemd-networkd.
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.