0

My knowledge on unix is very less. I updated .profile file for sudo user but some path was incorrect in that file. When I am trying to reconnect as a sudo user it does not recognize any commands and its not allowing me to edit the .profile file either. I tried to copy the correct .profile from my own profile but it does not recognize any commands.

How can I fix the corrupted .profile file for a sudo user ?

Edit 1: Below is the error when i try to edit the .profile -

/home/dts>vi .profile

-ksh: vim: not found [No such file or directory]

I tried this - /usr/bin/sudo nano ~/.profile? but I am not able to login because i dont have root privileges.

/home/dts/etc>/usr/bin/sudo nano ~/.profile?

sudo: 3 incorrect password attempts

Edit 2: Tried to copy/move the .profile from another sudo account but it does not recognize any commands

/home/dts/etc>cp /home/sq73223/.profile_dts /home/dts/.profile 
-ksh: cp: not found [No such file or directory] 

/home/dts/etc>mv /home/sq73223/.profile_dts /home/dts/.profile 
-ksh: mv: not found [No such file or directory] 

/home/dts/etc>whoami 
-ksh: whoami: not found [No such file or directory]  
  • probably you messed up the PATH on the profile and it is not able to find sudo right now. In order to fix it, you need to be able to obtain root privileges to edit the profile and undo the mistakes you did. Hopefully you remember what you did and revert it back. Otherwise I don't know how you can recover from this – MelBurslan Jan 26 '16 at 0:04
  • What exactly is the error when you try to edit the profile? if it is simply that the sudo executable is no longer on your PATH, have you tried /usr/bin/sudo nano ~/.profile? – steeldriver Jan 26 '16 at 0:07
  • I updated the question with the exact error as requested. – Mohsin Jan 26 '16 at 0:23
  • You need to try the sudo command from the account that has sudo permission. – psusi Jan 26 '16 at 0:53
  • Tried with another account which has sudo access but still not able to copy or move the .profile file - It does not recognize any commands. /home/dts/etc>cp /home/sq73223/.profile_dts /home/dts/.profile -ksh: cp: not found [No such file or directory] /home/dts/etc>mv /home/sq73223/.profile_dts /home/dts/.profile -ksh: mv: not found [No such file or directory] /home/dts/etc>whoami -ksh: whoami: not found [No such file or directory] – Mohsin Jan 26 '16 at 15:35
0

It looks like you screwed up the PATH setting (used to locate programs). Try e.g. sudo /usr/bin/vi ... (i.e., give full path to executables).

You can also try to login as root directly, or su into the account.

  • Thanks for the hint @vonbrand ..although I couldn't try it myself I got it fixed from my server admin who was able to update it with root permissions – Mohsin Jan 26 '16 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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