60 Linux Commands you NEED to know (in 10 minutes)

NetworkChuck
16 Nov 202210:50

Summary

TLDRThis video script offers a rapid-fire introduction to 60 essential Linux commands, covering everything from basic navigation with 'cd' and 'ls' to advanced operations like 'ssh' for remote connections and 'systemctl' for service management. It also touches on file manipulation, user management, package installation, and network diagnostics, all within a 10-minute format designed to empower viewers with foundational Linux skills.

Takeaways

  • πŸ”’ SSH is essential for connecting to a Linux machine, requiring a user, '@' symbol, and server IP address.
  • πŸ“ The 'ls' command lists files in the current directory, with options to display hidden files and detailed listings.
  • πŸ“ 'pwd' prints the current working directory, while 'cd' changes it, including shortcuts for parent and home directories.
  • πŸ“„ 'touch' creates new files, and can even create dated files with the '-d' option.
  • ✍️ 'echo' can be used to append text to a file, while 'nano' is a popular editor for making file modifications.
  • πŸ” 'cat' quickly displays file contents, and 'shred' can securely delete files.
  • πŸ—‚οΈ 'mkdir' creates directories, 'cp' copies files, 'mv' moves them, and 'rm' removes files with options for directories and recursion.
  • πŸ”— 'ln' with the '-s' option creates symbolic links to files.
  • 🧼 'clear' cleans the terminal screen, and 'whoami' reveals the current user identity.
  • πŸ‘€ 'sudo' allows executing commands with superuser privileges, and 'su' switches the current user.
  • πŸ”„ 'apt' and 'yum' are package managers for Debian-based and Red Hat-based systems, respectively, used for updating and installing software.

Q & A

  • What is the first Linux command mentioned in the script and why is it essential?

    -The first Linux command mentioned is SSH (Secure Shell). It is essential because it allows you to connect to your Linux machine remotely, which is a fundamental requirement for using Linux, especially when you are not physically present at the machine.

  • How can you list all the files in the current working directory in Linux?

    -You can use the 'ls' command to list all the files in the current working directory. Adding the '-l' switch provides a detailed list, and adding the '-a' switch shows hidden files as well.

  • What command is used to find out the current working directory in Linux?

    -The 'pwd' (print working directory) command is used to find out the current working directory in Linux.

  • How can you create a new file in Linux?

    -The 'touch' command is the quickest and easiest way to create a new file in Linux. You simply type 'touch' followed by the name of the file you want to create.

  • What command allows you to edit a file in Linux?

    -The 'nano' command allows you to edit a file in Linux. It opens the file in a text editor where you can make changes.

  • How can you copy a file to a new location in Linux?

    -The 'cp' command is used to copy a file to a new location in Linux. You specify the source file followed by the destination path where you want the file to be copied.

  • What is the command to remove a file in Linux?

    -The 'rm' command is used to remove or delete a file in Linux. You specify the file name that you want to delete.

  • How can you create a symbolic link to a file in Linux?

    -The 'ln' command with the '-s' switch is used to create a symbolic link to a file in Linux. You specify the original file and then the name or path for the link.

  • What command is used to update the package repositories in Debian-based systems?

    -The 'apt update' command is used to update the package repositories in Debian-based systems, ensuring that you have the latest package versions available for installation.

  • How can you find out the IP address of your Linux machine?

    -You can find out the IP address of your Linux machine using the 'ip addr' or 'ip address' command followed by 'show' or 's' for a more concise output.

  • What command can you use to check the status of your firewall in Linux?

    -You can use the 'ufw status' command to check the status of your firewall in Linux. This command shows the current rules and whether the firewall is enabled or not.

Outlines

00:00

πŸ“ Essential Linux Commands Overview

