It's not only important to know when to use sudo and when not to use it, but it's also useful to know that whenever you wanna edit a file use sudoedit instead of sudo vim. Sudoedit opens a file with root privileges, but with your preferred editor keeping your user config of vim, nvim, or whether editor you're using. It's neat as it opens vim that you're used to, not the standard vim without any config.
I doubly recommend using shell aliases (e.g; bashrc, fishrc, zshrc) to prevent catastrophic data loss: such as extending their instruction to include safeguard flags (the "hyphen-letter" that you see in manpages), like "rm -i --preserve-root" so NOTHING you remove by accident has a chance to destroy root files of any kind. The "cp -n" should replace the standard cp command via an alias of "cp", so catastrophically erroneous overwrites do not occur. Same applies to "mv -n" in place of just "mv".
As someone who is very guilty of pasting random stuff from the internet into my terminal, I think a better way to go about this is using a VM. Save a snapshot it every now and then so it doesn't matter when you break everything inside that VM. If you don't have the time to fully understand what you're doing, you can be free of worries. And if you do break something, it's a great opportunity to learn without going through the pain of setting things up again.
Using sudo requires the user to know what he's doing, but using Linux requires the user to do changes as root all the time, because only 25% of tools are working out of the box xD
When I first used linux, I had to reinstall it thrice in the same week (Fedora 9). I blindly edited config files as root and broke things. I didn't know to to reverse things back the then. Fun times :-)
When copying from a web it is also possible that the copied text contains escape sequences which make it not show on the terminal when pasted, but injected text is executed. It may easily install a trojan and you won't notice. It happened to me.
Just last week a coworker ran the following command on a server without knowing what it does: "sudo find /. -mtime +30 -delete". Long story short he deleted the whole Root Directory and important files and we had reinstall the whole server. Took us a week to undo what 2 min of thinking could have prevented. So always be careful when working with Linux.
@Terminalforlife I would have thought so too, but apparently "/." means the whole root directory. If your type "ls /." it totally list the whole root directory. He got an SSH ban on all systems.
I've never broken system with sudo and don't mind about braking my system too much I can recover the data from a live iso and reinstall but what I do care about is losing data like accidentally moving a file and then deleting where I moved it to.
As a dum dum who's used Linux over a decade I still have no idea what I'm copying/pasting in the command terminal. I've simply learned to back up my system.
@@MormonJesus69420 It probably only matters if you edit multiple files. sudo -e will use sudoedit. Or something like that, not 100% sure. Some of the options vary too.
When I was new to Linux, I mistakenly break OS every week mainly because of using sudo. That's why having a backup of system or having a bootable pendrive is nessary.
Hey, I like your terminal setup. Is there a video you made on how to get this look and feel? If so I'm unable to find it and would appreciate if you could share me a link. If not, which terminal emulator is this and how can I get it to look like that?
This video will get you close if you're talking about the shell itself. ua-cam.com/video/oR8v9uOCq0E/v-deo.html If you're talking about the terminal, that's alacritty. It's in i3 with picom for rounded corners.
We learn most from our mistakes. You know very well that “knowing precisely what your doing” doesn’t come from reading a man page or watching a video alone. It also requires one to actually work with the command or platform. In that process, mistakes are inevitable as are system breakages. If one wants to avoid those possibilities, stay away from Linux. Stay with Apple or Microsoft. They have locked away most of those possibilities. [edited]
@Terminalforlife I sorry that my comment about man pages came across negatively. My point is that it takes BOTH reading/study AND practice/application to become proficient in any discipline. I have edited my comment to hopefully correct the impression.
I used sudo apt install nautilus-admin to get a right click option to open a file or folder as root. Makes things nicer for us 30 yr Windows users. Zorin Core, BTW.
I would recoment tldr or --help over man. If you have never even used the command before, man is just insanely excessive and can leave you more confused about what the command does than when you started
Just came to poke anyone who cares. Most don’t. It’s not a big deal I guess. But in case you find yourself teaching in a room. sudo is short for ‘Super User Do’. ‘Sue Doo’. Not ‘Sue Dough’. Sorry for that. Don’t mean to be the douche of the comments section.
"You have to know precisely what you're doing" "Hmmm, I don't actually know if it would delete pacman.conf - so I'm gonna cancel" lmfao - you do not have permissions to: remove write-protected regular file 'pacman.conf' - so it will warn you and even if you confirm say "Permission denied" How do you not know that? How do you not know how the basics of Linux permissions work? Get outta here trying to tell anyone they have to be an expert to use sudo if you don't even know that
This video was released early for Patrons. patreon.com/thelinuxcast
It's not only important to know when to use sudo and when not to use it, but it's also useful to know that whenever you wanna edit a file use sudoedit instead of sudo vim. Sudoedit opens a file with root privileges, but with your preferred editor keeping your user config of vim, nvim, or whether editor you're using. It's neat as it opens vim that you're used to, not the standard vim without any config.
Been doing this stuff for a while and did not know about 'sudoedit' - thank you!
oh that's wonderful to know. thanks!
Oh sweet
There are great noob pointers on this video with clear explanations. Nice work.
I doubly recommend using shell aliases (e.g; bashrc, fishrc, zshrc) to prevent catastrophic data loss: such as extending their instruction to include safeguard flags (the "hyphen-letter" that you see in manpages), like "rm -i --preserve-root" so NOTHING you remove by accident has a chance to destroy root files of any kind. The "cp -n" should replace the standard cp command via an alias of "cp", so catastrophically erroneous overwrites do not occur. Same applies to "mv -n" in place of just "mv".
I thought that's what the "one weird linux tip" was gonna be
As someone who is very guilty of pasting random stuff from the internet into my terminal, I think a better way to go about this is using a VM. Save a snapshot it every now and then so it doesn't matter when you break everything inside that VM.
If you don't have the time to fully understand what you're doing, you can be free of worries. And if you do break something, it's a great opportunity to learn without going through the pain of setting things up again.
Solid advice. 👍
Excellent video. Good information.
when you said "if you never used sudo before", i thought you were going to say "remember that with great power comes great responsability", 😂
Using sudo requires the user to know what he's doing, but using Linux requires the user to do changes as root all the time, because only 25% of tools are working out of the box xD
Great video. Very informative and essential for beginners. Kudos!
When I first used linux, I had to reinstall it thrice in the same week (Fedora 9). I blindly edited config files as root and broke things. I didn't know to to reverse things back the then. Fun times :-)
When copying from a web it is also possible that the copied text contains escape sequences which make it not show on the terminal when pasted, but injected text is executed. It may easily install a trojan and you won't notice. It happened to me.
a trojan!!!!! get real.
@@riseabove3082 Yeah because you're entering the sudo password.
Just last week a coworker ran the following command on a server without knowing what it does: "sudo find /. -mtime +30 -delete". Long story short he deleted the whole Root Directory and important files and we had reinstall the whole server. Took us a week to undo what 2 min of thinking could have prevented. So always be careful when working with Linux.
@Terminalforlife I would have thought so too, but apparently "/." means the whole root directory. If your type "ls /." it totally list the whole root directory.
He got an SSH ban on all systems.
Surprised you didn't mention more restricted sudo alternatives like doas.
I love doas, but I think it might confuse the issue.
I've never broken system with sudo and don't mind about braking my system too much I can recover the data from a live iso and reinstall but what I do care about is losing data like accidentally moving a file and then deleting where I moved it to.
An important reminder to us all.
Why not install ‘doas’ and remove ‘sudo’?
As a dum dum who's used Linux over a decade I still have no idea what I'm copying/pasting in the command terminal. I've simply learned to back up my system.
`sudo -e FILE` will edit the file with your current Vim configuration. `sudo vim FILE` uses the config of your super users Vim config.
Oh i didn't know that you could do sudo -e, I'm used to sudoedit. Good to know the other alternative
@@MormonJesus69420 It probably only matters if you edit multiple files. sudo -e will use sudoedit. Or something like that, not 100% sure. Some of the options vary too.
I know. I also know about sudoedit, but I never use them because I never remember when I'm supposed to
@@TheLinuxCast yeah I'm guilty of that too, but it's nice to use it when I remember that i can
@@TheLinuxCast It is easy to remember using sudo -e instead of sudo vim, because my plugins won't work otherwise.
Can you tell me what fetch script you use? And also how do you get icons for ls?
When I was new to Linux, I mistakenly break OS every week mainly because of using sudo. That's why having a backup of system or having a bootable pendrive is nessary.
Hey, I like your terminal setup. Is there a video you made on how to get this look and feel? If so I'm unable to find it and would appreciate if you could share me a link. If not, which terminal emulator is this and how can I get it to look like that?
This video will get you close if you're talking about the shell itself. ua-cam.com/video/oR8v9uOCq0E/v-deo.html
If you're talking about the terminal, that's alacritty. It's in i3 with picom for rounded corners.
Everyone needs to learn 'sudo !!'
We learn most from our mistakes. You know very well that “knowing precisely what your doing” doesn’t come from reading a man page or watching a video alone. It also requires one to actually work with the command or platform. In that process, mistakes are inevitable as are system breakages. If one wants to avoid those possibilities, stay away from Linux. Stay with Apple or Microsoft. They have locked away most of those possibilities. [edited]
@Terminalforlife I sorry that my comment about man pages came across negatively. My point is that it takes BOTH reading/study AND practice/application to become proficient in any discipline. I have edited my comment to hopefully correct the impression.
cd ... (triple dot)?
It's an alias for cd ../..
I used sudo apt install nautilus-admin to get a right click option to open a file or folder as root. Makes things nicer for us 30 yr Windows users. Zorin Core, BTW.
Over use of sudo without accompanying knowledge can/will make your system unbootable! Don't ask me how I know this :-)
From personal experience like the rest of us. We learn the most from our mistakes. We break things to learn things. LOL
Whats the terminal conf?
That's alacritty with powerlevel10k
@@TheLinuxCast cool tnx ill check it out
tldr and cheat with man is best, that way you have some example uses right off the bat that you can then go more extensively with the man pages.
lol the first tip is literally RTFM
How will this save my life?
I mean, you could show us some nice picture and speak in the background.
I would recoment tldr or --help over man. If you have never even used the command before, man is just insanely excessive and can leave you more confused about what the command does than when you started
Just came to poke anyone who cares. Most don’t. It’s not a big deal I guess. But in case you find yourself teaching in a room. sudo is short for ‘Super User Do’. ‘Sue Doo’. Not ‘Sue Dough’. Sorry for that. Don’t mean to be the douche of the comments section.
"You have to know precisely what you're doing"
"Hmmm, I don't actually know if it would delete pacman.conf - so I'm gonna cancel"
lmfao - you do not have permissions to: remove write-protected regular file 'pacman.conf' - so it will warn you and even if you confirm say "Permission denied"
How do you not know that? How do you not know how the basics of Linux permissions work? Get outta here trying to tell anyone they have to be an expert to use sudo if you don't even know that
I didn't say expert one time in the video. And I made this video for someone who didn't know. So don't be an elitist asshole.
He did a very important step which some people dont do: If you are unsure what a thing does, dont do it. He did everything right.