Latest / CyberCode Academy / Course 16 - Red Team Ethical Hacking Beginner Course | Episode 2: Essential Command Line Administration: Linux, Windows, Account Management
Transcript
- 0:00Speaker 1: If you're building software or securing networks, you probably spend
- 0:04Speaker 1: most of your time in the talk bit, the nice
- 0:06Speaker 1: graphical interface. But today we're heading straight for the flight
- 0:10Speaker 1: control panel. We're doing a deep dive into the cadline,
- 0:13Speaker 1: the true power center of any operating system.
- 0:16Speaker 2: I like that analogy. Think of it this way. The
- 0:19Speaker 2: GUI is cruising altitude, but the command line that's the
- 0:24Speaker 2: engine room of the starship. What we're doing here is
- 0:27Speaker 2: giving you a curated guide to the tradecraft the foundational
- 0:30Speaker 2: commands you'll see across both Linux and of course Windows.
- 0:33Speaker 1: And our mission is super practical. We're doing a side
- 0:36Speaker 1: by side look at the key tools you need to
- 0:38Speaker 1: navigate systems, check on network health, and manage users. This
- 0:42Speaker 1: is such a crucial skill set for anyone really serious
- 0:45Speaker 1: about system administration or say penetration test.
- 0:48Speaker 2: Absolutely, let's just jump right into the console.
- 0:50Speaker 1: Okay, so let's start with some foundational stuff. When you
- 0:53Speaker 1: first open a terminal, it's just a blank slate. How
- 0:56Speaker 1: do you even discover what's available, especially on a new Linux.
- 0:59Speaker 2: Box, right, and that discovery method is I think the
- 1:02Speaker 2: first piece of tradecraft you need in a Linux shell.
- 1:06Speaker 2: Just type a single letter let's say A, and then
- 1:09Speaker 2: hit the tab key a couple of times really fast.
- 1:12Speaker 2: The shell will just show you every single command it
- 1:14Speaker 2: knows that starts with that letter. It's a fantastic shortcut
- 1:17Speaker 2: for just teaching yourself what's on a new system.
- 1:20Speaker 1: That beats scrolling through endless documentation for sure. And speaking
- 1:23Speaker 1: of clutter, once you've run a few commands, the screen
- 1:27Speaker 1: gets messy. You need a reset button.
- 1:29Speaker 2: Yeah, And in Linux that's the simple but very necessary
- 1:33Speaker 2: command clear, and it's Windows equivalent that would be CLS
- 1:38Speaker 2: for clear screen.
- 1:39Speaker 1: Simple enough. Now for navigation, they both share a CD
- 1:42Speaker 1: change directory, but seeing what's inside a directory is different.
- 1:45Speaker 1: In Linux, it's the l's command exactly.
- 1:48Speaker 2: So if we want to create a little sandbox to
- 1:49Speaker 2: work in, we can use them kdare test, you know,
- 1:51Speaker 2: make a directory and then running l's just confirms yep,
- 1:54Speaker 2: it's there.
- 1:55Speaker 1: And that takes us to actually creating a file.
- 1:57Speaker 2: Yea.
- 1:57Speaker 1: If we want to drop a file in there, how
- 1:59Speaker 1: do we do that quickly?
- 2:00Speaker 2: The echo command is great for this, and it works
- 2:02Speaker 2: on both Linux and Windows.
- 2:04Speaker 1: So something like Echohello test dot txt perfect.
- 2:08Speaker 2: That command takes the text hello and just pushes it
- 2:11Speaker 2: right into a brand new file called test dot txt.
- 2:14Speaker 1: It's so fast, okay, And to check that it worked,
- 2:17Speaker 1: to see what's inside.
- 2:18Speaker 2: Here's where they split again. In Linux you use cat
- 2:21Speaker 2: tests dot txt rite cat, and in Windows it's type
- 2:24Speaker 2: test dot txt. Both will just split the word hello
- 2:27Speaker 2: rite back out at you.
- 2:28Speaker 1: But the real power of listing files comes with adding parameters,
- 2:31Speaker 1: doesn't it. I mean as simple, l's as fine, but
- 2:33Speaker 1: we need details.
- 2:34Speaker 2: We absolutely do for security. For permissions, you need more.
- 2:38Speaker 2: In Linux, the gold standard is ls.
- 2:41Speaker 1: LA Okay, L and DASH What do those do?
- 2:44Speaker 2: The ls gives you the long listing that immediately shows
- 2:47Speaker 2: you file permissions, the owner, the group size, date, everything.
- 2:50Speaker 2: For anyone in security seeing those permissions who can read, write,
- 2:54Speaker 2: or execute a file is probably one of the most
- 2:57Speaker 2: vital pieces of information.
- 2:58Speaker 1: And if you have a bunch of nested folders, you
- 3:00Speaker 1: don't want the CD into every single.
- 3:01Speaker 2: One, No, you'd be there all day. You just use
- 3:04Speaker 2: the recursive list LSR that shows you everything inside all
- 3:08Speaker 2: the subdirectories at once.
- 3:09Speaker 1: Okay. So if we had to pick one single skill,
- 3:13Speaker 1: the most critical foundational skill of the command line, what
- 3:16Speaker 1: would it be?
- 3:17Speaker 2: It's knowing how to ask for help, you will never
- 3:22Speaker 2: ever memorize every parameter for every command.
- 3:25Speaker 1: I completely agree. So in Linux, what are our lifelines.
- 3:29Speaker 2: You've got two main ones. The quickest is just adding
- 3:31Speaker 2: help to the end of most commands, like l's help.
- 3:34Speaker 2: It gives you a nice concise list of options.
- 3:37Speaker 1: And for the really deep dive.
- 3:38Speaker 2: For that you use man the manual. So Mandels brings
- 3:41Speaker 2: up the complete, scrollable manual page that explains every single
- 3:45Speaker 2: nuance of the tool.
- 3:46Speaker 1: And the Windows way is a little different, but just
- 3:48Speaker 1: as vital. Instead of hyphens, it's all about the forward
- 3:50Speaker 1: slash and question mark.
- 3:52Speaker 2: Right, you type ping and bam, all the parameters for
- 3:55Speaker 2: the ping command are right there. Knowing these three help
- 3:58Speaker 2: man is the key to learning without every leaving the terminal.
- 4:01Speaker 1: It really does turn the operating system into its own library. Okay,
- 4:05Speaker 1: so we know how to move around and get help.
- 4:08Speaker 1: The next logical step is figuring out how the system
- 4:10Speaker 1: is talking to the world. Let's get into network diagnostics.
- 4:14Speaker 2: Step zero in any network troubleshooting is understanding your own identity.
- 4:20Speaker 2: In Linux, the traditional command was if config.
- 4:23Speaker 1: Right, but I hear there's a newer one.
- 4:25Speaker 2: There is. Yeah, the more modern alternative you'll see a
- 4:28Speaker 2: lot now is.
- 4:28Speaker 1: Ip canfig and for Windows the go to is ip
- 4:31Speaker 1: canfig all. And I think we have to stress the
- 4:34Speaker 1: all part. Just ip canfig gives you the basics, but
- 4:36Speaker 1: adding all gives you the critical details. MS address, DHDP info,
- 4:41Speaker 1: DNS servers, that's where the good stuff.
- 4:43Speaker 2: Is, that's where the power is exactly. So once you
- 4:45Speaker 2: know who you are, you test connectivity, and the fundamental
- 4:48Speaker 2: tool is ping.
- 4:49Speaker 1: The ultimate health check being pinging yourself right the loop back.
- 4:52Speaker 2: One T seven twenty seven point zero point one. If
- 4:55Speaker 2: you can't talk to yourself, you've got some serious internal
- 4:58Speaker 2: problems to solve first.
- 4:59Speaker 1: And you don't always want to send the default what
- 5:01Speaker 1: four or five packets? You could be more precise.
- 5:03Speaker 2: Yeah, you can specify exactly how many. In Windows, it's
- 5:06Speaker 2: ping nash N two that'll send us two requests, very clean.
- 5:11Speaker 1: So what if you're troubleshooting a website, you need to
- 5:14Speaker 1: know if the name is even resolving to an IP address.
- 5:17Speaker 2: That's where you use n slock up. Running say enslip
- 5:20Speaker 2: upfun dot com will show you the IP address it
- 5:22Speaker 2: resolves to, and just as important, which DNS server gave
- 5:26Speaker 2: you that answer?
- 5:26Speaker 1: Okay, beyond just can I connect, We need the map
- 5:30Speaker 1: how does the traffic actually flow?
- 5:32Speaker 2: The routing table In Linux you can query that with
- 5:35Speaker 2: IPR or the older netstat r N. The Windows command
- 5:39Speaker 2: you'll want is route print And.
- 5:40Speaker 1: When you look that route print output, you see those
- 5:42Speaker 1: key columns network destination, gateway interface, and the metric.
- 5:48Speaker 2: The metric is fascinating. It's basically a number that helps
- 5:51Speaker 2: the os make traffic decisions. If your computer has two
- 5:54Speaker 2: different ways to get to the same destination, it's going
- 5:56Speaker 2: to pick the path with the lower metric value. It's
- 5:58Speaker 2: like the traffic cop inside your computer, always looking for
- 6:01Speaker 2: the most efficient route.
- 6:02Speaker 1: We also need to see what's happening right now, what
- 6:03Speaker 1: services are listening for connections.
- 6:05Speaker 2: Netstat is essential for this, specifically netstat n O in Windows.
- 6:10Speaker 1: Why those three parameters, A, N, and OH.
- 6:13Speaker 2: They're all vital as shows all connections and shows the
- 6:16Speaker 2: numerical addresses instead of trying to resolve names. And the
- 6:19Speaker 2: really crucial one is oh. It gives you the process ID,
- 6:22Speaker 2: the pid UH and that's the link that is the
- 6:25Speaker 2: key link. That little number lets an analyst immediately map
- 6:28Speaker 2: a suspicious open port back to the exact program the
- 6:32Speaker 2: exact executable that's running it. That's how you trace weird
- 6:36Speaker 2: activity back to its source.
- 6:37Speaker 1: And what about seeing who's on the local network with
- 6:39Speaker 1: you your neighbors.
- 6:40Speaker 2: For that, you look at the AIRP Cash Address Resolution Protocol.
- 6:44Speaker 2: Running ARPA shows you that table of IP addresses map
- 6:47Speaker 2: to physical and map addresses. If you see an IP
- 6:51Speaker 2: in there, you know that machine is active in communicating nearby.
- 6:54Speaker 2: It's a quick way to map your digital neighborhood.
- 6:56Speaker 1: To wrap up networking, let's talk about a couple of
- 6:58Speaker 1: quick troubleshooting utility. If a network interface gets stuck in Linux, you.
- 7:02Speaker 2: Can just manually cycle it. If config's zero down, and
- 7:05Speaker 2: then if configure esero up, well, quick reset.
- 7:08Speaker 1: And Windows has a really cool kind of hidden gem
- 7:11Speaker 1: for error codes.
- 7:12Speaker 2: Oh, this one is so useful. If you get some
- 7:14Speaker 2: cryptic numbered error, don't even bother googling it at first.
- 7:18Speaker 2: Just use the command net help message and then the
- 7:20Speaker 2: error number. For example, net help message fifty three immediately
- 7:24Speaker 2: tells you the network path was not found. It saves
- 7:28Speaker 2: so much time when you're under pressure.
- 7:29Speaker 1: That's a perfect example of using the system's own documentation. Okay,
- 7:34Speaker 1: let's pivot to what is probably the most powerful and
- 7:37Speaker 1: definitely the most security sensitive area of all this, managing
- 7:41Speaker 1: user accounts and domain assets.
- 7:43Speaker 2: Right, and this is where permissions are everything. Before we
- 7:45Speaker 2: even touch the net command suite, we have to stress
- 7:48Speaker 2: if you're managing accounts on a corporate domain, you almost
- 7:52Speaker 2: certainly need to be a domain admin. If you're not,
- 7:54Speaker 2: these commands are just going to fail.
- 7:56Speaker 1: So step one is confirming who you are. We use
- 7:59Speaker 1: WAMI to see our usernames, say Peter dot Pan.
- 8:03Speaker 2: Then what then you verify your status on the domain.
- 8:06Speaker 2: You run net Userpeter dot pan domain. That queries the
- 8:09Speaker 2: main domain controller to get all the details about that
- 8:12Speaker 2: user account.
- 8:12Speaker 1: Okay, identity confirmed. Now we start mapping the environment. How
- 8:16Speaker 1: do we see all the security groups that control everything.
- 8:18Speaker 2: We use net group domain and that domain switch is crucial.
- 8:22Speaker 2: Without it, you're just seeing local groups on your machine.
- 8:25Speaker 2: With it, you see the important ones like domain admins
- 8:28Speaker 2: and domain users.
- 8:29Speaker 1: And to see the full list of employees every user account.
- 8:32Speaker 2: Simple enough, net user's domain. But that just gives you
- 8:35Speaker 2: a long list. It doesn't tell you who's actually powerful, right,
- 8:38Speaker 2: So how do we drill down on that to see
- 8:40Speaker 2: exactly who has the keys to the kingdom. You run
- 8:43Speaker 2: net group domain admin's domain that lists the specific members
- 8:47Speaker 2: of that group. It's a key step in any security audit.
- 8:50Speaker 1: Okay, now for the big one modification. This is why
- 8:54Speaker 1: the command line is so potent. Let's say we need
- 8:56Speaker 1: to upgrade a standard user Alex Johnson to a domain admin.
- 9:01Speaker 1: How fast can that happen?
- 9:02Speaker 2: Instantly? The command is netgroup domain admin's Alex dot Jason
- 9:06Speaker 2: ad domain. You hit enter and that change is made
- 9:09Speaker 2: on the domain controller. It's done. This is a concept
- 9:12Speaker 2: that everyone in cybersecurity needs to understand. Privileged escalation can
- 9:16Speaker 2: be a single line of text with massive sweething implications.
- 9:20Speaker 1: Here, just as easily, we have to know how to
- 9:22Speaker 1: clean it up. If you forget the command.
- 9:24Speaker 2: You use your help skill dot netgroup dot will remind
- 9:26Speaker 2: you about the delete parameter.
- 9:28Speaker 1: So the cleanup is just as simple, just as simple.
- 9:30Speaker 2: Netgroup domain admin's alex dot json delete domain access granted,
- 9:35Speaker 2: access revoked all in seconds.
- 9:38Speaker 1: Account management isn't just about permissions, though, It's also about
- 9:41Speaker 1: you know, activity. What if we find an inactive user account,
- 9:45Speaker 1: say Edward scissorhands.
- 9:47Speaker 2: A standard admin task right, you check his status with
- 9:50Speaker 2: net user Edward dot scissorhands domain. You see the account
- 9:54Speaker 2: is inactive. To reactivate it, the command is net user
- 9:57Speaker 2: Edward dot scissorhandsactive dot yes domain. You run that, confirm
- 10:01Speaker 2: the change and he can log right back in.
- 10:03Speaker 1: Now. Before we wrap, it's worth noting the net command
- 10:05Speaker 1: Suite is classic, but it's not the only game in
- 10:07Speaker 1: town for Windows, is it?
- 10:08Speaker 2: That's right? More and more administrators are using w MIIC,
- 10:11Speaker 2: the Windows Management Instrumentation command Line. For quick list, you
- 10:15Speaker 2: can run things like romek, groupless brief or remop user
- 10:18Speaker 2: account less brief. It often gives you output that's much
- 10:21Speaker 2: easier to use in scripts.
- 10:22Speaker 1: This has been a whirlwind tour from just clearing the
- 10:25Speaker 1: screen to managing the most sensitive accounts on a network.
- 10:28Speaker 1: The command line really is an administrator's toolbox.
- 10:31Speaker 2: It is, and every command we covered is foundational. But
- 10:34Speaker 2: I have to say it again, the single most powerful
- 10:37Speaker 2: tool you have is knowing how to use the help
- 10:40Speaker 2: features man help press and that amazing net help message utility.
- 10:46Speaker 2: Those tools empower you to solve ninety percent of your
- 10:49Speaker 2: problems without ever looking away from the terminal.
- 10:51Speaker 1: They turn the system itself into your guide.
- 10:53Speaker 2: Exactly so to leave you with a thought to explore
- 10:55Speaker 2: on your own. We look to older commands like if,
- 10:58Speaker 2: canfig and newer ones like it the a we talked
- 11:00Speaker 2: about net user versus the more script friendly zibbi make.
- 11:04Speaker 2: So here's the question. If you are writing a big
- 11:07Speaker 2: automated script to manage hundreds of systems, why might you
- 11:10Speaker 2: deliberately choose to use a newer command set like IPAA
- 11:13Speaker 2: or REO make instead of the older, simpler versions. Think
- 11:16Speaker 2: about consistency and how the format of the data they
- 11:19Speaker 2: return might make your life easier.
- 11:22Speaker 1: Something to definitely mole over as you start building out
- 11:24Speaker 1: those scripts. Until next time, stay curious and keep learning