This paragraph introduces the top 60 Linux commands in a fast-paced 10-minute format. It begins with SSH for remote connections, explaining the basic usage with user, '@' symbol, and server IP address. The script continues with file system navigation using 'ls', 'pwd', and 'cd' commands, including options to list files, view hidden files, and change directories. The 'touch' command is highlighted for file creation, with examples of creating multiple files and setting future timestamps. Sponsor acknowledgment is given to Tolin for providing affordable virtual machines. The video also covers file editing with 'echo', 'nano', and 'vi', viewing file contents with 'cat', and secure file deletion with 'shred'. File and directory management commands like 'mkdir', 'cp', 'mv', 'rm', and 'rmdir' are explained, along with 'ln' for creating links. The paragraph concludes with 'clear' for terminal cleanup and 'whoami' for user identification, followed by user management commands like 'adduser' and 'passwd'.

05:01

πŸ—‚οΈ File Management and System Administration

The second paragraph delves into advanced file management techniques, starting with the 'finger' command for inspecting user information, which requires installation via 'apt' or 'yum' package managers after updating repositories. The 'man' command is introduced for accessing manual pages, with shortcuts like 'whatis' and 'which' for quick command information. The paragraph covers network configuration commands such as 'ifconfig', 'ip address', and 'grep' for filtering output. DNS settings are viewed with 'cat /etc/resolv.conf' or 'systemd-resolve --status'. Network diagnostics tools like 'ping', 'traceroute', and 'netstat' are discussed, along with 'ss' for socket statistics and 'ufw' for firewall management. System information is retrieved with 'uname' and 'neofetch' for a visual representation. The paragraph also touches on calendar utilities with 'ncal', mathematical calculations with 'bc', memory checks with 'free', disk space with 'df -h', and process monitoring with 'ps aux', 'top', and 'htop'. Process management concludes the section with 'kill' and 'pkill' commands for terminating processes.

10:03

πŸ”§ System Services and Maintenance Commands

The final paragraph focuses on system services and maintenance, starting with 'systemctl' for managing services on Systemd systems and 'service' for others. Commands to stop, start, status check, and restart services are provided. The paragraph also covers command history retrieval with 'history', and system reboot and shutdown commands with 'reboot' and 'shutdown', including immediate shutdown with 'shutdown -h now'. The script wraps up by reminding viewers of the extensive range of commands covered, providing a quick recap and closure to the video.

Mindmap

Keywords

πŸ’‘SSH

SSH stands for Secure Shell, a protocol that provides a secure way to access a remote computer over a network. In the context of the video, SSH is the first command introduced as it is essential for connecting to a Linux machine. The script demonstrates how to use SSH to log into a server by specifying the user, the '@' symbol, and the server's IP address.

πŸ’‘LS

LS is a command-line utility in Linux used to list directory contents. The video mentions using 'LS' to view all files in the current working directory and describes how to use the '-l' switch for a detailed listing and '-a' to show hidden files. This command is fundamental for navigating and managing files in Linux.

πŸ’‘PWD

PWD stands for 'Print Working Directory'. It is a command used to display the current directory in which the user is working. The script explains that PWD helps users understand their current location within the file system, which is crucial for file management tasks.

πŸ’‘CD

CD is short for 'Change Directory', a command used to navigate to a different directory in the file system. The video script illustrates how to use CD to move to a specific directory, including moving to the root directory or a user's home directory, which is essential for file organization and access.

πŸ’‘Touch

The 'touch' command in Linux is used to create a new, empty file. The video script mentions using 'touch' followed by a filename to quickly create a file. It also humorously suggests creating multiple files from a sentence by using each word as a separate filename, showing the command's simplicity and utility.

πŸ’‘Echo

Echo is a command used to display a line of text on the screen or to add text to a file. In the script, 'echo' is described as a way to 'talk to oneself' or to append text to a file quickly, demonstrating its use for both user feedback and file manipulation.

πŸ’‘Nano

Nano is a simple, user-friendly text editor for Linux. The video script describes how to use 'nano' to edit a file, including how to save changes with 'Ctrl+X', 'Y', and 'Enter'. It positions 'nano' as an accessible tool for users who may not be as comfortable with more complex editors.

πŸ’‘Cat

The 'cat' command in Linux is used to concatenate and display the contents of files. The script quickly shows how to use 'cat' followed by a filename to view the contents, and humorously mentions 'shred' to illustrate the command's speed. 'Cat' is a fundamental command for file inspection.

πŸ’‘MKDIR

