O GoConqr está de visual novo! Conte para nós o que você achou.

Notas

Introdução ao Linux

Rafael Rodrigues Linux Português 1 página

Conteúdo das notas (1)

Página 1

as well -> bem como, também

made up -> é constituído de

What is Linux?

Most of you are probably familiar and used to Operating Systems (OS) like Windows 10 or Mac OSX. Like Windows and Mac OSes, Linux is an operating system as well. It is an open source operating system and is used in different kinds of devices like your smartphones, tablets, home appliances, personal computers and even supercomputers.

The Linux Operating Systems (or in short called OS) is made up of the following items:

Kernel

Bootloader

Daemons

Graphical server

Desktop Environment (DE) and Applications

Command Line or Shell

attached -> associado a

lead to -> provocar

threat -> ameaça, perigo

timestamp -horário marcado

pattern - padrão, modelo

The Kernel

The kernel is the core part of the Linux OS and the kernel is sometimes just referred to as “Linux”. It helps to manage the computer processor, the memory and the attached devices like your DVD drive, USB drive, keyboard, etc. When hackers write hacker code that infects and corrupts the Linux kernel, it can lead to what is referred to as “Kernel Panic” and that is a serious threat.

To find out the name and details of a Linux operating system, you can use any of the following commands.

uname -r and uname -a

lsb_release -a

cat /etc/os-release

cat /proc/version

dmesg and grep

Let us try a few of the common Commands

In the terminal on your right, type uname or uname -s and

press enter

You should see that the Operating System is Linux.

Now try typing uname -a and press enter.

You will see something like

Linux host01 4.4.0-151-generic #178-Ubuntu SMP Tue Jun 11 08:30:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

This means that the name of the kernel is Linux

The hostname is host01

The numbers and text 4.4.0-XXX-generic mean

4 - Kernel version

4 - Major version

0 - Minor version

XXX - Bug fix

generic - This is specific to a Linux distribution (or distro). In the case of Ubuntu, generic means desktop for the desktop version and server for the server version.

The next text #178-Ubuntu means that this version of Linux kernel was compiled 178.

The text SMP Tue Jun 11 08:30:22 UTC 2019 is the latest

timestamp when the kernel was compiled.

The next three numbers, all of which in this case is x86_64 represent

the Machine architecture,

the Processor architecture, and

the Operating system architecture

Finally the GNU/Linux means that the Operating System is Linux OS.

You can also type lsb_release -a and press enter.

You should see something like

Distributor ID: Ubuntu Description: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial

LSB stands for Linux Standard Base and executing this command will give you more OS specific information such as the Distributor, Description the Release number and the codename that is used to refer to this version of the Linux OS.

You can also use the following cat commands to find out information about the Linux kernel.

The cat command stands for Concatenate (read) files and print to standard output (display on the screen)

cat /etc/os-release

cat /proc/version

The last way that we will learn to find to find out kernel information is by using 2 familiar Linux commands - dmesg and grep.

dmesg is a command used to examine and display messages from the kernel and the

grep command searches and prints the lines matching a pattern.

By combining these two commands we can we can print the kernel messages using dmesg and grep to find the pattern "Linux" in the messages.

Try typing dmesg | grep 'Linux' and press enter.

You should see some information about the Linux kernel.

splash screen -> tela de início

is part of -> é parte, faz parte de

portion -> parte

lightweight -> leve

notice -> perceba que

Bootloader

The Bootloader is what makes the computer start (or boot) up. You may be used to seeing a splash screen show with a message like “Your computer is starting up”. When this splash screen is shown, the bootloader part of the OS is running in the background, making your computer ready for your use. The bootloader is part of the Master Boot Record (MBR) portion of the OS. What the bootloader does is - it loads the Operating System into computer memory.

Common Linux bootloaders include:

GRUB (GRand Unified Bootloader)

LILO (Linux Loader)

Syslinux which is really a mix of many lightweight bootloaders that makes it possible for you to boot from different sources, such as optical disks like CDs, DVDs, USBs or from a network.

To find out what bootloader, you Linux OS uses, you can use the file -s command. But before you can find out the bootloader, we must first find out what the bootdisk is. The boot disk has the Master Boot Record (MBR)

To find of the bootdisk, you will need to use the fdisk -l command

Type fdisk -l and press enter

