-1

I have mistakenly deleted all the environment variables from a file by running the following command and restarted my Ubuntu 16.04.

sudo gedit /etc/environment

Now, it is loading and showing black screen and doing nothing. How can fix this issue?

Nomiluks
  • 101

2 Answers2

2

Here is the contents of my stock /etc/environment file from an Ubuntu 16.04 installation. It is only one line setting your PATH variable. Without knowing where to look for commands, that could definitely halt your boot. Can you add the below line to your /etc/environment file so it is the only line and see if it boots? Did your /etc/environment file only have one line in the beginning?

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Kyle H
  • 1,044
  • 6
  • 7
  • Yes, this was the line that removed. Now, problem is how can I add this line? Without having a UI? Or filesystem access!! – Nomiluks Dec 05 '16 at 18:47
  • @Nomi Follow the information that we have given you. Boot a liveCD and mount your drive. Edit the file in question. Done. – negusp Dec 05 '16 at 19:03
  • 1
    Yes, that would be how to edit the file on your install. Please let us know how it goes! – Kyle H Dec 05 '16 at 19:14
1

Boot the installation media, choose "Try Ubuntu", mount your root filesystem in /mnt, copy /etc/environment to /mnt/etc/ (use sudo cp -a to preserve timestamps, ownership and access mode), unmount /mnt and reboot.

AlexP
  • 10,197