MKDIR stands for 'Make Directory' and is used to create a new directory in the file system. The video script explains how to use 'mkdir' to create a new directory and then copy files into it using the 'cp' command, highlighting the importance of directory management in file organization.

πŸ’‘CP

CP is a command used to copy files and directories in Linux. The script describes using 'cp' to specify a file and its destination, illustrating the command's use for duplicating files, which is essential for backup and organization.

πŸ’‘RM

RM stands for 'Remove' and is a command used to delete files or directories in Linux. The video script explains the basic use of 'rm' to delete files and the '-r' option for recursively deleting directories, which is crucial for file and directory management.

Highlights

SSH is essential for connecting to a Linux machine using the format 'user@server'.

The LS command lists files in the current directory, with options to show hidden files.

PWD command reveals the current working directory.

CD command is used to change directories, including shortcuts for parent and home directories.

Touch command quickly creates new files.

Echo command can be used for adding text to a file or for self-communication.

Nano is a user-friendly text editor in Linux.

Cat command is used for viewing file contents quickly.

Shred command securely deletes files by overwriting them.

MKDIR and CP commands are used for creating directories and copying files.

RM and RMDIR commands are used for removing files and directories.

LN command with the -s switch creates soft links to files.

Clear command cleans the terminal screen.

The WHO AM I command provides information about the current user.

AD USER and SU commands are used for user account management and switching users.

The EXIT command is used to exit various interfaces and return to the previous user.

The PASSWORD command is used to change user passwords.

Finger command can be used to inspect information about other users.

APT and YUM are package managers used for installing software on Debian and Red Hat based systems.

The MAN command provides manual pages for understanding command usage.

WGET and CURL commands are used for downloading files from the internet.

ZIP and UNZIP commands are used for file compression and decompression.

LESS command allows for page-by-page viewing of files.

HEAD and TAIL commands are used to view the beginning and end of files respectively.

CMP and DIFF commands compare files to identify differences.

SORT command sorts data in alphabetical or numerical order.

FIND command is used to locate files within the file system.

CHMOD and CHOWN commands change file permissions and ownership.

IP, IFCONFIG, and GREP commands are used for network configuration and IP address management.

PING, TRACEROUTE, and NETSTAT commands are used for network diagnostics.

UFW command simplifies firewall management on Linux systems.

The uname command provides information about the system's kernel.

NEO FETCH displays system information in a visually appealing way.

CAL command provides a quick view of the calendar.

BC command can be used for mathematical calculations in the terminal.

FREE and DF commands provide information about memory and disk space usage.

PS, TOP, and HTOP commands are used for process monitoring.

KILL and Pkill commands are used to terminate processes.

SYSTEMCTL and SERVICE commands manage system services and daemons.

HISTORY command lists previously executed commands.

REBOOT and SHUTDOWN commands are used to restart or shut down the system.

Transcripts

play00:00

Here are the top 60 Linux commands you need to know,

play00:02

and we're gonna do this in 10 minutes. Our first command can be used anywhere.

play00:05

It's SSH because you can't use Linux unless you can get to it.

play00:08

To connect to your Linux machine, you'll specify your user it,

play00:11

then the ad symbol and then the server you're gonna connect to.

play00:13

So I'll copy the IP address of my lin node that I just set up past that in here.

play00:17

Hit enter. Accept all fingerprints.

play00:18

Put your password in and or in the LS command will list all the files in your

play00:22

current working directory.

play00:23

We can add the L switch to give us a nice list and we can add the A switch to

play00:28

see the hidden stuff. Elix is a big place. Where are you with the PWD command?

play00:32

You can find out print working directory. It'll tell you where you are,

play00:35

but if you don't wanna be there, we can change that with the CD command.

play00:37

Change directory. Just after CD will tell it where you want to go.

play00:40

Maybe the root of the file system who we made it guess or we can specify a

play00:44

specific path.

play00:44

With cd.dot we can jump back one directory and with CD space nothing,

play00:49

we can click our heels and get back. Home.

play00:51

Touch is the quickest and easiest way to create a file.

play00:53

Type in touch with a file name in you got yourself a file.

play00:56

We can create more than one file.

