How to add /usr/bin to path after I mistakenly removed it (sudo and nano are no longer in path)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












Lets get this out of the way, I did something stupid. Yes, stupid. Very stupid. I am well aware of how stupid this is. I am embarrassed and I regret doing it. Please help. I was installing a program, while also watching TV, and somehow managed to remove /usr/bin from path. NOOOOOO.



I'm using ubuntu 16.04. I added the new program bin to path by typing:



sudo nano ~/.bashrc


The new path was added, but then I tried to update using sudo and I got this error:



The command could not be located because '/usr/bin' is not included in the PATH environment variable.


However, the bin still exists:



 Command 'sudo' is available in '/usr/bin/sudo'


nano in available, ls is available - its all available - but not in path. So, simply trying:



sudo nano ~/.bashrc


and trying to add /usr/bin to path is not an option. Without sudo I dont have permission to open bashrc. I can cd into /usr/bin, but I cant ls anything, and I have no idea how to access sudo or nano once I'm in there. ./sudo, sudo.sh ./sudo.sh all returns "command not found".



How do I add /usr/bin to path in the event I remove it?



EDIT



I found the solution here: I think I accidently deleted the PATH variable



I replaced the PATH with the path of the program I added to my path. So, typing this into a terminal gave me access to sudo and nano again:



export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin









share|improve this question



















  • 1




    Try /usr/bin/sudo su.
    – N0rbert
    1 hour ago










  • @N0rbert, I found the answer, please see my edit. I gotta turn the TV off is the real solution.
    – Phil_T
    56 mins ago






  • 1




    Possible duplicate of I think I accidently deleted the PATH variable
    – N0rbert
    55 mins ago










  • FWIW you really shouldn't be using sudo to modify files in your own home directory
    – steeldriver
    6 mins ago














up vote
2
down vote

favorite












Lets get this out of the way, I did something stupid. Yes, stupid. Very stupid. I am well aware of how stupid this is. I am embarrassed and I regret doing it. Please help. I was installing a program, while also watching TV, and somehow managed to remove /usr/bin from path. NOOOOOO.



I'm using ubuntu 16.04. I added the new program bin to path by typing:



sudo nano ~/.bashrc


The new path was added, but then I tried to update using sudo and I got this error:



The command could not be located because '/usr/bin' is not included in the PATH environment variable.


However, the bin still exists:



 Command 'sudo' is available in '/usr/bin/sudo'


nano in available, ls is available - its all available - but not in path. So, simply trying:



sudo nano ~/.bashrc


and trying to add /usr/bin to path is not an option. Without sudo I dont have permission to open bashrc. I can cd into /usr/bin, but I cant ls anything, and I have no idea how to access sudo or nano once I'm in there. ./sudo, sudo.sh ./sudo.sh all returns "command not found".



How do I add /usr/bin to path in the event I remove it?



EDIT



I found the solution here: I think I accidently deleted the PATH variable



I replaced the PATH with the path of the program I added to my path. So, typing this into a terminal gave me access to sudo and nano again:



export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin









share|improve this question



















  • 1




    Try /usr/bin/sudo su.
    – N0rbert
    1 hour ago










  • @N0rbert, I found the answer, please see my edit. I gotta turn the TV off is the real solution.
    – Phil_T
    56 mins ago






  • 1




    Possible duplicate of I think I accidently deleted the PATH variable
    – N0rbert
    55 mins ago










  • FWIW you really shouldn't be using sudo to modify files in your own home directory
    – steeldriver
    6 mins ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











Lets get this out of the way, I did something stupid. Yes, stupid. Very stupid. I am well aware of how stupid this is. I am embarrassed and I regret doing it. Please help. I was installing a program, while also watching TV, and somehow managed to remove /usr/bin from path. NOOOOOO.



I'm using ubuntu 16.04. I added the new program bin to path by typing:



sudo nano ~/.bashrc


The new path was added, but then I tried to update using sudo and I got this error:



The command could not be located because '/usr/bin' is not included in the PATH environment variable.


However, the bin still exists:



 Command 'sudo' is available in '/usr/bin/sudo'


nano in available, ls is available - its all available - but not in path. So, simply trying:



sudo nano ~/.bashrc


and trying to add /usr/bin to path is not an option. Without sudo I dont have permission to open bashrc. I can cd into /usr/bin, but I cant ls anything, and I have no idea how to access sudo or nano once I'm in there. ./sudo, sudo.sh ./sudo.sh all returns "command not found".



How do I add /usr/bin to path in the event I remove it?



EDIT



I found the solution here: I think I accidently deleted the PATH variable



I replaced the PATH with the path of the program I added to my path. So, typing this into a terminal gave me access to sudo and nano again:



export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin









share|improve this question















Lets get this out of the way, I did something stupid. Yes, stupid. Very stupid. I am well aware of how stupid this is. I am embarrassed and I regret doing it. Please help. I was installing a program, while also watching TV, and somehow managed to remove /usr/bin from path. NOOOOOO.