You should see something like

Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 94160895 94158848 44.9G 83 Linux /dev/vda2 94162942 102397951 8235010 3.9G 5 Extended /dev/vda5 94162944 102397951 8235008 3.9G 82 Linux swap / Solaris

The one with the asterisk (*) is the bootdisk. In the example above, it is /dev/vda1

Now type file -s /dev/vda1 and press enter. The -s option stands for special files and the bootloader is a special file in the Linux OS. This command will give you information as to what bootloader is. In this case, you may see something like /dev/vda1: Linux rev 1.0 ext4 filesystem data, UUID=50300c45-9dcd-483c-acea-2f376f7acd95 (needs journal recovery) (extents) (large files) (huge files) which does not explicit state the name of the bootloader.

So what we can do is use the dmesg and grep command and search for the word BOOT

Type dmesg | grep BOOT_IMAGE and enter. This will search for the word BOOT in the kernel messages and output the BOOT_IMAGE details.

When you run the dmesg command

You should see something like

[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-151-generic root=UUID=50300c45-9dcd-483c-acea-2f376f7acd95 ro quiet [ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-151-generic root=UUID=50300c45-9dcd-483c-acea-2f376f7acd95 ro quiet

Notice in the Kernel command line, you see the words BOOT_IMAGE=/boot/vmlinuz-4.4.0-151-generic

The Linux Loader (LILO) always passes the word BOOT_IMAGE=[KernelName] to the kernel, where [KernelName] is the name by kernel.

From this you can determine the the bootloader used here is LILO.

From a hacker perspective, it is important to recognize that Bootloader computer viruses corrupt the bootloader part of the OS making it impossible for the computer to start, causing a denial of service or DoS attack.

thought -> pensado, imaginado

parent> principal

Daemons

Pronounced “Day-mens”, this part of the OS is another name for processes that run in the background. For example, when you login or when you send a print command, the login or printing service is run as a daemon.

In Linux, we can see the list of processes that are running by using the ps -ef command. Each process has a unique identifier called PID which standards for Process IDentifier.

One of the most important processes in Linux is the init process, which can be thought of as the grandfather of all processes, because every other process that runs, except the kernel, is a child of this init process and can be traced back to init. The kernel itself runs in PID 0 while the init process has a PID of 1.

Technically, a daemon is a parent process that is started when the Operating System boots is initialized and boots up. So daemons are configured to run from /etc/initd where initd stands for initial daemons. This means that they usually have a PPID (Parent Process IDentifier) of 1. So we can look for all processes and search for the pattern where the PPID is equal to 1 to find daemons.

Type ps -ef | awk '$3 == 1' and enter.

When you run the ps -ef command, you see that all processes are standard output to your display as shown below. The 2nd column shows the Process ID (PID) and the 3rd Column shows the Parent PID. So the awk command here takes the 3rd column (denoted by $3) and checks to see if the PPID is equal (==) 1, which is the PPID for daemons.

root 285 1 0 20:39 ? 00:00:00 /lib/systemd/systemd-udevd root 749 1 0 20:39 ? 00:00:00 /usr/lib/accountsservice/accounts-daemon root 766 1 0 20:39 ? 00:00:00 /usr/sbin/cron -f root 768 1 0 20:39 ? 00:00:00 /lib/systemd/systemd-logind syslog 777 1 0 20:39 ? 00:00:00 /usr/sbin/rsyslogd -n root 908 1 0 20:39 ? 00:00:02 /usr/bin/containerd root 959 1 0 20:39 ? 00:00:01 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 960 1 0 20:39 ? 00:00:00 /usr/sbin/sshd -D root 4599 1 0 22:30 ? 00:00:00 /lib/systemd/systemd --user

Graphical Server

When Linux OS was introduced, it was mostly a command line driven OS, which is why it was not as widely adopted as other Graphical OS such as Windows or Mac OSX. However, nowadays, most Linux OSes come with a graphical server that is known as an X server or simply X. The X server makes it possible to display graphics on your monitor.

In this environment, we do not have X server installed, but if you installed a full version of a Linux OS, you are likely to be presented with a login screen and a graphical user interface that you can click on and interact with the OS. In some Linux distributions, you may be required to start the graphical server by using the startx command.

built-in -> integrado, no contexto, que já vem instalado.

Desktop Environment (DE) and Applications

The desktop environment (DE) component of the Linux OS is what you as the user of the Linux OS can interact with using the built-in or installed applications like file managers for managing files, or web browser for surfing the Internet. There are many desktop environments to choose from based on your preference. Some well known Linux Desktop Environment are GNOME, KDE, LKDE and MATE Desktop.

In this environment, we do not have a Desktop Environment installed, but if you installed a full version of a Linux OS, you are likely to be presented with a desktop with icons and applications that you can click on and start. Some examples of applications that are installed are office applications, word processing software, email applications and games like Minecraft, Solitaire and Chess.

driven -> conduzidos

in short -> resumidamente

along with -> junto

Command Line (or) Shell

The Linux command line or Shell is an OS process that allows you to control the computer by using commands that you type in as text interface. With modern Desktop Environments, the need for using the Shell is not as needed. However most hacking tools are command line driven and if you want to learn hacking, it is very important that you become very familiar with how to use the linux command line and the basic and advance Linux commands.

Type date and press enter.

You should see the date and time stamp printed on the screen.

What you did was you interacted with the shell as you have been doing so for most of this course.

In the Linux Commands scenarios you will be introduced to many of the Linux commands you need to know.

The Linux OS along with the Desktop Environment, and Applications can be customized according to your preference and are known as Linux distributions are simply in short “distros”.

way -> maneira, forma

unethical -> antiético

Why Linux?

The OS of choice for most hackers is Linux. This is because hackers like to do things their way and because the Linux OS is open source, it can be customized to whatever applications (or hacker tools) that they would like to hack. Also, unethical and bad hackers use many tools that they develop or is available in Linux to hack into other weak and vulnerable networks and software applications. Many Linux distros already have the necessary hacker tools readily available to use in them. If a hacker application does not exist, then it can be easily installed on the Linux OS and distributed.

Some very well known hacking Linux distros are:

Kali Linux based on the Debian flavor of Linux OS

BackBox based on Ubuntu flavor of Linux OS

Parrot Security OS based on the Debian flavor of Linux OS

CAINE which stands for Computer Aided INvestigative Environment which is used for Digital Forensics and

Samurai Web Testing Framework for penetration testing web applications.

So if you want to learn hacking as a hobbyist, or for ethical hacking purposes, it is important that you learn and master Linux.

Categories of Linux Commands

Categories / Types of Linux Commands

There are various types of Linux commands as listed below.

Directory Commands

File Commands

Copy or Transfer Commands

Find Commands

Compression Commands

User Commands

Group Commands

Utilities Commands

Software Commands

Shell or Terminal commands

Program or Process commands

Network Commands

Environment Commands

Security / File Permission Commands

Help Command

CaSe SeNsItIvE Commands

Linux Commands are CaSe SeNsItIvE

The first thing to know is that Linux commands are CaSe SeNsItIvE - meaning that if you type the commands in the wrong case (uppercase or lowercase or mixed-case), the command will not work and you will most likely get a “command not found” message on the terminal.

Type in date and press enter.

You should see the date and timestamp displayed on your terminal screen.

Now type in Date (with an uppercase Date) and press enter.

You will be notified that there is no command called Date and that the Date command is not found.

You may also be suggested other commands that Linux would recognize as shown below.

No command 'Date' found, did you mean: Command 'date' from package 'coreutils' (main) Command 'yate' from package 'yate' (universe) Command 'late' from package 'late' (universe) Command 'kate' from package 'kate' (universe) Date: command not found

This proves that Linux is CaSe SeNsItIvE!

Cheatsheet > folha de notas

has been -> foi

wreaked -> causado

havoc -> dano, caos

It has -> tem

compressed -> compactados

Start

Here you will learn about some common Linux Commands.

The commands you learn in this module are not all the commands that Linux users or hackers use but some of the most common ones. It is important for you to practice this commands as many times as necessary, until you are very familiar with them.

In this training session, we will introduce this commands using a scenario of superheroes & villains.

The scenario is as follows:

The EndGame virus has wreaked some havoc in your Linux computer system. It has hidden some files and created some duplicates of the real original files. It has also removed some folders that we need to recreate and extract some files that have been compressed.

Are you ready for learning?

Don’t worry, we will help you through this exercise, step by step.

start out -> começa

pwd (Print Working Directory)

pwd stands for Print Working Directory.

Some examples of directories in the Linux OS are /root, /boot, /bin, /opt, /run, /usr and /home.

The pwd command tells you the current folder where you are.

The default directory that you start out with is the home directory of the user who is logged in.

If you are the root user, your first directory would be /.

If you are a user named duke, then your home directory would be /home/duke

Type pwd and press enter.

You will find that you are in the / directory as shown below. Note:The hostname (The value after the word root@ may be different than what is shown below.) root@1d57118366ce:/# pwd /

requested -> solicitado

ls (List Directory Contents)

ls stands for list directory contents.

The ls command displays the names of files contained within a directory, as well as any requested, associated information.

Type ls and hit enter.

You should see several directories. One directory that is of interest that we will use for our learning is the cybershaolin directory.

root@2c76ac044cd9:/# ls bin cybershaolin etc lib media opt root sbin sys usr boot dev home lib64 mnt proc run srv tmp var

that there are -> que há

related -> relacionados

tape archive -> arquivo de fita

previous -> anterior

cd (Change Directory)

cd stands for Change Directory.

Type cd cybershaolin and press enter.

What you just did was you changed your directory to the cybershaolin directory.

You can check by typing pwd and pressing enter.

You will now be in the /cybershaolin directory.

Now type ls and press enter. You will see that there are some files related to superheroes comic companies (e.g., dc and marvel) as well as a villains file that is compressed as a tape archive (.tar file) as shown below.

root@2c76ac044cd9:/cybershaolin# ls superheroes_dc1.txt superheroes_dc2.txt superheroes_dc3.txt superheroes_marvel.txt villains.tar

cd and ../(DotDotSlash))

In order to go to the previous folder, you can use the shortform ../ (DotDotSlash) along with the cd command.

Since you are in the cybershaolin directory now, you can go to the previous directory using the cd ../ command.

bottom -> inferior

It may seem -> Parece que

would have been -> teria sido

mkdir (Make Directory)

mkdir stands for Make Directory.

It is used to create a folder or directory so that you can be organized.

You can think of directories like a bookshelf. In the top shelf you may have your school books, the middle shelf may have some fiction books and the bottom shelf may contain some activity books. So also in a computer system, you can organize your files in directories.

You notice that there are some files in there, but no folders (or directories) to organize them. So let us create two directories to organize these files. The two directories you are going to create are a directory called dc and another one called marvel.

Type mkdir dc and press enter.

What happened? It may seem like nothing happened if your command ran successfully.

To see if your directory was created successfully, you can use the ls command which will list all the contents of the current directory where you are.

Type ls and press enter.

You should see aa directory/folder called dc.

Now type mkdir marvel and press enter.

And is &&

NOTE: You could have also created both the directories in a single command using the && operand. The command in that case would have been mkdir dc && mkdir marvel.

find out -> desbovrir

misspelled -> com erros ortográficos

diff (Difference)

diff or diff3 stands for Difference.

The diff command compares two files line by line. The diff3 command compares three files line by line.

Type ls and press enter.

You see that there are the a few text (.txt) files and the folders that you created.

We need to move the files into the respective directories, meaning the superheroes_dc file need to be moved into the dc folder and the superheroes_marvel file need to be moved into the marvel folder.

But wait, there are three superheroes_dc text files. So which of these files is the correct file that we need to move into the dc directory.

One way we can find out about each of these files is look into the files using the cat command, but that would take time. So we can use the diff or diff3 command.

Type diff3 superheroes_dc1.txt superheroes_dc2.txt superheroes_dc3.txt and press enter.

You will see the contents of the three files that are different from each other line by line.

The first file has the word 'Flash' misspelled as 'F|ash' (note the second letter is a pipe character and not a lowercase 'L').

The third files has the word 'Batmans' and not 'Batman'.

The second file is the only file that has the names of the DC superheroes, correctly spelled.

So we will move the superheroes_dc2.txt into the dc folder and the superheroes_marvel.txt into the marvel folder, but first let us remove the two incorrect files.

https://www.katacoda.com/cybershaolin/courses/intro-to-linux

Informações

Descrição
Linux Notas sobre Introdução ao Linux, criado por Rafael Rodrigues em 02-04-2020.
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?