play00:57

Every one of those words in that sentence will be its own file .

play01:01

Or we can do something weird like this or we could even create a file in the

play01:04

future by using the dash D switch and specifying the date it's created a file

play01:08

from the future. And seriously shout out Tolin for sponsoring this video.

play01:12

Whenever I need to do anything in Lennox,

play01:13

I go Tolin node and spend out the quick virtual machine to do stuff like this.

play01:16

And it only costs me 0.01 cents an hour. When I'm done,

play01:19

I destroy it and that's all I'm charged. Check it out.

play01:22

Link below the Echo command allows you to talk to yourself or we can use it to

play01:26

add stuff to a file really quickly.

play01:27

We'll specify the right arrow and then a name of a file, a new or existing file.

play01:31

But if you really want to edit a file like a Linux Pro,

play01:33

you'll use Nano Nano and then the file name. And boom,

play01:35

we're editing a file to save your file with Nano,

play01:37

you'll hit control x Y and enter to save.

play01:41

Now if you're Lennox Pro that thinks you're better than everybody else,

play01:44

you'll use them, them the file name and now you can try to edit a file.

play01:48

The best way is to hit I to start inserting text and once you're done,

play01:51

hit Escape Colon and wq to write and quit.

play01:56

Now if you wanna see what's inside a file,

play01:57

really quickly use the Cat Command Cat and then the file name super fast.

play02:01

And if you don't want anyone to ever see what's in that file, you can shred it.

play02:04

Shred the file name and cat that one. Again,

play02:08

nothing looks like a cat road.

play02:10

We can make a new directory with the M K D I R command,

play02:12

but right now he's empty, it's lonely. So let's copy something in there.

play02:15

We can copy a file of the CP command.

play02:17

We'll specify our file and then where we want it to go. If you don't wanna copy,

play02:20

you can use the MV command to move the file, Specify the file,

play02:23

you wanna move and then where you wanna put it.

play02:25

We can remove or delete a file with the RM command and we can remove a directory

play02:29

with the RM D i R command. But if it's not empty,

play02:32

we can go back to the RM command and do a dash R for recursive and try that

play02:37

done.

play02:38

We can create a link to a file with the LM command using the S switch for soft,

play02:42

we'll specify the file and then the link. Now if your terminal's a bit dirty,

play02:46

you can clean it off, type in clear. Ah, so much better Coffee break.

play02:49

If you don't know who you are,

play02:51

you can type in who am I and it'll tell you existential crisis over.

play02:54

If you don't like who you are, you can change that.

play02:56

Let's first create a new person.

play02:57

We'll use the ad user command and then the username, Oh,

play03:01

too bad we don't have permission,

play03:02

but we have pseudo or psdo specify pseudo Before your command,

play03:05

enter your pseudo password and you're good to go.

play03:08

We can also reverse the command by doing ad user instead of user ad and we'll be

play03:12

able to set some parameters like passwords and stuff.

play03:14

Now if I wanna become Nick or Austin,

play03:16

I can do that with the SU command for Switch user.

play03:19

SU specify the username and I am Austin, but I don't wanna be Austin anymore.

play03:22

I can use the exit command, type in exit back to V and Me. And by the way,

play03:26

the exit command can be used to exit at a lot of places.

play03:29

Now Nick didn't have a password but I can change that with the password command.

play03:32

P A S S W D and then the username. If you wanna change your password,

play03:36

just type in password or password.

play03:37

Type into the terminal. Pseudo password, Millie password,

play03:40

but it's so it's just password .

play03:44

Now this next command is kind of weird and you'll have to install,

play03:46

it's called Finger . It's really strange, trust me.

play03:49

But to install that we'll need to learn a new command on Debbie and Base

play03:52

Machines. We'll use a P t but hold up. Before we can install anything,

play03:55

we have to update our repositories.

play03:56

So we'll do pseudo a P t update whilst doing, That'll take a coffee break.

play04:01

If you're on Red Hat or sent to West,

play04:02

you'll use the Yum package manager and if you're on Arch or anything else,

play04:05

you're on your own. After an update,

play04:07