I'm using ubuntu 16.04. I added the new program bin to path by typing:



sudo nano ~/.bashrc


The new path was added, but then I tried to update using sudo and I got this error:



The command could not be located because '/usr/bin' is not included in the PATH environment variable.


However, the bin still exists:



 Command 'sudo' is available in '/usr/bin/sudo'


nano in available, ls is available - its all available - but not in path. So, simply trying:



sudo nano ~/.bashrc


and trying to add /usr/bin to path is not an option. Without sudo I dont have permission to open bashrc. I can cd into /usr/bin, but I cant ls anything, and I have no idea how to access sudo or nano once I'm in there. ./sudo, sudo.sh ./sudo.sh all returns "command not found".



How do I add /usr/bin to path in the event I remove it?



EDIT



I found the solution here: I think I accidently deleted the PATH variable



I replaced the PATH with the path of the program I added to my path. So, typing this into a terminal gave me access to sudo and nano again:



export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin






permissions sudo environment-variables bashrc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 57 mins ago

























asked 1 hour ago









Phil_T

1717




1717







  • 1




    Try /usr/bin/sudo su.
    – N0rbert
    1 hour ago










  • @N0rbert, I found the answer, please see my edit. I gotta turn the TV off is the real solution.
    – Phil_T
    56 mins ago






  • 1




    Possible duplicate of I think I accidently deleted the PATH variable
    – N0rbert
    55 mins ago










  • FWIW you really shouldn't be using sudo to modify files in your own home directory
    – steeldriver
    6 mins ago












  • 1




    Try /usr/bin/sudo su.
    – N0rbert
    1 hour ago










  • @N0rbert, I found the answer, please see my edit. I gotta turn the TV off is the real solution.
    – Phil_T
    56 mins ago






  • 1




    Possible duplicate of I think I accidently deleted the PATH variable
    – N0rbert
    55 mins ago










  • FWIW you really shouldn't be using sudo to modify files in your own home directory
    – steeldriver
    6 mins ago







1




1




Try /usr/bin/sudo su.
– N0rbert
1 hour ago




Try /usr/bin/sudo su.
– N0rbert
1 hour ago












@N0rbert, I found the answer, please see my edit. I gotta turn the TV off is the real solution.
– Phil_T
56 mins ago




@N0rbert, I found the answer, please see my edit. I gotta turn the TV off is the real solution.
– Phil_T
56 mins ago




1




1




Possible duplicate of I think I accidently deleted the PATH variable
– N0rbert
55 mins ago




Possible duplicate of I think I accidently deleted the PATH variable
– N0rbert
55 mins ago












FWIW you really shouldn't be using sudo to modify files in your own home directory
– steeldriver
6 mins ago




FWIW you really shouldn't be using sudo to modify files in your own home directory
– steeldriver
6 mins ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










You can prefix the commands with the path:



/usr/bin/sudo /bin/nano ~/.bashrc





share|improve this answer




















  • Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
    – Phil_T
    53 mins ago










  • @N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
    – WinEunuuchs2Unix
    48 mins ago











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1081544%2fhow-to-add-usr-bin-to-path-after-i-mistakenly-removed-it-sudo-and-nano-are-no%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










You can prefix the commands with the path:



/usr/bin/sudo /bin/nano ~/.bashrc





share|improve this answer




















  • Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
    – Phil_T
    53 mins ago










  • @N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
    – WinEunuuchs2Unix
    48 mins ago















up vote
3
down vote



accepted










You can prefix the commands with the path:



/usr/bin/sudo /bin/nano ~/.bashrc





share|improve this answer




















  • Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
    – Phil_T
    53 mins ago










  • @N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
    – WinEunuuchs2Unix
    48 mins ago













up vote
3
down vote



accepted







up vote
3
down vote



accepted






You can prefix the commands with the path:



/usr/bin/sudo /bin/nano ~/.bashrc





share|improve this answer












You can prefix the commands with the path:



/usr/bin/sudo /bin/nano ~/.bashrc






share|improve this answer












share|improve this answer



share|improve this answer










answered 59 mins ago









WinEunuuchs2Unix

37k760138




37k760138











  • Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
    – Phil_T
    53 mins ago










  • @N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
    – WinEunuuchs2Unix
    48 mins ago

















  • Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
    – Phil_T
    53 mins ago










  • @N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
    – WinEunuuchs2Unix
    48 mins ago
















Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
– Phil_T
53 mins ago




Yeah, that works too. Thanks. My heart dropped for second when sudo stopped working.
– Phil_T
53 mins ago












@N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
– WinEunuuchs2Unix
48 mins ago





@N0rbert Sorry I didn't notice any comments when I started writing the answer. It could be we were writing at same time? Also since the user is owner of ~/.bashrc using sudo isn't necessary.
– WinEunuuchs2Unix
48 mins ago


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1081544%2fhow-to-add-usr-bin-to-path-after-i-mistakenly-removed-it-sudo-and-nano-are-no%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Confectionery