mkdir is used to make a directory, so you use it whenever you want to create a new directory. It’s the same as creating a new folder with your file manager.
You should use sudo only when you need to run a certain command not as your user account, but as root. This is usually limited to operations that modify files that are owned by root, files which are outside your home directory. This includes operations like installing packages or updating your system. If you are in doubt, you should first try without sudo and then pay attention to the error message. If the error message is something like “Permission denied” or “you cannot perform this operation unless you are root”, that means exactly that. Then think twice do you really want to perform this operation as root, and if you do, then you need sudo. Just make sure you know exactly what you’re doing and why root privileges are necessary for it. The time it takes you to type sudo is well spent thinking about what are you doing ![]()
You should never use sudo in the following situations:
- when the command works fine without
sudo - with any GUI program (including, but not limited to GUI text editors and file managers)
- when building packages for ALPM (i.e. with
makepkgor withyay) - with 3rd party package managers, like
pip,npm,gem(this is especially important on Arch, on other distros you may need to). - with
wine
I call these use cases: sudon't ![]()