we'll do a pseudo a P T install and the name of our package which will be finger

play04:11

done and now we can use that command Finger can be used to inspect another user.

play04:15

So I might want to inspect Austin. It's pretty handy.

play04:19

The Man command will help you with things you don't know, which is a lot,

play04:23

at least for me.

play04:23

You find out what the finger command does by doing Man Finger .

play04:26

That sounds weird. It'll tell us all about it and how to use it.

play04:29

Hit Q to get outta there. We can man Cat, we can man, man.

play04:32

So when in doubt consult your manual.

play04:34

Now a faster man is what is type in what is Finger.

play04:37

It'll tell you real quick or maybe you wanna know where finger is,

play04:40

you can type in which finger, which will tell you one place,

play04:42

but you wanna know where all the fingers are.

play04:44

So say where is Finger W Get can help you get stuff from the

play04:49

internet. Like maybe you wanna download the entire Bible in text form.

play04:51

We can do that right now. And there it is, the entire Bible.

play04:55

Another way to download is with Curl,

play04:56

my personal favorite type in curl the URL you wanna download from and then using

play05:01

the right arrow, direct that to something else like a file Done.

play05:06

Now the Bible's kind of big, what do you say? We made that file smaller.

play05:08

We can zip it up.

play05:09

Zip the zip file you wanna create and what you wanna zip inside.

play05:12

Hey that wasn't too bad.

play05:13

Now often you might want to unzip something with the unzip command,

play05:16

specify that file name and some other options and you're good to go.

play05:20

Now if we wanna read our file we could cat it but that's crazy. Come on.

play05:24

A better way is using the less command, giving you one page at a time.

play05:27

Just the way I like it.

play05:29

If you only wanna see the beginning of your file type in head,

play05:32

what about the end type and tail?

play05:34

If you wanna compare two files to see if they are the same,

play05:36

like this guy and this guy, use these CMP command for a compare.

play05:40

Specify your two files and hey,

play05:42

we do have a difference but it didn't tell us what it only told us where for

play05:45

that we can use the diff command specify files and it will tell us exactly

play05:48

what's different. You decide what's true,

play05:50

the sort command will sort your stuff alphabetically. So for example,

play05:54

I could cat the Bible,

play05:55

do a pipe and type in sort at the end the entire Bible in alphabetical order

play05:59

ending with Zephaniah.

play06:00

The fine command is nuts and will help you well fine things type in fine.

play06:04

Specify what directory you wanna look in.

play06:06

I'm gonna look in all of them and then specify a name of a file with a regular

play06:09

express BAM files found. You can also find all hidden files,

play06:13

empty directories or all executable files. And speaking of executable,

play06:17

how do you make a file executable?

play06:18

We'll change the attributes with the CH mod command and do a plus x and then the

play06:23

file name and now it executes.

play06:24

We can change the ownership of that file with the CHONe command or change

play06:28

ownership. Specify the user and then the file. Congrats Austin,

play06:31

you own a file time for some network stuff. Copy break. What's your IP address?

play06:36

I have config. If you don't have it, install it. Let's try it again.

play06:39

If F conf fit, there it is.

play06:40

You could also try IP address which makes more sense.

play06:43

Same information just better.

play06:45

Now what if you only wanna see it for one interface?

play06:47

For that we can use GR grip is crazy. I love gr same command IP address.

play06:52

For this time I'll use a pipe type inre and say Ethan Nets zero to only see

play06:56

Ethan at zero's IP address. Bam.

play06:58

We could grip again do another pipe grip for ANet and it only shows you that

play07:02

line. But what if we only wanna see the IP address for that?

play07:05

We can use a A is even crazier than gre.

play07:08

Just after our grips I'll A this put in a crazy regular expression and get

play07:12

exactly what I want. Now what about dns? What's our dns sir?

play07:15

One way is we can cat it.

play07:17

Cat the et tc resolve with no e.com file.

play07:22

But if you're on newer versions of things like Ubuntu,

play07:24

you might see something like this not very informative.

play07:26

Instead we can type in resolve with an E CTL status and there

play07:31

it is. Now is your website up? We can find out with Ping.

play07:33

