Skip to playerSkip to main contentSkip to footer
  • 4 days ago
Join me in this comprehensive guide to over 30 essential Linux commands! Whether you’re a beginner or looking to brush up on your skills, this video covers critical commands such as cd, ls, cp, and many more. Each command includes practical examples to help you understand how to use them effectively in your daily work, be it in programming, system administration, data science, or something else. Let’s dive into the world of Linux and enhance your command-line skills!
---
πŸš€ Launch your websites with Cloudways β€” managed cloud hosting made easy.
Try Cloudways for fast, secure WordPress, WooCommerce, or custom apps.
πŸ‘‰ Get started with our link πŸ‘‡
https://go.watsontechworld.com/cloudways
---
Our website: https://watsontechworld.com
---
00:00 Intro
00:50 cd
01:50 ls
03:58 Using tabs for auto completion
04:25 cp
06:23 diff
07:14 pwd
08:23 mkdir
09:30 Comments in Bash
10:39 sudo
11:52 rm part 1
12:29 * wildcard
13:30 rmdir
14:08 rm part 2
15:32 history
16:36 cat
17:40 man
19:18 wget part 1
19:54 unzip
20:24 wget part 2
20:48 ping
21:33 top
22:30 sort
23:21 uniq
23:53 Example of 2 commands used with piping (|)
24:41 touch
26:00 echo
26:42 Example of output redirection (>)
27:46 Output redirection (>)
29:04 du
30:00 df
30:56 free
32:34 find and "." in bash
34:30 grep
37:13 rename
38:44 sed
40:36 head
41:23 tail and CTRL l
42:21 git clone
43:28 bash
44:30 chmod and chown
45:42 Review of Linux commands part 1
46:03 mv
47:07 Review of Linux commands part 2
49:17 Conclusion
---
#Linux #LinuxCommands #LinuxTutorial #CommandLine #Bash #SysAdmin
Transcript
00:01Hi, everyone. In this video, I'm going to go over 30 very useful Linux commands, and these will be very useful regardless of what you do, whether it's for personal computer use, whether it's for cybersecurity or data science or data analytics or system administration.
00:18These commands are all very useful in Linux, and I would consider most of them to be beginner commands, and I'm going to give you examples of all of these and try to make it very useful.
00:30Okay, so let's get started. So these are the commands I'm going to use. I'll scroll over them, and I also have, I've named all the different folders, the commands I'm going to use.
00:46So let's get started with the first one. The first one is the cd command. And cd, I just did there, cd means change directory, I believe.
01:00Okay, I'm pretty sure cd means change directory, and it's basically how you can move around directories.
01:09And cd is very, very useful, and if you ever use Linux, you're almost certainly going to use it a lot.
01:15So let's say, for example, I wanted to move to the 05 folder, 05-mv. I would just type cd and then the folder name.
01:26And if I want to go up one directory, you can type cd space dot dot. And to go up two directories, you can do cd space dot dot, and then a forward slash and then another.
01:41And that takes you up two directories. So it's very, very useful. The next one would be ls. And I think I've used, I've typed ls already.
01:54ls stands for list directory contents. And it's basically a way to get the, basically list all the different files and folders inside of a directory.
02:09And there's a lot of different flags and or a parameters you can use or anyway, that's very, very useful. It's very versatile.
02:22So this is the typical command ls. But if I wanted to get all the information, you can type ls space dash la.
02:32And this will give you all the, basically the most important file information, the owner, the group, when it was, I believe this was when it was, when it was made or either when it was last.
02:46Yeah, it's probably when it was made. Honestly, I don't remember. These are the permissions.
02:51And so this gives you lots of very good information. And instead of listing it like that, you could also have it listed all on one line.
03:02And if you do dash one, that will list it all on one. Now these are all directories.
03:16Those are all directories. But it will also show you files. So for example, this has, this was a GitHub repository. So this shows you folders and files.
03:28So the ls and if you wanted to do ls dash one, it'll show you the, so the way that this terminal is set up, I think the blue color means it's a folder.
03:39And if it's not blue, it's, it's a file. So ls is very, very useful. And then of course, you can combine. So you can use CD and then ls or ls dash la.
03:58And I forgot to mention, I'm also using the tab. If you, if you use Linux commands a lot, you can use a tab.
04:09So for example, I can type CD and then bi tab. And that can, it's kind of a way to auto complete.
04:20Okay, so now I've shown you ls and CD. And now let's go over the copy command CP.
04:28So the copy command CP is basically, like I said, it's a way to copy files. So this is a GitHub repository I downloaded.
04:43And this is a, it has a file code of conduct. Let's say you want to call it, you want to copy the code of conduct.
04:54Just call it code of conduct. You can say, for example, underscore copy.
05:01And that's a way to actually copy the files.
05:07And I wanted to show you, I just copied that. And just to show you that they're identical, we can look at them and they're exactly the same size.
05:18So that's good. So that was the copy command and copy command is certainly going to be one of the most common ones you may use.
05:28And again, it stands for copy files and directories. And you can also copy an entire directory.
05:35For example, let's say when I copy packages, you can do the, you can use the dash R, that means recursive.
05:41You can do packages. And I can call, let's call it another folder.
05:50And I'll discuss about this, the diff command, but just to make sure the diff command, just to make sure these are exactly the same.
05:59So it didn't give any output, which means those are exactly the same.
06:07So I just copied the packages command, I mean, the packages folder into another folder.
06:12So they're exactly the same. So copy can be used both for copying just a single file or multiple files or even folders.
06:21Okay, let's go up. Now let's talk about the ls.
06:25I was already talking about, so the diff command, I think I mentioned about the diff command.
06:28So again, we want to, if we want to check to see if they're, for example, diff code of conduct dot markdown code of contact.
06:42We want to see if they're exactly the same. We get no output, so that means they're exactly the same.
06:51And similarly, if you want to see if the folders, another folder and packages are exactly the same.
06:57We can use the recursive flag dash R, do another folder and packages like that.
07:08Okay, so that was the copy command.
07:14Now let's talk about pwd.
07:24So what this stands for is print working directory.
07:29It says print the name of current or working directory.
07:32And it's quite useful at times.
07:35So I just type pwd.
07:37And what this tells you is basically where you're working at the current moment.
07:44And this can be very useful, especially if you're programming.
07:47So for example, if I want to copy this, let's say I want to copy this.
07:51I can type cd and then put that in parentheses or put quotes or double quotes.
07:58It doesn't matter.
07:59cd dot.
08:00And we're back into the same one.
08:02But let's say, for example, I went up two directories.
08:06I can go back to it, back to where we were originally.
08:10Okay, so that was pwd.
08:11It's pretty simple, but it's very useful.
08:13And I would say it's mostly useful probably for programming.
08:16But it can be useful if you're not programming.
08:21Okay, now the make dir command.
08:28So this is a very useful command.
08:30Basically, it stands for make directories.
08:35So let's say we want to make a folder.
08:42You can make a folder with make dir like that.
08:45And then folder, folder one.
08:47Call it whatever you want.
08:48Let's say we want to make five folders.
08:50Make dir a, b, c, d, e.
08:54Okay, it just made five folders.
08:56Folder a, folder b, folder c, folder d, folder e, and folder one.
09:04And so we have just made six folders.
09:07So make directory is a very useful command.
09:11And make a directory fun.
09:14And so all these folders are empty.
09:18We haven't put any files in them.
09:20But later I'll show some with output.
09:24Okay, now let's go to the next command, which is,
09:29I'm going to say it's this.
09:32So this symbol hash means a comment.
09:36And it's a very, very useful thing.
09:40So I wouldn't actually say it's a command.
09:42It's an aspect of the bash language.
09:45But anything you have, if you put this as the first in a command,
09:51anything after will be ignored.
09:54So for example, it can say hash space cd.
09:59And with that, that'll basically, a comment means the interpreter will ignore everything after it.
10:05So if you, if you're making, if you've made a typo, or if you've done something you,
10:11it can be useful for example, if you, if you don't want to run a command,
10:15but you'll come back to it.
10:17For example, let's say you want to delete a file.
10:20I'll discuss the RM command, but you don't want to delete it now.
10:23You can just do a, this means ignore.
10:25And then when you want to come back, you can run it as is.
10:28So this, the, the hash is the comment in bash and it's very useful.
10:36Okay.
10:37So let's go to the next one, sudo.
10:40So sudo is basically, I'll look it up for you.
10:44So execute a command as another, basically this, execute a command as the super user.
10:51So that's the most common use is as, so basically it means run a command as the administrator.
10:57So I'm not going to actually run this command, but for example, in Ubuntu,
11:02you can update your system with sudo apt update and then sudo apt upgrade dash y.
11:10And what this will do is basically it'll update and upgrade your system.
11:16You have to be an administrator to update and upgrade on in Ubuntu or Debian.
11:22And so sudo is basically, you'll be using it if you want to install software or do things that require super, super user rights.
11:32So you'll use sudo a lot, most likely.
11:35And I just put a comment here.
11:37So it completely ignored it.
11:39But if I, if I didn't completely ignore it, it'll ask you for your sudo password and you'll need to type that in.
11:46Otherwise it won't work.
11:49Okay.
11:50Let's go to the next one.
11:52It is the RM command.
11:59So I have these five files.
12:02They are, notice they, they all have zero bytes.
12:08So they're all completely empty files.
12:10It just file one, two, three, four, five, they're different files.
12:13And RM is a command that allows you to delete a file.
12:17For example, let's say delete one.
12:19RM one means you will delete that file.
12:23Let's say RM five.
12:25So you'll delete file five and so on.
12:28And now I want to discuss the, the wildcard.
12:35So the wildcard in, in, in Linux, in bash, the asterisk is a wildcard that, and that means anything or everything, depending on the context.
12:50So in this context, for example, I've still got these files.
12:57So if I want to delete all of them at once, you can type RM space star or asterisk, and it will delete all of them.
13:05So this, so this is a very useful thing in regular expressions.
13:10I won't discuss regular expressions much other than this is a very useful wildcard.
13:16The wildcard is very useful.
13:17So if you type RM star, notice that all of these files are gone.
13:22And then if you type LSS LA, they're all gone.
13:28So that's a very useful command.
13:30Now let's talk about the RM dir command.
13:34And it's similar to the RM command, but it only deletes directories.
13:40So we have, previously I did something like this, make dir A, B, C, D.
13:46And we've got empty folders.
13:48The RM dir command will delete folders.
13:51It only deletes folders.
13:52It won't delete files.
13:55So I just did RM dir A.
13:57And if you want to delete multiple folders, they all have to be empty.
14:01So this will delete all of them.
14:07Now going back to the RM command, I wanted to also mention about, I'm going to show you something I'll discuss later.
14:16Let's say I want to discuss, I want to make a directory.
14:19Let's say test.
14:21And let's, let's go into test and we'll make, we'll make four sub folders.
14:28And let's also make four sub files.
14:33And I'll just, I'll discuss the touch command later.
14:36So we have four files and we have four folders in here.
14:40You can actually use the RM command, RM dash R.
14:45And this will, if you do RM dash R and then on a folder, what it will do is essentially do, it will delete all the files and sub files.
14:58And it will do, excuse me, it will, it'll delete the folder and all sub folders and sub files.
15:06So if I'd run it like that, RM dash R test.
15:10So the entire folder is gone and all the sub files and sub folders are gone.
15:16So that's a very useful thing to have.
15:18And typically I actually use RM dash RF, but you can use just dash R for beginners.
15:26Okay.
15:27Now let's talk about the history command.
15:34So history command is very useful.
15:38I'm going to type history dash C that's going to clear the history, but I'm going to type a few commands.
15:46Now let's say CD this, this, this.
15:49So I cleared the history, but now let's go back and let's type the history command now.
15:57So I've typed, there are nine commands that I've typed.
16:01And then if I want to clear it, history will just show that I've typed the history command.
16:07A history command is very useful if you want to see all the previous commands that you've typed.
16:14So for example, here, I'm just moving around and it, the history command will show you all the previous commands you've typed.
16:28It can be very useful, especially if you're trying to debug something or doing system administration.
16:35Okay, now the cat command.
16:38The cat command, basically it's a way to, let's see here, let's go back to, let's go to here, let's go to the playground.
16:53So the cat command is a way to basically output a text file to the, to the terminal.
17:00So I have, this is Sherlock Holmes, this is a Sherlock Holmes book.
17:06And cat stands for concatenate files and print them on the standard output.
17:12So again, if I want to, if I want to output the book, Sherlock Holmes, and this is from Gutenberg, the cat is an incredibly useful thing.
17:24Now this file is very big.
17:27So I don't think it'll show everything because it actually cuts off after a certain point.
17:32But the cat command is very, very useful.
17:35And it's basically a way to output the text to the terminal.
17:40Okay, now the man command, M-A-N.
17:44The man command is a way to get manuals for specific commands.
17:49So for example, let's say you want to look up LS.
17:51Maybe you've forgotten different flags.
17:53You can look up different flags and different things.
17:56And it's incredibly, very, incredibly useful.
17:59So for example, again, man LS.
18:02You can look up, for example, I did LS-LA before.
18:07You can look up, what is dash, dash N, dash L sorry.
18:14So dash L means use a long listing format.
18:19And then for example, I, again, like I've said, I do LS-LA.
18:24If I want to do, if I want to look up what the dash A flag means.
18:34It means dash, it means do not ignore entries with dot.
18:41So this means show everything, even hidden files.
18:45So the man command, you can use it for almost any Linux command, if it actually has a manual.
18:51And later I'll discuss this command, wgit.
18:54And it's basically, you can learn so much about Linux using the man command.
19:00And again, if you want to learn about the pwd command, you can type man space pwd, the command, and you can learn about it.
19:15Okay, now let's go into wgit.
19:21So wgit is a way to basically download things.
19:26And it's called the non-interactive network downloader.
19:29So let's say that you wanted to download WordPress.
19:32If you're on the WordPress site, you can copy the, it has a download WordPress link.
19:38And if I, if you actually type wgit and then, it has to be the direct link to the file.
19:46And you can download it this way.
19:48So this, this just downloaded WordPress.
19:51And now I'm going to discuss the unzip command.
19:56So the unzip command is basically what it, it's in the name, it unzips.
20:01So it basically takes a zip file, a dot zip file, and it will extract it.
20:06So unzip latest dot zip.
20:08So this is all of the WordPress files, the default WordPress files.
20:13For example, if you want to learn about the index dot PHP.
20:20So this is the default WordPress.
20:23And we just downloaded WordPress with wgit.
20:25So the general form is wgit.
20:27And then the direct link, whatever the link is.
20:30So that's the link to WordPress.
20:32But you can download basically anything with wgit.
20:35So long as the firewall isn't blocking wgit.
20:38And it's available publicly on the internet.
20:44Okay.
20:45Now let's discuss the next one, which is ping.
20:50So ping is basically used for networking.
20:54It's very useful.
20:55It has two main uses.
20:57The main use is one, to check if the website is working.
21:04So you can ping, ping olama.com.
21:06Okay.
21:07Olama is working.
21:08And also the other thing is ping can be used to test if your internet connection is working.
21:14If for example, olama.com is working, but your internet is down, you'll see no output.
21:20So ping is very useful.
21:23One, to test if a website is working.
21:26And two, to test if your own internet connection is working.
21:30So that's very good.
21:32Now let's discuss the top command.
21:34So top, T-O-P.
21:36So top is a way to see Linux processes running.
21:39You can see here, it shows you the username, the root, the process ID.
21:46It's got a percentage of CPU usage, the memory usage, and a lot of information.
21:54For example, this is the LX terminal running.
21:57I'm filming this video with OBS.
22:01And so, and this is related to sound stuff.
22:06And then code is VS code.
22:10So the top command is very useful.
22:12And it's basically like a computer monitor, monitoring all the different things going on.
22:19And it says here display Linux processes.
22:23So that's what top is.
22:26Okay, and I've already discussed the history.
22:29Now let's discuss sort.
22:33So the sort command, I'm going to output this text here.
22:37So I have a bunch of random texts.
22:40I wrote blah, blah, blah.
22:42And then I typed the letter D multiple times.
22:44And then, you know, just a bunch of gibberish.
22:47I wrote star text, Star Trek, Star Wars, fun, fun, fun, computer science, computer science.
22:52So the sort command is basically in the name.
22:55It sorts a file.
22:56So you type the sort and then the file name.
22:59And then it will output the file sorted.
23:02And by default, it will be alphabetically from, you know, from A to Z.
23:08You can sort descending, but there's different options.
23:12And if you want to learn more about sort, you can just type man sort.
23:15And you can learn a lot from that.
23:18So that's the sort command.
23:21And then the unique or uniq command is pretty similar.
23:26But it only will give you unique lines.
23:31So it says it will report or emit repeated lines.
23:35So basically, yeah, so unique is basically a way to remove duplicate lines.
23:41So if I do it like this, unique random text, and sometimes you need to do this multiple times.
23:51For example, I'll show you, I'm going to show you piping, but I'll show you this later.
24:05But let's say you want to sort this and then you use unique.
24:09So what this does is it first sorts it, and then it takes the sorted text and gives it to this.
24:15So sometimes unique won't work on the first time.
24:18Like here it has multiple Ds, but I think that's because of the way the original text was.
24:27Sometimes you need to play around with it.
24:29But if you did something like this, first sort it and then do unique,
24:33then you can get rid of the duplicate lines and also sort it.
24:36So that's very useful and they're often, they can be used together.
24:41Okay, the touch command, the touch command is very useful.
24:44What this does is, one, there's basically two things.
24:48One, you can make empty text files.
24:50For example, if I want to untouch.
24:59So this allows you to make empty text files and just to list it like that.
25:02Notice they're all empty.
25:04They have zero bytes.
25:05So these are all empty files.
25:07And note that there's a timestamp on them.
25:10This is the time that I've just made them.
25:16But I'll come back to them in just a moment.
25:18And I want to show you touch because it can update the timestamp.
25:24Okay, let's go back to touch now that it's gone up by one minute.
25:27Just for C.txt.
25:30I just touched it.
25:32And what that did, notice what it did is it updated the timestamp.
25:36It just did it for C.
25:38Notice the timestamp is 2239 for all the other ones.
25:42But I did touch C.txt.
25:45And it updated the timestamp for what the current time is.
25:50So that's the main.
25:51There's two main things.
25:52One, it can make empty text files.
25:54And two, it can update the timestamp of a file.
25:58So it's very useful.
25:59Okay, next let's go to echo.
26:03So echo by itself isn't actually that useful.
26:08It's kind of like if you're familiar with Python,
26:11and it's basically like print of Python or command.council.log in JavaScript.
26:17So by itself, it's not that useful.
26:20But it is very useful in other things like with Pypean.
26:26So you can just type echo and then you can either use single quotes or double quotes like that.
26:36And it echoes.
26:37It's basically print to console.
26:38But it's most useful when you actually use it with other things.
26:43For example, I'm going to show you about this redirect.
26:49Let's say, so what I just did is I said hi there.
26:54And I put it, what this does is it, what's the exact terminology?
26:59It will, it's called output redirection.
27:05And what this does is I just made a text file with hi there.
27:11And we can see that with cat, cat abc.txt.
27:15And notice that the text file is, it has hi there.
27:20And just to show you again, let's say, let's do a moment here.
27:31Where did I put that?
27:32It's in echo.
27:34And if I open the file like this, the text file is just hi there.
27:40So that's echo.
27:42Now, output redirection.
27:49The output redirection, as I've mentioned before, it's just this symbol.
27:55Basically, it's the, this caret symbol pointing to the right.
28:04And again, it's called output redirection.
28:06It's very, very useful.
28:07And basically, it's a way to take output and put it into a text file.
28:14So again, like I said before, you can do like, say, echo.
28:21I like Linux, and put that into a text file, Linux.txt.
28:28And see here, so now that's in there.
28:34So that output redirection is very, very useful.
28:37And you can, when you're doing complex commands, this can be very, very useful.
28:42I use it all the time.
28:44But it's hard, it's a little bit more advanced.
28:47But I just wanted to let you know about that.
28:49That's very, very useful.
28:50So you can take the output from a command and put it into a text file.
28:57Okay, now I've already mentioned about ping.
29:00Okay, so I guess I had pinged twice.
29:02That was a mistake.
29:03Now let's discuss the du command.
29:06So the du command, it stands for estimate file space usage.
29:14So I use it mainly just on single files.
29:18So for example, this one, du Sherlock Holmes.txt, it shows you, and then you can add the flag dash human.
29:31So it's almost one megabyte in size.
29:36It's 596k.
29:38So du dash h is something I use all the time to find what the size of a file is.
29:44If it's a big file.
29:45If it's a big file.
29:49Or just I want to know.
29:51And there's another command I'll discuss later, df.
29:53And that's used for like for the file system.
29:56du is used for individual files.
30:00Okay, now df.
30:02Again, the df command tells you about your file system.
30:07It's very, very useful.
30:09But the one I use most often is df.
30:12And then you have the flag dash h and slash.
30:16And that's assuming your main partition is on slash.
30:19So this gives me very useful information.
30:22So this is my main system.
30:25This is how much storage has been used.
30:28And this is how much storage I have left.
30:31So it says 97% has been used.
30:34So I only have 3% left or 15 gigs left.
30:37And that's a df dash h.
30:40And again, usually I would use that.
30:42It depends on your system.
30:44You can just type df.
30:46And here, this is my main system.
30:50But you can also learn about other things as well.
30:53Okay, the free command.
30:58The free command is very useful.
31:00It tells you information about memory.
31:02So it says display amount of free and use memory in the system.
31:09So the default one, I don't use that much.
31:14Actually, I use the, I often use something like this.
31:19I often will use free dash m or free dash h.
31:26But actually this one is probably better.
31:28Free space dash dash giga dash h.
31:32So this will tell you how much memory is used in gigabytes.
31:36And how much is, for example, this is the total memory is 31.
31:41This is how much swap.
31:44This is how much is free.
31:48So basically this is the memory.
31:51So there are two different things.
31:52This is the memory.
31:53And this is the swap.
31:54Swap takes from the hard drive.
31:56And memory is basically your RAM.
32:00So I have 16 gigabytes free.
32:03And this is how much 4.1 gigabytes has been used.
32:07And then these are some more information.
32:11So if you're running a server, for example, and you have limited RAM, the free dash can give you very useful information.
32:23Again, especially if you're running like a website or you don't have that much memory on your computer.
32:28So you can find how much is being used and how much you have left and so on.
32:33Okay, now let's go to the find command.
32:36So this is a little bit more of a complex command, but I still wanted to show it to you.
32:43So the find command basically is a way to find find files.
32:51So let me show you what I'm talking about.
32:55So what this says is this will find all the different.
33:10This is going to find in find.
33:12First, you have to give it the directory you want to use.
33:15If you want to give it the current directory, you will give it the dot.
33:20So current directory would be dot find dot.
33:23This gives me all the text files.
33:25So all what this says is find all files in the current directory dot dot means current directory.
33:31And this is good to know.
33:36I mentioned before about the asterisks and the dot is another very useful one.
33:41That means dot means current working directory and star means anything or everything, basically.
33:47So it's good to know about dot.
33:49You'll use dot often.
33:51So with find space dot and then dot name space star dot txt.
33:58What this says is find all the files ending in dot txt in the current working directory.
34:06And this will find all.
34:07And it also will look through all the sub folders and sub files as well.
34:13And I have, you see it has WordPress and look how many sub folders.
34:19We've got one sub folder, two, three, four, five, six.
34:23So at least five levels of folders.
34:25So find is a very useful way and a great way to save you time.
34:29Okay, now let's talk about grep, G-R-E-P.
34:35And it's a very useful command.
34:37And let's just look in the manual.
34:39It says print lines that match patterns.
34:43So for example, if I have this.
34:48I mentioned before about the Sherlock Holmes book.
34:53This outputs the whole book.
34:57But let's say we want to find all the lines that have the word Sherlock spelled with a capital S first.
35:06So what this does is it will show you all the lines that have the word Sherlock in it.
35:12Anywhere on the line.
35:14And actually there's not that many lines.
35:18And I'll show you a way we can also use this, the output redirect.
35:26Let's say we want to put it into abcd.txt.
35:30So this takes the output from grep.
35:35Or I'm going to use my favorite text editor, vim.
35:40But I won't show you how to use vim.
35:43So there's 97 lines in the output.
35:46So grep is an incredibly useful thing.
35:52And also you can use the grep.
35:56We can use grep with the dash r flag.
36:05What that does is it's searched recursively.
36:07So that searches for all sub files and sub folders.
36:11It searches through all sub folders.
36:13And I think it only looks through files.
36:15But let's look through all the folders in that that have Sherlock in it.
36:32Let's see here.
36:36grep dash r Sherlock.
36:41Top Linux commands.
36:44Okay, so what this does is it searches for all the files in all the sub folders.
36:51And this shows you here we've got, I put it in a lot of different, and it's going to give you a lot of output because it's actually going to show it a lot.
37:00So search all the different sub files.
37:03So it's a very useful thing.
37:05grep dash r is incredibly useful.
37:07Allows you to search recursively.
37:09And again, it's very useful.
37:12Okay, one more.
37:13And then let's go to rename.
37:18So let's say for example,
37:22let's say that you have some files that are,
37:26there's like a typo.
37:27For example,
37:36let's say that you have your,
37:38you are writing Python code.
37:39And Python code actually should be ending in dot py.
37:43But for some reason,
37:44let's say it ends in dot pyy.
37:46Instead of manually adding all of those,
37:49you can use the command rename.
37:51And that the general form is,
37:54you'll have rename like this,
37:56and then an S.
37:57And then the first one in here is,
38:00is the text that you want to edit.
38:02And then the next one here is the text you want to replace.
38:05And this means everywhere.
38:09And this is the star.
38:12That means,
38:13so that means basically everything in the current folder,
38:17rename.
38:18And I'll,
38:19I'll run that here.
38:20So what this is going to do is rename all the files,
38:24and you need that have dot pyy,
38:27and it'll change it to dot py.
38:30And let's show you here.
38:31So now they've all been changed to dot py.
38:34So rename.
38:35This can use complicated regular expressions,
38:37but it's a very useful thing.
38:39Now let's go here.
38:43Said.
38:44Said is a little bit complicated to use,
38:47but it is incredibly useful.
38:49So for example,
38:51let's say that we wanted to,
38:58I'll zoom out here if I can.
39:02Let's say that we want to replace anywhere where there's the word Sherlock with three emojis of a detective.
39:10And this is something,
39:14notice here that we have,
39:16this is a similar pattern like said.
39:19Rename and said have similar patterns like this.
39:23So what this said will do,
39:24is it will edit the text file and do whatever replacements or other complicated editing in a programmatic way.
39:36So what this is going to do is change all references of Sherlock to three detective emojis.
39:43And then,
39:44again,
39:45what this does,
39:46the,
39:47the carrot,
39:48it's going to save it to a file called detective edited.
39:53So I'm going to do that.
40:00And I made a mistake.
40:01And notice it gave an error.
40:03So you'll learn to use debugging.
40:08It's a very useful skill.
40:10Okay.
40:11So what I just did is,
40:12I now replaced all references of Sherlock with three detective emojis.
40:20Notice here,
40:21it's called the adventures of,
40:23and it's not Sherlock,
40:24the adventures of three detective emojis.
40:27I'll scroll down,
40:28three detective emojis,
40:30three detective emojis,
40:32and so on.
40:33So it's a very useful thing.
40:35And now let's discuss head.
40:38So head is a way to show the top end lines of a file.
40:45So it says output the first part of files.
40:50So for example,
40:51let's say I want to do head detective edited.
40:54This will show the first few lines of the file.
40:57But let's say I wanted to,
41:00I wanted to show the top,
41:04the top 30 lines.
41:07You can type the dash end parameter,
41:10and then the number.
41:11This will show the top 30 lines,
41:13for example.
41:14So head is very, very useful.
41:16It doesn't have to be 30.
41:17It can be any line.
41:18And it's very useful.
41:20Okay.
41:22Now let's type,
41:23let's discuss tail.
41:26So tail is kind of the opposite of head.
41:29Head will show you the first few lines.
41:31And tail will show you the last few lines.
41:34So let's do,
41:35for example,
41:36tail detective edited.
41:38So this is the last few lines of the book.
41:41Now let's say I wanted to show the last,
41:44last 50 lines.
41:47I wanted to show the last 50 lines.
41:51I can type like that.
41:55And note,
41:56I just typed control L.
41:57Control L will clear the screen.
41:59And it's a very useful thing.
42:01So if I want to show the last 50 lines of the book,
42:05type tail dash 50.
42:08Sorry,
42:09tail.
42:10I meant to type,
42:11tail dash n 50 detective edited.
42:15So that's very useful.
42:18And let's do one more.
42:21Git clone.
42:23So this is kind of,
42:24it's not Linux.
42:29I wouldn't say it's command you're going to use that much.
42:32But anytime you're on GitHub,
42:34for example,
42:35any GitHub page will have stuff like this.
42:38And you can copy,
42:39it'll say copy URL.
42:42What you can do is you can copy,
42:44you can download GitHub repositories
42:47with a command like this.
42:49Git clone.
42:50And then you copy the,
42:51the dot get URL.
42:53And what that will do is it will download the GitHub repository for you.
42:58It's very useful.
42:59It doesn't have to be for GitHub.
43:01It can be for any Git repository,
43:02but GitHub is the biggest.
43:04And this is,
43:06this is a machine.
43:09I think this is a open deep research.
43:11I forgot what this is.
43:12It's something from Langchain.
43:14And I haven't actually looked at this much,
43:17but this is,
43:18this was a trending repository and it's,
43:20it's pretty popular.
43:25Okay.
43:26And let's do,
43:27I think we have one more to go.
43:28And then a bash.
43:31So I mentioned,
43:32what we're actually typing right now is bash.
43:38Bash is itself a language.
43:42But if you want to actually run commands like this,
43:48and you want to do it in a programmatic way,
43:51instead of typing everything into the command line,
43:53manually,
43:54you can type them into text files.
43:56And this,
43:57for example,
43:58will download the,
43:59uh,
44:00WordPress.
44:01And then let's say I'll,
44:03I also want it to unzip.
44:06And I'm going to save this.
44:10And then you can run bash files like that.
44:15So what this just did is it downloaded the,
44:20uh,
44:21WordPress,
44:22and it also unzipped it.
44:24And some honorary mentions I'll mention about would be,
44:27uh,
44:28chmod and chown.
44:29So chmod is,
44:30um,
44:31changed the,
44:32uh,
44:33basically it changes the permissions of a file.
44:34So for example,
44:35uh,
44:36download WordPress has,
44:37the permissions for this are six,
44:38six,
44:39four,
44:40but let's say I wanted to change the permissions to seven,
44:41seven,
44:42seven,
44:43seven.
44:44Uh,
44:45Uh,
44:46chmod.
44:47And I haven't used this command in a while.
44:48But let me see here.
44:49Oh,
44:50because I had man first.
44:51So if you want to change the permissions to seven,
44:53seven,
44:54seven,
44:55seven,
44:57um,
44:58chmod.
44:59And I haven't used this command in a while,
45:01but let me see here.
45:02Oh,
45:03because I had man first.
45:04So if you want to change the permissions to seven,
45:06seven,
45:08seven,
45:09let's type this again.
45:11Oh,
45:12because I had man first.
45:15So if you want to change the permissions to seven,
45:18seven,
45:19let's type this again notice that the permissions just changed now this is 777 right here 777 is
45:26the permissions but the permissions for this are 664 and then ch own
45:35is a way to change the ownership but i think i'll end the video here
45:42so i've gone over a lot but these are all incredibly useful commands and
45:47um the best way to learn is by doing so i recommend you practice these a lot
45:53so we went over cd ls the copy command cp pwd diff make directory
46:03mv and oh i'm not sure if i did did i do that okay let's just make sure i did
46:11i think i might have skipped that accidentally so the mv command is very very useful it's a
46:17way to rename files or folders so we have this code of conduct let's say the code of conduct we don't
46:25like the name let's change it to just conduct
46:31so what we just did is we we renamed the code of conduct as that and we can also rename folders so
46:38move packages and let's call it some other name so what i just did is i changed the the folder name
46:48so move is uh very very useful and uh yeah so you can change and let's say when it we want to rename
46:56security to just security and now it has been renamed
47:06and uh so i went over sudo and then the asterisk wildcard i went over rm which is delete fold delete
47:15files or folders rmdir is just delete folders and they have to be empty history shows all the
47:21commands you've typed and now we have a lot more i have over almost 250 commands i've typed
47:28and it's very useful so history shows you the what you've typed
47:34and then cat command this again will show it'll output the it'll output a text file man will give
47:40you a manual page of a command if it has one wgit will download files unzip will unzip files
47:47this is like downloading files ping is a way to test a website or your own internet connection
47:52top is a way to get linux processes and it's like a way to monitor your computer
47:59again history okay i guess i've typed this twice history anyway as a way to get the
48:03history of your command sort is a way to sort a file unique is a way to get the unique lines touch is a
48:09way to make empty files or update the timestamp echo is a way to just print this is a way to output to a
48:21file and again i guess i've i have some things that are duplicates du allows us to get the information on
48:29files df will give us file information for example how much hard drive space we have left free is for
48:37getting information about memory find is a way to we find files very useful grep is a way to search
48:42files for specific things in the fall rename will allow us to rename files sad is a tool that allows
48:50us to edit text files in a programmatic way head will allow us to see the the first few lines of a
48:57text file tail will allow us to see the last few lines of a text file git clone is how we can
49:04get repositories especially from github and then if you have a bash file so any file that ends in dot sh or
49:13dot bash you can likely run it with the bash command okay i hope you enjoyed this video and this was
49:21around 30 very useful linux commands and i hope you enjoyed and if you like this please subscribe to
49:28or follow my channel and see you in the next one thank you

Recommended