How to Stay in the Same Directory When Using Sudo in Linux?

0
10
Asked By CuriousExplorer42 On

I'm trying to get a handle on Linux, but it's been a bit of a challenge. I often need to run applications as an admin (you know, with 'sudo'). The problem I'm facing is that when I run 'sudo -i', it kicks me out of the current directory and I have to manually 'cd' back to where I was, which feels really tedious. Is there an easier way to use 'sudo' without losing my place in the file system? It seems like a small thing, but it makes using Linux feel more cumbersome compared to Windows. Any tips or tricks to streamline this would be greatly appreciated!

2 Answers

Answered By LinuxGuru89 On

You can try using 'sudo su' instead of 'sudo -i'. This command will log you in as the root user while keeping you in the same directory. It makes the process a lot smoother since you won’t have to re-navigate to your previous folder every time. Give it a shot!

CuriousExplorer42 -

Thank you! I appreciate the simple solution.

Answered By NewbieNavigator On

Just a heads up, not everything on Linux needs to be run as admin. It might feel that way because a lot of tutorials emphasize using 'sudo' for everything. You could check your permissions and see if you really need to escalate privileges for what you're doing. Sometimes, you can run things as a regular user, which avoids the hassle altogether!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.