We can find out if anything's up with ping ping and then the name of the

play07:36

website. Get responses forever. Hit control C to stop.

play07:40

We can limit that with a dash C command specifying the count of things we wanna

play07:43

send just five. We can specify the size of the packets.

play07:46

If you wanna see the path through the internet you're taking to get to a

play07:49

website, you can use the trace route command, which is so cool.

play07:52

Trace route and then the name of the site telling you every haw and that

play07:57

latency. Now what ports are open on your Linux machine?

play07:59

We can check it out with netstat net Statistics, this gives you a lot.

play08:03

Do you not wanna try netstat dash two lupin, all those switches,

play08:07

which is much better. A more modern version is the SS command,

play08:10

which is basically the same thing.

play08:12

Use a topen switches and it's nice and pretty. Now what about your firewall?

play08:15

Are things getting through or do you wanna block 'em?

play08:17

If you wanna to allow pour 80, you could run something like this,

play08:20

which is honestly kind of complex. That's why U F W is way easier.

play08:23

This sits on top of IP tables and makes it so much easier.

play08:26

If I want to allow pour 80,

play08:28

just do U F W allow 80 as psdo

play08:32

done. See what you're allowing with U FW status,

play08:35

which right now it's not even enabled.

play08:37

So we can enable it with U F W enable.

play08:40

Then check our status once more. Beautiful.

play08:42

Now if you wanna know a bit more about your system, you can use the you name,

play08:45

command, you name. It'll tell you just a little bit. If you type in dash A,

play08:50

it'll tell you a lot. Now if you want a prettier version of all this,

play08:53

try Neo fetch. Going to install that real quick.

play08:56

A t install neo fetch and then simply run Neo fetch. And how pretty is that?

play09:01

The Cal command will give you a quick little calendar here.

play09:04

I don't know why you want that, but it's kind of cool. If you don't have it,

play09:06

you can install it with pseudo A P t install n cal.

play09:08

If you wanna do some math right here in your terminal,

play09:10

you can echo a problem out to bcbc will tell you what the answer is.

play09:14

If you wanna check on your memory and see how much memory you have available on

play09:17

your system, just type in free.

play09:18

It'll tell you what's used and what's going on with your swap.

play09:21

How much space do you have?

play09:22

You can use the DF command and more specifically the DF dash capital H command.

play09:27

You're gonna use that one all the time.

play09:28

What about the stuff running on your system? The processes?

play09:30

We can use the PS command,

play09:31

which won't tell you much unless you use the PS A U X switch.

play09:35

Then we can get all the goodies.

play09:36

If you wanna see the processes eating up all your stuff, type in top.

play09:39

If you wanna see that in a prettier way, type in H top , that's slick.

play09:44

If you have a process that you want to kill it,

play09:47

we can do that with the kill command first we have to find the process id.

play09:49

I'll do that with ps. I'll grip for that script I wanna kill. There it is.

play09:53

There's this process ID and I'll kill the process with the dash nine signal

play09:58

forcibly killing it. And then the process ID 66 59. Goodbye buddy. He's gone.

play10:03

Now. Even better than kill is P kill because you don't need to know the process.

play10:06

ID type in kill, use the F switch and specified the name.

play10:10

You kind of think it is and it did it to stop,

play10:12

start and restart services or Damons and Linux.

play10:14

You can use the system CTL command at your systems using System D. If not,

play10:18

it'll be using service. So to stop a service system ctl, we do Apache two.

play10:23

Replace with start. We'll start the service,

play10:25

type in status to see what's going on or do a restart.

play10:28

Now we've gone through a lot of commands.

play10:29

If you want a history of all we did type in history and that's a lot of stuff.

play10:34

And finally, if you wanna reboot pseudo reboot. If you wanna shut down,

play10:38

pseudo shut down. This will shut down your machine in about one minute.

play10:43

If you want to do it now, do a dash H now, which I'll do.

play10:47

That's the end of the video. Talk to you guys later.

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Linux CommandsSSH ConnectionFile ManagementTerminal BasicsCommand LineUser ManagementPackage ManagementNetworking ToolsSystem MonitoringScripting Tips