Coursera上Learning Linux for LFCA Certification专项课程01:Linux Fundamentals 学习笔记

Linux Fundamentals

Course Certificate
在这里插入图片描述

本文是 Linux Fundamentals 这门课的学习笔记,如有侵权,请联系删除。
在这里插入图片描述

文章目录

  • Linux Fundamentals
  • Week 01: Linux Operating System
      • Learning Objectives
    • Specialization Overview
    • History of Linux
    • Quiz: History of Linux Practice
    • Linux Licensing Model
    • Quiz: Linux Licensing Model Practice
    • Linux Distributions
    • Quiz: Linux Distributions Practice
    • Linux Command Line
    • Quiz: Linux Command Line Practice
    • Week 1 Lab
    • Module Graded Quiz
  • Week 02: Linux Services
      • Learning Objectives
    • Servers vs Desktops
    • Quiz: Servers vs Desktops Practice
    • Web Servers
    • Quiz: Web Servers Practice
    • Database Servers
    • Quiz: Database Servers Practice
    • Managing Services
    • Quiz: Managing Services Practice
    • Week 2 Lab
  • Week 03: View, Create, Copy, Move and Remove Files
      • Learning Objectives
    • Handle Files and Directories
    • Quiz: Handle Files and Directories Practice
    • Files and Directory Links
    • Quiz: Files and Directory Links Practice
    • Reading Files
    • Quiz: Reading Files Practice
    • Find and Compare Files
    • Quiz: Find and Compare Files Practice
    • Week 3 Lab
    • Quiz: Module 3
  • Week 04: Search and Analyze Text
      • Learning Objectives
      • Examples
    • Quiz: Filter Text Files Practice
    • Redirect Standard In, Out and Error
    • Quiz: Redirect Standard In, Out and Error Practice
    • Pipe & Filter
    • Quiz: Pipe & Filter Practice
    • Editing Text Files
    • Quiz: Editing Text Files Practice
    • Week 4 Lab
    • Quiz: Module 4
  • 后记

在英语中,符号 & 通常称为 “ampersand”(音标:/ˈæmpərsænd/)。

Week 01: Linux Operating System

Welcome to Linux Operating System, the first course of the Linux Fundamentals specialization. By enrolling in this course, you are taking the first step to kick start your career in information technology. In the first week of the course, we will learn about the history of the Linux operating system, its unique licensing model and the major distributions that are available to use. By the end of this module, you will know how to choose a distribution, install it and login to the command line. So, let us get started!

Learning Objectives


  • Describe the history of the Linux Operating System
  • Define the Linux licensing model and its effect on the success of the operating system
  • Describe Major Linux Distributions
  • Login to a Linux Command Line

Specialization Overview

Welcome to the Linux
Foundation Specialization. In this specialization
are four courses that cover the foundations of
Linux administration. Upon completion of
this specialization, I want you to be able
to do several things. You should be able to
view, create, copy, move, and remove files from
your Linux system, you should be able to search and analyze text in Linux system, you should be able
to configure network connections users and groups, you should be able to manage
disks and software packages, you should be able to
secure that Linux system. We’ll talk about both
securing it internally, the permissions, authentication
and authorization, but also perimeter security, and you should be able
to compare and contrast cloud computing models,
virtualization and containers. These are buzzwords we hear a lot of today that use Linux, but I want you to
really be able to understand them and
think about which is the right solution for the problem you’re
trying to solve.

在这里插入图片描述

In this specialization, the first course is
Linux fundamentals, the second course is
managing Linux systems, we’ll then follow up with
securing Linux systems, and then we’ll conclude with Linux Cloud and DevOps
in the fourth course.

在这里插入图片描述

There are two other courses that are not part of this
specialization but are bundled together in what we call the Professional
Certificate for LFCA, Linux Foundation
Certified IT Associate. That’s a professional
certification out there, and you can take an exam that
will test your knowledge of fundamental IT concepts,
including operating system, software application
installation management, hardware installation, use of the command line
and basic programming, basic networking functions,
security best practices and other related topics to validate your capability and preparedness for an entry level IT position. I have a link here, so you can get to more
information about certification. But there’s two courses combined with this specialization, one is a practice
where we’ll have more lab opportunities
to practice the things you should know
for this certification. Lastly is an exam prep, where we’ll have some
sample tests and we’ll talk about the exam
in that course. I hope you enjoy specialization and learn a lot. See
you in the courses.

History of Linux

Welcome to Linux Fundamentals. Linux Fundamentals
is the first course in the Linux Foundation
Specialization. The first module here
we’re going to think about the Linux
operating system. By the time we’re done
with this first module is many things I want
you to be able to do. What I mean by things I want you to be able do, you
should be able to do them, but you should
also be able to be assessed on them in
the quizzes and tests. You should be able to list
several Linux distributions, you should be able to
describe Linux services, you should be able to
view, create, copy, move, and remove files on
the Linux file system. Lastly, you should be able
to search and analyze text. In this first lesson,
we’re going to think about the history of Linux. First off, what is Linux? When we say Linux,
we mean one of many specific distributions in a family of open source
Unix-like operating systems. They’re all based
on the Linux kernel that was developed
by Linus Torvalds. These are typically bundled in what we call Linux distribution. We’ll talk about all these
terms through this module. Don’t stress a lot of what I just said that make sense,
we’re going to get there. Linux was originally developed
for the personal computer, which is the X86 architecture. That’s the same
architecture that we use for Windows machines, for Macintosh machines today. Very popular architecture
used in home. It was then ported to
many other platforms. These are typically servers that are out in the Internet,
in the Cloud today. Very successful. It’s
also used in Android. Android, which is
google smartphone, which has at least half of the smartphone
market, uses Linux. Chromebooks, which had become very popular again from Google. They have a Chrome
OS that uses Linux. Many embedded systems
also run Linux. About 90 percent of all the Cloud Infrastructure
is powered by Linux. Linux is out there, very popular and very
important to our society.

在这里插入图片描述

Let’s take a step
back and think about those embedded systems. There are many different
embedded systems. The difference is
a generic system is what we call
personal computer. You can use it for many things. You can use it for creating
music, for watching videos, for learning, for doing
Excel and accounting, those sorts of things,
for programming. It’s generic. Embedded
systems have one purpose. Some examples are a home router or a router in your company, it’s going to route
traffic between your private network and
your public network. Automation control systems in industry, smart home technology, things like our thermostats
today or sprinkler systems, all of our televisions now come with an embedded
system so we can install channels like Peacock or Netflix and Amazon Prime. New channels can
come along that are developed or updated after our television has
been released. Our automobiles have
many embedded systems, our digital video recorders, our video game console, our smartwatches right there, everywhere nowadays
and it’s going to keep growing and a lot
of these run Linux.

在这里插入图片描述

How is Linux different? Linux has many advantages
over other operating systems. This includes, it’s open-source. Now we’re going to drill into what we mean by open source. But the one-liner is, you’re able to see
the source code, make changes and share
it with other people. That’s not true of other
operating systems. We’ll come back to this. It’s community supported. Because it’s open source lots of people can provide support. You’re not locked into
one vendor for support. It supports older hardware. In the other world, the operating systems
try to get you to upgrade your
hardware all the time. That becomes
expensive. Linux will actually work on older machines.

在这里插入图片描述

To think about the
precursors(前身) to Linux, Unix was developed in
1969 by Bell Labs. Bell Labs was owned by AT&T, which was a monopoly(垄断) that
owned the phone service. AT&T because it wasn’t monopoly
was required to license the Unix operating
system source code to anyone who asked. Then in 1984, when
the government split up AT&T it divested
itself of Bell Labs. Bell Labs began selling Unix
as a proprietary product.

在这里插入图片描述

At that time that the
GNU project started up. The goal of GNU was creating a complete Unix compatible
software system composed of entirely
free software. This doesn’t necessarily
mean free in dollars, but free in use. Again, we’ll keep talking
about this concept later on. In 1985, Richard Stallman started the
Free Software Foundation. In 1989, Stallman wrote the
GNU general public license. We call that GPL or GNU GPL. Then by the early 1990s, many of the programs required in an operating system
were completed. These include things
like the libraries. We link 在这里插入图片描述
our source code to, the compilers that convert our human-readable text
to machine readable code. The text editors,
command line shell, and a windowing system
similar to Mac and Windows.

Another early project was Minix. It was created by
Andrew Tanenbaum. Andrew Tanenbaum is a famous operating system
computer scientists. This was a minimal Unix-like
operating system targeted at students and others
who wanted to learn operating
system principals. Tanenbaum shared the complete
source code of Linux. But the licensing terms prevented from being
free software, meaning you couldn’t change Minux and share it
with other people. Today Minix 3, which
is the latest version, is a free open source operating
system similar to Linux. But really the ship had sailed. Linux became popular and so it’s really too
late for Linux, but it’s still there
to learn from.

在这里插入图片描述

Let’s think a little bit
about Linus Torvalds. In 1991, he was attending
the University of Helsinki and he became curious
about operating systems. He tried to build his own
operating system kernel, which eventually became what we call the Linux kernel today. It was originally developed for Minix and use Minix tools. But then he switched
the license to use the GNU GPL and the
tools from GNU project. That’s it for lesson 1.
Just a little review here. Unix was owned and
licensed by Bell Labs. The Free Software
Foundation created GNU tools as part
of the GNU project. Linus Torvalds created
the Linux kernel and used the GNU
tools ultimately. That’s how we ended
up with Linux today. I’ll see you in the next lesson.

Quiz: History of Linux Practice

在这里插入图片描述

在这里插入图片描述

Linux Licensing Model

Welcome back to the
Linux operating system. In this lesson, we’re
going to drill into the Linux licensing model. We talked about the GNU GPL. GPL stands for General
Public License. The Linux kernel
and the code from the GNU project are all
licensed under GNU GPL, which means you can freely
copy the source code, you can change it, and then you can distribute those changes. What you cannot do is impose any restrictions on
further distribution. If you’re giving在这里插入图片描述

someone your changes, you can’t control
what they do with it, besides, it has to be
licensed under the GPL. When you make changes and you share them with the community, if anyone then
improves your changes, they have to share those
with the community. But that’s what we meant
by community support in that last lesson.

You’re probably saying how do companies make
money on Linux? Well, some distributions charged
for a supported release. Consultants charge for the
installation customization of Linux because once
you become an expert, people want to hire experts. Cloud companies do not distribute because they’re
not giving their code, so there’s no need to
share the source code. Many commercial companies
gave up their own OS work and embrace Linux to compete
with Microsoft Windows. This includes IBM,
Hewlett-Packard, Dell. The idea is, let’s take Linux, embrace it and add features
to it so we can now charge for distributions
potentially and services and compete
with Microsoft Windows. All right, a little review here. Open source does not mean
you cannot charge for Linux, it means you have to allow someone to have the
source code if you give him Linux and you have to allow them to
share those changes also. If you give someone your
changed Linux executable, you have to give the
source code with it. Everyone has the right
to change and add to Linux. All right,
see you next time.

Quiz: Linux Licensing Model Practice

在这里插入图片描述

Linux Distributions

Welcome back to the
Linux operating system. In this lesson,
we’re going to look at some Linux distributions, and we talked about earlier
that Linux is often packaged into what we
call a distribution. We’re going to look at
the major ones here, but there’s many out there. Red Hat Enterprise Linux, this is often abbreviated RHEL. It’s developed by Red Hat
for the commercial market. They’re trying to sell
to businesses and the price that you pay for Red Hat Enterprise
Linux includes support. Now, you may say, ''Pay?
I thought it was free? ‘’. Remember, you can charge
for your Linux distribution, but you have to include the
source code, and they do so. You can buy Red Hat
Enterprise Linux and you pay, you get support and you
get their distribution. The initial release was
February 22nd, 2000, so it’s been around for 22
years or almost 22 years. Today, Red Hat is a
subsidiary of IBM, and we talked about
IBM leveraging Linux to make money to compete
with Microsoft Windows. IBM has gone all in
and they actually purchased Red Hat
Enterprise Linux. The server versions
of their software, which is what they’re mainly aiming for the
commercial market, are for x86-64, which
means 64-bit Intel, Power PCs, ARM64
processors, and the IBM Z. There is a desktop
version for x86-64, so you can run Red Hat
Enterprise Linux on the desktop, but that’s not really
what their goal is. Their goal is really to sell server software to the
commercial market. They’re designed
to be stable with long-term support for
enterprise users. What I mean by
that is new things do not come flying
into the distribution. One of the benefits of Linux’s is there’s
lots of innovation. One of the challenges with Linux is there’s lots of innovation. In a commercial environment, you want a stable system where new versions only patches
that have been tested to ensure that
vulnerabilities for cybersecurity or bugs are
fixed should be released, and that’s basically how Red
Hat Enterprise Linux works. They aren’t going to
throw a new version into the current version
of Enterprise Linux. They only put patches
that fix problems. There is an open source
version called CentOS, which is a redistribution. When I say open source,
they’re both open source, but Red Hat Enterprise Linux includes intellectual
property added, things like their logos,
those are copywritten. The Linux system is GPL. CentOS strips out that intellectual
property and gives you an equivalent version of
the Linux distribution.

在这里插入图片描述

Fedora, this Linux
distribution is developed by the community and it’s what’s called community
supported Fedora project. It’s mainly supported by Red Hat and its initial release
was November 6th, 2003. Its had over 30 releases. Remember, Red Hat
Enterprise Linux tends to be very controlled. That’s what the
commercial market wants. Fedora is this
community supported and Red Hat supported version
that has innovation in it. It’s designed to innovate. Lots of releases. It focuses on innovation by
integrating new technologies early so they can see
what they’re going to embed into the Enterprise
Linux later on.

在这里插入图片描述

SUSE is a big name in Linux. They are German-based
multinational open source software company. They distribute several
different Linux products including open or SUSE
Linux Enterprise server, openSUSE, SUSE Linux
Enterprise Desktop. The initial release was very
early September 2nd, 1992. They were owned by
Novell from 2003-2011. Novell was a big player in the PC networking
world before this, and one of the ways it
tried to adjust was to buy openSUSE or buy SUSE and that didn’t really
work out so well.

在这里插入图片描述

Ubuntu is a relatively new
player and very successful. It’s based on Debian. Debian is one of the
two major categories, if you will, of distributions. It’s free to download. Paid support can
be purchased from Ubuntu. There are
three editions. There’s a desktop, server, and there’s a core
for Internet of things, devices, and robots. You can think of the
Internet of things as almost the same as embedded. They tend to be things like
in appliances and such, like air conditioners or thermostats, those
sorts of things. Long Term Support,
what they call LTS, releases are supported for five years and are
released every two years. Every two years Ubuntu is
going to have a version that will be supported
for the next five so people can plan.

在这里插入图片描述

Debian is both a
distro and a category. Many of the other distributions
are based on Debian, as we talked about with Ubuntu, but you can also just
download Debian itself. Debian comes in three
different releases: stable, testing, and untested. You can probably guess
what untested means. As features are added, you can download
them immediately in the untested version, versus the other end of the
spectrum is stable where the developers think
that everything in the distro is
stable at that point. Debian is free to download. It is very similar to Ubuntu because Ubuntu is
based on Debian. Now, Ubuntu focuses on usability and Debian
really focuses on freedom. It’s about the ability to make changes and add those
back to the community. There’s no corporate
support for Debian. It’s very community-driven. A little review here.
There are hundreds of Linux distributions
out there. Some require money to download, others are free to download, and all are open source, but they may include content
that is not open source, such as in the Red Hat
Enterprise Linux model. See you in the next lesson.

在这里插入图片描述

Quiz: Linux Distributions Practice

在这里插入图片描述

Linux Command Line

Welcome back to the
Linux operating system. In this last lesson
of this module, we’re going to think about
the Linux command line. Now, later on
throughout this course, you’re going to learn
more and more commands. We’re just going to get
a little taste here. The Linux desktop has a
graphical user interface, we called it a GUI, but most installations
use the command line. We talked earlier in
an earlier lesson that 90 percent of
the cloud is Linux, and most of the time,
what we call SSH’ing, you’re getting a terminal
session and using the command line of a
server that’s out in the cloud because that’s
faster than trying to display a graphical user
interface across the cloud. A shell provides you with an interface
to the Unix system, and it’s different shells, you
can choose your own shell, but the Bourne shell
is the standard one, and you’ll get a dollar
sign character as the prompt when it’s waiting for a command
with the Bourne shell.

在这里插入图片描述

Some common commands, PWD is going to return the path of the current
working directory. You see that in
the screen image. You’ll see in the screen image, I did a PWD and it
shows home aspen, that’s the directory
I’m in at the time. Cd changes the directory, and there’s different
ways to do it. So you can cd… to
move one directory up. Directories in the file
system are hierarchical, we’ll talk more
about that later. But in the example in the
screenshots has home aspen, if I do a cd… I
go back to home. If you type just
the cd on its own, you’ll go to the home directory or the home folder for the user, and cd with a hyphen to move
to your previous directory. Ls lets you view the
contents of a directory, and there’s several switches. There’s ls -R will list all the files in the
sub-directories as well, ls -a will show hidden files. Hidden files are files
just like any other files, but they don’t show
up by default. Ls al will list the files
and directories with detailed information like the permission size, owner, etc.

在这里插入图片描述

The cat command lists the contents of a file
on standard output, and we’re going to
learn a lot about standard output and
redirecting standard output. But you’ll see an example
here where we say cat, and we redirect with the greater
than symbol to filename, is going to create a new file, or cat filename 1,
filename, space, filename 2, redirect to
filename 3 is going to join the two files to
this new filename. The cp command is
going to copy files, you’ll see an example in
the screenshot in front of you where I’m just copying
a file called my.txt, that’s got to be in
the current directory, and I’m copying it to
the directory home two. Mv is going to move
or rename files, make directory is
going to create a new directory in the
current directory, rm is going to remove
a file and directory, and rm -r is going to remove a directory and all
the files inside of it. I’ll do some examples, and you’ll have a Linux
terminal that you can play with in the lab. But just to review
here, the PWD command will show you the
current directory, the ls command will list the
contents of a directory, and the cat command will
list the contents of a file. See you in the lab.

在这里插入图片描述

Quiz: Linux Command Line Practice

在这里插入图片描述

Week 1 Lab

Use the slides from the 1st lesson reading and try each of the commands discussed in the cloud implementation of Debian Linux. When you enter the cloud lab - please click on the terminal menu and new terminal. This will give you a command line prompt in an debian Linux shell.

You should try out these commands we talked about this week:

  • pwd
  • cd
  • ls
  • cat
  • cp
  • mv
  • mkdir
  • rm

Make sure you try the command options we discussed in the lectures

Module Graded Quiz

就是前面做的Quiz的集合。

Week 02: Linux Services

In the second module of this course, we will discuss the services available in the Linux operating system. We will explore many services including web servers and database servers, among others. We will look at how you start and stop services from running in the Linux operating systems.

Learning Objectives


  • List the several services provided by the Linux operating system
  • Describe several Web Servers available in Linux
  • Describe several Database Servers available in Linux
  • Start and Stop services

Servers vs Desktops

Welcome back to
Linux Fundamentals. This is the first course in the Linux Foundation
Specialization. In this module, we want to
think about Linux services. By the time you’re
done with this module, when you take the quiz, you should be able to do these things: you
should be able to list several services provided by
the Linux operating system. You should be able to describe several web servers
available in Linux. You should be able to describe
several database servers available in Linux, and lastly, you
should be able to start and stop services. In lesson 1, we
want to distinguish between server and desktop. Servers focus on programs that
provide shared resources, we call those services. Desktops focus on
programs that run in a graphical user interface.
We call that a GUI. Think about macOS and Windows, these are typical desktop
operating systems. Now it’s true, you
might say Windows has server operating systems, it’s true, but the GUI is
really for the desktops. In this course, we’re
going to think about primarily the use of
Linux as a server. We’re going to think about these shared resources
and services. There are two primary ways
servers run service programs. The first is a background
process that’s always running
listening for request. The other is as a
process spawned(产生) by a parent program that
listens for request. The parent is listening,
a request comes in, it spins up a new child to service that
request so that it can continue listening
for new requests coming in from other clients.

在这里插入图片描述

You’re going to hear
this term deamon referred to in services in
Linux. What is a deamon? When a Linux service runs continually as a
background process, it is called a deamon. Linux deamons often end with
the letter d. For example, mysqld is the program that’s a demon for
the mysqld database.

在Linux中,“daemon”(守护进程)是在后台运行的一种特殊类型的进程,通常不与任何终端相关联。守护进程通常在系统启动时启动,并在系统关闭时终止。它们通常用于执行系统级任务,如管理硬件设备、提供网络服务等。

在这里插入图片描述

There are several major
service types available. We have file servers,
print servers, web servers, database
servers, mail servers. Now, you all can think about the default name of a
host on the web is www, that stands for web server. This comes from
the days where in the office you would
have a file server, often called file and a print server called print
and web came along, which was World Wide Web,
that was web server. We have all different
kinds of servers, maybe a one machine, they may have separate machine, may have multiple machines
to service the load. But we have these different
major service types. We also have network
resource servers. These are supplemental services that help support things
like assigning addresses, logging, those sorts of
things. A little review here. Linux desktop has
programs designed around GUI interactive applications,
graphical user interface. A Linux server has
programs designed around background services
that share resources, and deamons often
end with the letter d in their name to help
us see when it’s running, that it’s a deamon versus an interactive program. See
you in the next lesson.

Quiz: Servers vs Desktops Practice

在这里插入图片描述

Web Servers

Welcome back to Linux services. In this lesson, we’re going to
drill into a very specific and common service that’s running
Linux Servers Web Servers. I said earlier in a previous module that
90% of the cloud runs on Linux Servers. And so a lot of those our web servers,
So web servers sit and listen on either port 80 or 443,
they can actually listen to any port. But these are the two common
ones 80 is for non encrypted, 443 is for SSL or HTTPS connections. And when an incoming request comes in, they assign the request to a process and
return the response, okay? There are three major web
servers available on Lenox, Apache, nginX and Lighttpd.

在这里插入图片描述

Okay, so Apache, this is a free and open
source cross platform web server software. It’s released under the terms
of the Apache license 2.0. The Apache license 2.0 is similar to GPL,
there’s some small differences, but essentially it’s open
source software like GPL. Its initial release is 1995,
And Apache uses compiled modules to extend the core functionality
with things like Server Side Languages. PHP is the most common,
but Perl, Python, Tcl, those sorts of things are compiled
in to the Apache Server Side. Apache uses .htaccess files for
its configuration, and in 2009 it became the first
web server software to serve more than 100 million websites. As of (截至)April 2021, there are 313
million web servers running Apache.

在这里插入图片描述

All right, nginX is free and
open source cross platform web server software released
under the terms of FreeBSD. Now, FreeBSD is a little
more free than open source. So basically you can do what you want. So, remember GPL said you
had to make sure that any derivatives you made were
also available via GPL. The Apache license we just talked about
is very similar where freeBSD you can do anything you want. So for example,
MacOS X is actually derivative of open source Unix called BSD Unix. And BSD Unix used the FreeBSD license and Apple was able to close
source their derivatives. Okay, the initial release
of nginX is 2004, which is relatively recent. It’s owned by F5 Networks. F5 Networks does a lot in routers and
firewall software. In the next modular, event driven
architecture can provide predictable performance under very high loads. And as of April, there’s 432
million web servers running nginX. So they’ve overtaken Apache is
the most popular web server out there.

在这里插入图片描述

Our last one we’ll talk about is Lighttpd. This is free and open source web
service software that’s optimized for speed critical environments. And this also is released under
the terms of the FreeBSD License. Its initial release is 2015 and it’s
used by several high traffic websites, including YouTube, or
it was used by YouTube. There are around 33 million web servers
running Lighttpd as of April 2021. All right, little review here. Web servers run in the background and serve HTTP and HTTPS requests. Apache is used by more
shared hosting providers. These are hosting providers where there’s
multiple tenants on a single server, engine access taken a lot of the web
server market because of its predictable performance. All right, see you the next lesson.

在这里插入图片描述

Read through this blog that compares Apache and Nginx: https://kinsta.com/blog/nginx-vs-apache/

Quiz: Web Servers Practice

在这里插入图片描述

Database Servers

Welcome back to Linux services. In this lesson,
we’re going to think about a very specific service. Just like in the last lesson, but this time we’re going to think about database servers. Database servers listen on the network for
incoming requests. Often, this is in
the form of SQL, and then they respond
with the data. There are two major
categories of relational. In the relational databases, we have Postgres and MySQL, the two major Linux versions. In the NoSQL world, popular NoSQL is MongoDB to
be run on Linux servers.

在这里插入图片描述

Let’s first talk about the
relational database model. It’s the dominant
database model used in business applications and it
has been since the 1980s. It’s organized in
two-dimensional tables and you have entities which are a distinguishable
component of the system. For example, an employee
would be an entity, a customer, or a rug for sale. A tuple is a row in
a relational table, and an attribute is a
category of a field. We have this concept
of a primary key, which are attributes that
uniquely identify a tuple.

在这里插入图片描述

SQL stands for Structured
Query Language. It’s the standard query language for database management systems. You use SQL queries to retrieve data according to some criteria. For example, if I wanted to
retrieve the name, phone, and email for customers
in a specific zip code, I’d issue a query
that looks like this. Select name comma
phone, comma email, from customers, where
zip code equals. I’m giving it a
specific zip code.

在这里插入图片描述

The NoSQL database model
is document-oriented. Not all of them are, but most of them are
document-oriented. They mainly come from this idea, what’s called the CAP theorem. The CAP theorem says we can only have two of the following; availability consistency
and partition tolerance. It’s really designed
to scale really high. For example, if we have a
partition in the network, we want to still be able to sell customers goods on
our shopping cart. We will choose consistency and availability and give
up partition tolerance. Or we’ll give up consistency and choose availability and
partition tolerance.

“Availability”, “Consistency”, and “Partition Tolerance” are three key concepts in distributed systems, often referred to as the CAP theorem. The CAP theorem states that it is impossible for a distributed system to simultaneously provide all three guarantees. Here’s a brief overview of each concept:

  1. Availability: This refers to the guarantee that every request receives a response about whether it succeeded or failed. In other words, the system is always operational and accessible to handle requests, even if some parts of the system are experiencing failures.

  2. Consistency: Consistency ensures that all nodes in a distributed system have the same data at the same time. When a data update occurs, all subsequent access requests should return the updated data or an error. Inconsistent data should not be returned.

  3. Partition Tolerance: Partition tolerance means that the system continues to operate despite network partitions (communication breakdowns) between nodes in the system. Even if some nodes can’t communicate with each other due to network failures, the system as a whole can still make progress.

In distributed systems, designers often have to make trade-offs between these three properties. For example, a system can choose to sacrifice consistency in favor of availability and partition tolerance, which is known as the AP model. Alternatively, it can prioritize consistency over availability, leading to the CP model. The choice depends on the specific requirements and priorities of the application being designed.

CAP 定理指出在分布式系统中, Consistency(一致性)、Availability(可用性)、Partition Tolerance(分区容错性)三者不可同时兼得,最多只能同时满足其中两项。这三个概念分别表示:

  1. 一致性(Consistency):指系统中的所有节点,在同一时刻看到的数据是一致的。也就是说,当一个节点对数据进行了更新,那么所有后续对该数据的访问都应该返回更新后的数据,或者返回一个错误。不能返回过期的或不一致的数据。

  2. 可用性(Availability):指系统一直保持可用,对于用户的每一个操作请求,系统都能在有限的时间内返回结果(成功或失败)。即使系统中的某些部分发生了故障,也不会影响整体的可用性。

  3. 分区容错性(Partition Tolerance):指系统能够容忍网络中断或者分区(即部分节点之间无法通信),即使系统出现了分区,仍然能够继续运行。

在设计分布式系统时,往往需要在一致性、可用性和分区容错性之间做出权衡和取舍。不同的应用场景可能会选择不同的权衡策略,例如优先保证可用性和分区容错性而牺牲一致性(AP 模型),或者优先保证一致性和分区容错性而牺牲可用性(CP 模型)。选择取决于具体的应用需求和优先级。

在这里插入图片描述

We have this idea
of CRUD which are standard operation on
facts in a database. These include Create,
Read, Update, and Delete. This is true of both relational
and NoSQL databases. Just a little review
both relational NoSQL support CRUD operations. Relational databases
are transactional focused and NoSQL is
often document-focused. Alright, see you in
the next lesson.

Quiz: Database Servers Practice

在这里插入图片描述

Managing Services

Welcome back to Linux services. In this final lesson
of this module, we’re going to think about
how do we manage services. The Init process,
or init program, or systemd is the parent process of every process in
your Linux system. Now, you might not know which program is actually
the parent process. You can use the
command Which Init, which will show you the
location of the init process, but that’s still may be a link. So you can use the readlink-f and what comes back
from Which Init. In my case, it came up with /usr/sbin/into and
if I did readlink, it actually says what
that program links to.

在这里插入图片描述

Often nowadays, it’s
going to link to systemd. Systemd is a software
suite that provides an array of system components for the Linux operating system. Its main aim is to unify service configuration
and behavior across the different
Linux distros. We’ve talked about
those Linux distros or the major ones
at least so far.

在这里插入图片描述

I want to talk about how you
can control these services. The things you want to
do are often starting or stopping or restarting services. In front of you are the
different commands, and I put sudo in front of them depending on your user rights. Often, you use sudo, which gives you
administrative rights to the command you’re running. If you’ve already got those, you don’t need to put the sudo, but sudo system control start, and then the name in brackets
is the application server. That will work on any
systemd distribution to start a service. The same command but
replace start with stop, will stop that service in
any systemd Linux distro. Now there are other
commands that you can see for restarting. That will stop and then start the service again or reload, which essentially is a
way if the service is designed to reload its
configuration quicker, so maybe you change your configuration
file, you can reload. You can enable a service
so that it will start on reboot or disable it so it would no longer
start on reboot, or you can check the status. You can see this
one system control does all these
things for services, and it’s consistent across any Linux distro
that does systemd. Just a little review
for this lesson. The systemd is the
new standard for a service configuration
and the Which Init command will allow you to see where your process init is
actually located. You can use the
readlink command to see what process controls your
service configuration. Because a lot of these
old distros will try to keep the
same init command there for compatibility, but they switch to systems, so that’s where the Which Init
and the readlink come in. We’ll have some labs where
you get to play around a little bit with all this and then I’ll see you
in the next lesson.

systemd 是一个在 Linux 系统中用于管理系统启动、服务管理、进程控制、日志记录等的系统和服务管理器。它被设计为替代传统的 init 系统,提供了更快速、并行化的启动过程,并且可以更好地管理和监控系统中运行的服务。

systemd 的主要特点包括:

  1. 并行启动:systemd 可以并行启动系统中的服务,提高系统启动速度。

  2. 单一进程:相比传统的 init 系统,systemd 作为单一进程运行,更容易管理和维护。

  3. 服务管理:systemd 可以管理系统中的各种服务单元,包括启动、停止、重启、查看状态等操作。

  4. 依赖管理:systemd 可以根据服务之间的依赖关系自动启动和停止服务,确保服务按照正确的顺序启动。

  5. 日志记录:systemd 使用 journald 守护进程来记录系统日志,可以更方便地查看和管理日志信息。

  6. 资源限制:systemd 可以通过 cgroups 控制组来限制和管理各个服务的资源使用,提高系统的稳定性和安全性。

总的来说,systemd 提供了一种更现代化、高效的系统管理方式,使得管理 Linux 系统变得更加简单和方便。然而,它也因为其引入的一些变化和新特性而在 Linux 社区引发了一些争议。

Quiz: Managing Services Practice

在这里插入图片描述

Week 2 Lab

ps -aux 是一个用于显示当前系统进程状态的命令。在 Linux 系统中,ps 命令用于显示进程信息,而-aux 参数的含义如下:

  • -a:显示所有用户的进程,包括系统和其他用户的进程。
  • -u:以用户为主的格式显示进程信息。
  • -x:显示没有控制终端的进程。

因此,ps -aux 命令会列出当前系统中所有进程的详细信息,包括进程的 PID(进程号)、用户、CPU 占用率、内存占用率、启动时间等。这个命令在排查系统问题、监控系统状态时非常有用。需要注意的是,在一些较新版本的 Linux 发行版中,ps -aux 已经被废弃,推荐使用 ps aux 来获取相同的结果。

The cloud based Linux runs in a Docker session instead of a virtual machine. This means you do not have access to SystemD tools that we talk about in this module. You can still experiment with deamons. Launch the lab and go to a terminal shell. Type ps -aux and look for the process id number (PID) for MySQLD. Type Kill -9 [PID]. You will replace [PID] with the PID for the MySQL Deamon in your instance. This will stop the process. Next type mysqld at the command line. This will start the MySQL server in the foreground. You will see that you cannot type another command. Stop the lab and go back in and kill the MySQLd instance. Next type mysqld & so it runs in the background.

Week 03: View, Create, Copy, Move and Remove Files

In the third module of this course, we will learn how manage files and directories in the Linux operating system. We will discuss how to view, create, copy, move and remove files. We will look at creating links for files and directories. Lastly, we will look at comparing text files.

Learning Objectives


  • View, Create, Copy, Move and Remove Files
  • Create links to files and directories
  • Read complete and parts of files from the Linux command line
  • Locate File Locations from the Linux command line

Handle Files and Directories

Welcome back to
Linux Fundamentals. This is the first course in the Linux Foundation
Specialization. In this module, we want to
think about how to view, create, copy, move,
and rename files. Basically, we’re thinking
about how to manage files and directories in the
Linux operating system. Some learning objectives. When you’re all done
with this module, I want you to be able to
view and create files, copy and move files, remove files, create links
for files and directories, read portions of files, read complete files, and
find differences in files. In this first lesson,
we’re going to think about handling files and directories. Some commands here, the ls command, I want to
do a deep dive. We’ve looked at it a
little bit before. But essentially the
syntax looks like this. You say ls with the options
followed by the path. The example in front of you
in the console is ls minus a. Minus a says list all files
including the hidden files, and hidden files
start with a period. So you’ll see in that directory the period docker environment is a hidden file in
the current directory. The minus A option lists
all files including hidden files except for the
dot and double-dot files. These refer to the entries for the current directory and
the parent directory. So here you’ll see the dot and the
double-dot right there. Then the minus R lists
all files recursively descending down the directory
tree from the given path. In my case, in the example, I don’t give you a path which assumes the current directory, otherwise, you could tell it
a specific path to work in.

在这里插入图片描述

There’s also a minus l option that lists the files
in long format. This is with an index number, an owner name, a group name, a size, and permissions. There’s a minus o option which lists the files
in long format, but without the group name. There’s a minus
g, which is going to list the files
in long format, but without the owner name. There’s a minus i which lists the files along with
their index number, and there’s a minus s which lists the files along
with their size. So there’s lots of
options. We’re going to play around with them
a little bit in a lab.

在这里插入图片描述

There’s a minus t which
is going to sort the list by time of modification with
the newest at the very top. There’s a minus S which sorts the list by size with
the largest at the top, and there’s a minus r, which
reverses the sorting order, so it makes the
smallest at the top.

在这里插入图片描述

Just a little bit of a review of some things we saw earlier. For file commands, we saw cat, which lists the contents of
a file onto standard output. Later on in this course, we’re going to talk
about redirection so we can send it and
create new files. We have the cp to copy
files or directories. You see the example in front
of you where I copy a file. We have the mv to move or
rename files or directories. We have the make directory, which creates a new directory
in the current directory, and we have the rm to remove
files and directories. Lastly, the touch command, which updates the time
and date of a file. A little review here. The touch command can
create a new file. So if you touch something
and it doesn’t exist, it creates a file and puts a
current date and time on it. The ls command can show hidden files with
the right switches, and many commands work
with both directories and files. I’ll see you
in the next lesson.

在这里插入图片描述

Quiz: Handle Files and Directories Practice

在这里插入图片描述

Files and Directory Links

Welcome back to Managing
Linux files module. In this lesson, we
want to look at links to files and directories. First, we’ll start
with the hard link. A hard link is a file or
directory with one index number, we call it an inode, and at least two
different file names. I have a little image
in front of you. Essentially, you have
the inode number that points to a
location on disk, but we actually have two
different file names that point to that inode number.

在这里插入图片描述

You can create a hard link
with just the ln command. You say ln original
filename linkname, I have an example
there where I’m linking file 1 already existed, but I’m creating a new mylink that’s going to point to
the same inode number. The original file must
exist prior to issuing this command and the link file is created when the
command is issued.

在这里插入图片描述

硬链接(hard link)是指一个文件可以有多个有效路径指向它的索引节点(inode)。在 Linux 和类 Unix 系统中,每个文件都有一个索引节点,其中包含有关文件的元数据和数据块的位置。硬链接创建了一个新的目录项,将文件名与索引节点关联起来,从而允许同一文件在文件系统中有多个路径。这使得文件可以具有多个别名,但实际上只占用了一个索引节点的空间。

要创建硬链接,可以使用 ln 命令。其基本语法为:

ln 源文件 目标文件名

例如,要在当前目录下创建一个名为 file2 的硬链接指向 file1 文件,可以使用以下命令:

ln file1 file2

需要注意的是,硬链接只能针对同一个文件系统内的文件使用。在创建硬链接时,不会复制原始文件的内容,只是创建一个新的目录项指向相同的数据。因此,无论是原始文件还是硬链接文件的任何更改都会反映在其他所有硬链接中。

另外,删除一个硬链接并不会影响原始文件或其他硬链接,只有当所有硬链接都被删除时,文件的数据块和索引节点才会被释放并回收。

Soft links are when a file with different index numbers,
different inodes. The soft link file points
to the other files. I have a little image
in front of you where I’ve got filename1, which has got its own
inode number points to filename2 with inode number
which points to the disk.

在这里插入图片描述

We’re going to use
the same command, the ln command with
the minus s switch, and again, the original
file name comes first, then the link filename. The originalfilename must exist prior to issuing the command, and the link file is created
when the command is issued. A little review
here, if you delete the original file
with a hard link, the link still works
because you’ve got two files pointing to
the same inode number. If you delete the original
file with a soft link, the link will be broken because the soft link is pointing to the other file which
no longer exists. You can link both files and folders or directories.
See you next time.

软链接(symbolic link,也称为符号链接)是一种特殊类型的文件,它包含了另一个文件或目录的路径。与硬链接不同的是,软链接并不包含指向文件数据的索引节点,而是包含了目标文件的路径名。因此,软链接可以跨越文件系统,并且可以链接到不存在的目标。

在 Linux 和类 Unix 系统中,使用 ln 命令创建软链接。其基本语法为:

ln -s 目标文件或目录 软链接文件名

例如,要在当前目录下创建一个名为 link_to_file1 的软链接,指向 file1 文件,可以使用以下命令:

ln -s file1 link_to_file1

软链接的删除与创建非常简单,只需要删除软链接本身即可,不会影响原始文件或目录。但是,如果软链接指向的目标文件或目录被删除或移动,软链接就会失效,称为“死链接”。

软链接通常用于创建快捷方式或者在不同位置共享文件或目录。由于软链接是一个独立的文件,因此可以有不同的权限和拥有者,并且可以链接到目录以及文件。

Quiz: Files and Directory Links Practice

在这里插入图片描述

Reading Files

Welcome back to managing Linux files and
directories. In this third lesson, we want to look at
how you can read the entire text file or parts of text files from
the Linux command line. All right, so let’s first define
what are Linux text files. The Linux system contains many text files. They include configuration files,
log files, data files, plus many others. And understanding how to view these files
is a very important skill when you’re dealing with Linux command line.

在这里插入图片描述

So let’s revisit the cat command. We’ve seen this a few times, but the cat command lists the contents
of a file onto the standard output. So some example usage are cat
greater than filename, will create a new file based
on whatever you type in. Cat filename 1, filename 2 greater
than filename 3 will take the contents of filename 1 and contents of filename 2
and put it in the filename 3 as one file. There’s a couple options here. Dash n is going to
number the output lines. And dash s is going to suppress
repeated output lines that are empty. Okay, and again when we do our lab,
we’ll see this.

在这里插入图片描述

cat > filename 是一个常用的命令,用于创建或覆盖一个文件,并从标准输入(通常是键盘)中读取内容写入该文件。具体用法如下:

  1. 使用以下命令打开一个新文件 filename 并输入内容:

    cat > filename
    

    按下 Enter 键后,可以开始输入内容。输入完成后,按下 Ctrl + D(表示文件结束)保存并退出。

  2. 如果文件已经存在,cat > filename 命令将会覆盖该文件的内容。如果要追加内容而不是覆盖文件,可以使用 >> 操作符,如:

    cat >> filename
    

    输入内容后,按下 Ctrl + D 保存并退出。

这种方式在需要快速创建或编辑一个文件,并且内容不是很长时非常有用。但对于较长或复杂的文件内容,最好使用文本编辑器,如 Vim、Nano 等。

There’s the pr command which is going to
display too short text files at the same time. This allows you to quickly
view the files side by side. Now there’s two options
that are really important. One is the dash m which is going to
print all the files in parallel, one in each column. And the dash l which lets
you set the page link. So the example is pr minus m. So we’re going to put them in
pair of file 1 text file 2 text.

在这里插入图片描述

pr 命令是一个用于格式化打印文件的命令,可以将文件内容按照指定的格式输出到标准输出或打印机。pr 命令的基本语法如下:

pr [选项] 文件名

常用选项包括:

  • -d:双栏输出,将文件内容分成两栏输出。
  • -h 字符数:指定每页的页眉字符数。
  • -l 行数:指定每页的行数。
  • -o:将输出结果发送到标准输出,而不是打印机。
  • -w 字符数:指定每行的字符数。

例如,要将文件 file.txt 分成两栏输出到标准输出,每列最多显示40个字符,可以使用以下命令:

pr -d -w 40 file.txt

pr 命令还可以与其他命令结合使用,例如使用管道符将 ls 命令的输出传递给 pr 命令,实现分页输出:

ls | pr

这将按照默认的格式将 ls 命令的输出分页输出到标准输出。

We have the grep command which
helps you find a file line or lines that can contain certain text. So an example usage here is
I’m going to grep looking for the word aspen inside
the etc password file. Now the dash i ignores case,
that’s the option to ignore case, which is an important option to grep.

在这里插入图片描述

We’ve got the head command which is
going to display the first ten lines of a text file and
the example usage here is head minus n. And the minus n option lets you override
the number of lines to display. So here I’m going to say, just show five
instead of ten of the etc password file.

在这里插入图片描述

The tail is the opposite, it displays
the last ten lines of a text file. And again, the minus n lets you
override the number of lines. So tail minus n 5 etc password will
show the last five lines of the etc password file.

在这里插入图片描述

We also have the pager commands. And these allows us to go through
a large file’s text using the pager. And the utility allows you to
view one text page at a time and move through the text at your own pace. The two common ones are called more and
less. Less is more powerful. It’s kind of funny. So the example here is less etc password. Now, if it’s only one page,
it’ll display at all. If it’s more than one page, it gives
us a page and then we have our options. So we can move forward one line with
the down arrow, the enter key, the e, or the j. We can go backward one line
with the up arrow, y, or k. We can move forward one page
with a space bar or page down. We can move backward one
page with the page up or b. We can scroll to the right
with the right arrow, scroll to the left with the left arrow. We can jump to the top of
the file with a home or g. The main two options are to page forward
with the space bar or page down.

在这里插入图片描述

less 是一个类似于 more 的命令行文本文件查看器,用于浏览文本文件的内容。与 more 不同的是,less 允许用户向前或向后浏览文件,并提供了更多的浏览功能和选项。

使用 less 命令的基本语法如下:

less 文件名

这将打开指定文件,并在终端窗口中显示文件内容。一旦文件被打开,可以使用以下键盘命令来浏览文件:

  • 向下滚动一行:j 键或向下箭头键。
  • 向上滚动一行:k 键或向上箭头键。
  • 向下滚动一屏:空格键。
  • 向上滚动一屏:b 键。
  • 向下滚动半屏:d 键。
  • 向上滚动半屏:u 键。
  • 跳转到文件开始处:g 键。
  • 跳转到文件末尾:G 键。
  • 退出 lessq 键。

除了这些基本的浏览操作外,less 还支持一些其他的功能和选项,如搜索、跳转到指定行等。可以通过 man less 命令查看 less 的完整使用说明。

All right, a little review here, grep can
find individual lines in a text file. Head can show you n number of
rows from the top of a text file. And less is faster than more. I’d like to say, that’s kind of funny. But the less is the page utility that
most people use because it’s optimized more first. Okay, see you in the next lesson.

Quiz: Reading Files Practice

在这里插入图片描述

Find and Compare Files

Welcome back to managing
Linux files and directories. In this last lesson, we’re
going to look at how we can find and compare files. We’ll start out here
with the Diff Command. The Diff Command
makes comparisons between two files, line by line. The example usage here is diff
file 1.txt and file 2.txt. The options are minus q, if
the files are different, it issues a simple
message expressing this, so that’s the quiet. I don’t want to see
all the reasons, I definitely just want to know if they’re the same or not. Minus r compares any
subdirectories within the original directory tree and consecutively compares their contents and the
subdirectories as well. You can compare directories and files and subdirectories
and get very deep. Minus y is going to display
the output in two columns. If I’m comparing two
files and I want to see their differences
side-by-side, I can use that minus y option.

在这里插入图片描述

We’ve seen the Which Command, remember when we talked about
system D and then in it, you could use Which,
it’s going to show you the full path name of a shell command passed
as an argument. The Which Command is also
handy for determining quickly, if a command is an alias. For example, if I
say, which diff, it tells me, /user /bin /diff. It tells me the full
location of the file.

在这里插入图片描述

We also have the Locate Command. This utility searches a
database that’s called, mlocate.db. It’s located in the
/var/lib/mlocate/ directory, and in that directory
it tries to see if the file exists on
the local file system. This is much faster because it can keep an updated
database of this directory. The example usage here
is locate myProject.txt, and it spits out that
myProject.txt is located in /home/aspeno/
my project.txt. There’s several options here, minus b displays only
file names that match the pattern and do not include any directory names
that match the pattern. Minus i ignores case in the pattern for
matching file names. Minus q does not display any error messages such as permission denied
when processing. If you’re re-coursing
through many directories and you don’t have permission
to read everything, you get a lot of these
permission denied, so the minus q is helpful here. Minus r will let use
the regular expression, instead of the pattern
list to match file names. We’ll talk a little bit more about regular
expressions but they’re very powerful ways and a standard way of
expressing patterns.

在这里插入图片描述

The Find Command allows
you to locate files based on data such as
who owns the file, when the file was last modified, the permission set on
the file, and so on. For example here,
I can say fine. minusname and I put
star.txt in quotes. What this is going to
do is it’s going to look in the current
directory for a file that starts with anything and has
the extension.txt. There’s several options
I include here, the minus capital P says
never follow symbolic links. This is the default. Minus capital L follows
the symbolic links. You can say dash name
and give it a pattern, it’s going to return true, if the base of a file
name the path with the leading directories removed matches the shell pattern. You could do dash GID, which displays the
name of the files whose group ID is equal to
some specific group ID. You could search for
permissions with a dash perm. You can search for
sizes with a dash size, and there’s lots of
human-readable suffixes like G for gigabytes. I’ll put some of
those in the reading. Dash user, displays the names
of files whose owner is some specific username.
A little review here. The Diff Command can be
used to compare two files, Locate is a simple command to discover the location of a file, and the Find Command has much more control than the
simpler pinpoint commands. I’ll see you in the lab
and we’ll go through a lot of these commands. Bye.

在这里插入图片描述

find 命令是在 Unix、Linux 和类 Unix 系统中用于查找文件和目录的强大工具。find 命令的基本语法如下:

find [路径] [表达式]

其中,路径 指定要搜索的目录路径,默认为当前目录。表达式 指定了要匹配的条件和要执行的操作。

find 命令常用的表达式包括:

  • -name:按文件名进行匹配。
  • -type:按文件类型进行匹配,如 f 表示普通文件,d 表示目录。
  • -size:按文件大小进行匹配,可以使用 +- 来指定大于或小于某个大小的文件。
  • -exec:对匹配的文件执行指定的命令。
  • -print:将匹配的文件打印到标准输出。

例如,要在当前目录及其子目录中查找名为 file.txt 的文件,可以使用以下命令:

find . -name file.txt

要查找所有大于 1MB 的普通文件,并打印它们的路径,可以使用以下命令:

find . -type f -size +1M -exec ls -l {} \;

这个命令将搜索当前目录及其子目录中所有大于 1MB 的普通文件,并使用 ls -l 命令打印这些文件的详细信息。

Quiz: Find and Compare Files Practice

在这里插入图片描述

Week 3 Lab

Use the slides from the 1st lesson reading and try each of the commands discussed in the cloud implementation of Linux. When you enter the cloud lab - please click the terminal menu and new terminal. This will give you a command line prompt in an Debian Linux shell.

Please try the commands we discussed this week:

  • ls
  • touch
  • ln
  • pr
  • grep
  • head
  • tail
  • which
  • find

Make sure you try the different command options we discussed

Quiz: Module 3

就是上面的quiz的集合,相同的问题。

Week 04: Search and Analyze Text

In the fourth module of this course, we will touch on how we can combine commands together in Linux to create automatons and build new tools.

Learning Objectives


  • Filter Text Files to Produce Modified Output
  • Redirect Standard Input, Standard Output and Standard Error
  • Pipe Fitter output together to create advanced automations
  • Use a text editor to modify a file

Welcome back to Linux fundamentals. This is the first course in
the Linux Foundation Specialization. In our last module of this course we’re
going to think about searching and analyzing text. This can allow us to combine commands
together to create automations and build new tools to help us
get our jobs done quicker. So by the time you’re done with this
module I want you to be able to do many things. Including filter text files, redirect
standard output, redirect standard input, redirect standard error, pipe commands
together, and then lastly edit text files. All right, so in this first lesson we
want to think about filtering text files. And what we mean by this is pulling out
parts of text files to the command line. So the first command we’re
going to see is the cut command. And the cut command is going to cut out
sections from each line of files and writes the results to standard output. There’s several options here. The dash c says display only
the record characters in the list. So I can say in the second example usage
I say cut dash c 1 to 5 from /etc/passwd, which means only show the first
five columns basically. The dash d designates a field delimiter. So in the example here dash d colon
is going to say pull out fields 1 and 7, that’s the dash f. It’s going to display specific
fields based on delimiter. So in the /etc/passwd we use
a colon to separate fields and we’re only going to cut out the first and
seventh column here. And so you can quickly see that
this becomes very powerful. Now what I didn’t tell you here is by
default the tab is the default delimiter in a file. But we use all kinds of things
like the colon or space or commas lots of different delimiters
to separate out data, okay?

在这里插入图片描述

cut 命令用于从文件的每一行中剪切文本字段并打印出来。它在处理以字段为单位而不是整行的文本文件时非常有用。cut 命令的基本语法如下:

cut OPTION... [FILE]

常用的选项包括:

  • -f:指定要剪切的字段。可以使用逗号分隔的字段列表,如 -f1,3,也可以使用连续字段范围,如 -f2-4
  • -d:指定字段分隔符,默认是制表符。
  • -c:按字符而不是字段来剪切。

例如,假设有一个名为 example.txt 的文件包含以下内容:

apple,orange,banana
cat,dog,rabbit

要从第一列中剪切字段,并将结果打印到标准输出,可以使用以下命令:

cut -d ',' -f1 example.txt

这将输出:

apple
cat

cut 命令还有其他选项和用法,可以通过 man cut 查看完整的帮助文档。

cut 命令中,-f1 表示要剪切的字段。具体来说,-f1 表示要剪切每一行的第一个字段。在指定 -f 选项时,可以使用逗号分隔的字段列表,以指定要剪切的多个字段,例如 -f1,3 表示剪切每一行的第一个和第三个字段。

We’ve seen the grep command before. We’re going to keep seeing it
because it’s very powerful. The grep command is going to use regular
expressions to filter text from files. So I’ve some examples here, if I say grep daemon dot asterisk
nologin from /etc/passwd. It’s going to show me all the lines
that include daemon as a word and nologin as a word with something zero
more characters between it, okay? Now this doesn’t mean
it starts with daemon, it doesn’t mean it ends with nologin. It just has to exist on each line, okay? Now we’ve got options. So, grep the carrot root says
show me all the lines that start with word root from /etc/passwd. And then I included many options below. So the uppercase E lets you designate
the pattern as what we call an extended regular expression and
we’ll talk about that in a minute. Dash i lets you ignore case on the search. Dash lowercase r searches
a directory’s contents for any subdirectory within
the original directory tree and consecutively searches
its contents as well. And dash v displays only text files
records that do not contain the pattern match. So it’s like a not true kind of thing.

在这里插入图片描述

All right, so basic regular expressions. Essentially these are easier, right? So we’ll start off with the asterisk. This represents multiple characters. I’m going to call that zero or more, okay? If we want to signify one character,
we do that with a single dot. So in the first one that we have a dot
asterisk which means one or more. So you can turn the zero or more into one
or more without having the dot, okay? Now the next one is to represent specific
characters by putting them in brackets. So in this example we have a,
comma e, comma i, comma o, comma u, which means any of those five characters. We can also represent a range with a dash. So here we’ve got the A to Z in brackets. We can represent characters
at the beginning of a line, we saw an example of that with the carrot. And we can represent them at
the end with the dollar sign.

在这里插入图片描述

BREs(Basic Regular Expressions,基本正则表达式)是一种用于文本模式匹配的简单正则表达式语法,通常用于 Unix 和类 Unix 系统中的工具,如 grep、sed 和 awk。BREs 提供了一组基本的元字符和操作符,用于匹配文本中的模式。

BREs 的一些基本元字符和操作符包括:

  • .:匹配任意单个字符。
  • *:匹配前一个字符的零个或多个副本。
  • []:字符类,匹配括号内的任何一个字符。
  • \:转义字符,用于匹配特殊字符。
  • ^:锚定字符,匹配行的开头。
  • $:锚定字符,匹配行的结尾。
  • \<\>:词边界,匹配单词的开头和结尾。

使用 BREs 可以进行简单的模式匹配和替换操作。例如,要在文件中查找包含 “hello” 的行,可以使用以下命令:

grep 'hello' filename

要将文件中所有的 “foo” 替换为 “bar”,可以使用 sed 命令:

sed 's/foo/bar/g' filename

需要注意的是,BREs 是一种相对简单的正则表达式语法,不支持一些高级特性,如非贪婪匹配、后向引用等。如果需要更强大的正则表达式功能,可以使用 EREs(Extended Regular Expressions,扩展正则表达式)或 PCREs(Perl Compatible Regular Expressions,Perl 兼容正则表达式)。

And again we’ll have more readings
on these regular expressions. Extended regular expressions. Remember you could pass in the dash E
to say you’re going to use an extended regular expression. It allows more complex
patterns than the basic. And mainly you’re combining
together possible options. So you can combine two or
more possible characters with the pipe and you can you can designate additional
sub expressions with parentheses, okay?

在这里插入图片描述

We also have the word count command which
displays the number of lines, words, or bytes in a file. So an example usage here is word
count dash IL, the I here uppercase I displays the files line count,
I guess it’s a lower case L. And an uppercase L displays the byte
count of the file’s longest line. And we’re going to pass in /proc/cpuinfo. There’s also an option with a dash m that
displays the file’s character count. All right.
A little review here, grep can use both basic
regular expressions and extended regular expressions. The asterisk in basic regular
expressions mean zero more characters. The dot means one character
in basic regular expressions. All right, see in the next lesson.

在这里插入图片描述

Read through the following command references for commands we discussed in this lesson:

  • cut - https://ss64.com/bash/cut.html

  • wc - https://ss64.com/bash/wc.html

Also check out this article on regular expressions in grep: https://linuxize.com/post/regular-expressions-in-grep/

Examples

Parse out column 2 from a semicolon (😉 delimited file:

$ cat myfile.txt | cut -d ; -f 2 > output.txt

这段命令的含义是从一个以分号 (;) 分隔的文件中解析出第二列,并将结果保存到 output.txt 文件中。

  • cat myfile.txt:使用 cat 命令读取 myfile.txt 文件的内容,并将其输出到标准输出。
  • |:管道符号,将 cat 命令的输出作为下一个命令的输入。
  • cut -d \; -f 2cut 命令用于剪切文本字段。-d \; 指定了字段的分隔符为分号 (;),-f 2 指定了要提取的字段为第二个字段。
  • > output.txt:重定向符号,将 cut 命令的输出重定向到 output.txt 文件中,而不是输出到终端。

因此,整个命令的作用是读取 myfile.txt 文件的内容,解析出其中的第二列,然后将第二列的内容保存到 output.txt 文件中。

Quiz: Filter Text Files Practice

在这里插入图片描述

Redirect Standard In, Out and Error

Welcome back to searching,
analyzing text and Lennox. In this lesson, we want to think about
redirecting our standard input output and error. You may say what does that to do
with searching and analyzing text. But you’ll see this
becomes very important for us to redirect or input to other commands. So it will become really a foundation for
later work. All right, so there are three
different descriptors that we use for standard output,
Standard input and Standard error. Standard output is a file descriptor
that’s either called one or standard out. What I mean by a file descriptor is
it looks like a file to our programs, so we can write to standard output
just like we’d write to a file. And standard out by default will send all
the information to the current terminal, which is also called dev/tty, okay. And the redirection operators allow you to
redirect standard output to another place. Typically that can be a file, so for
example, the greater than symbol will redirect the output from the command
before it to whatever you put after.

在这里插入图片描述

Standard error is a file
descriptor that I defended and identifies the error is to or STDERR. And so when a program is writing air
messages, it’s not going to send it to standard out, it’s going to send it to
a specific place, which is standard error. Which is really helpful because you can
redirect heirs to one location like an air log and
redirect output to another location. So standard error, by default is going to
send it to the same place as standard out which is the current terminal or
the dev/tty. An example of redirection is the two
greater than redirection operator, and this allows you to send it any place.

在这里插入图片描述

And then we have standard input, the file
descriptor that identifies input is zero or standard in and standard in
by default is going to receive its information from the keyboard or
another input device. And the redirection operator allows you to
redirect that standard in typically you’re taking the input from another command or
from a file and we’ll use the less than symbol
as a redirection operator.

在这里插入图片描述

Now I put a table in front of that shows
the common redirection operators and you’ll see there’s basically two. For standard out we have
the greater than or the double greater than the difference is
how it handles when we’re going to a file. So in the first one, the single
greater than symbol, if a file exists, it’s going to overwrite it. With the double if the file exists,
is going to append to, it’s going to write the data
to the end of the file. And then for standard error we have
the same idea with the two greater than or the two greater than greater than again
to greater than is going to overwrite the file to greater than greater
than is going to append to the file. And then there’s a special one which
is the ampersand greater than or ampersand greater than greater than. That’s going to redirect both standard out
and standard error in a single operator. Typically you don’t want this, typically
you want your errors to go someplace else but you can do it here and you have
the same idea with a single is going to override a file or
the double is going to append to it. And then with STDOUT we typically just use
one operator which is the lesson symbol. So whatever is on the right hand side
of the less than symbol will be sent as the input instead of the keyboard. Right cylinder, review her STDIN
is typically the keyboard and can be redirected from another command or
from a file. STDOUT is typically the console and can be
redirected to another command or a file. And STDERR is where messages
are sent by programs and typically you want that to be
someplace else and standard out. All right, I’ll see in the next lesson.

在这里插入图片描述

Quiz: Redirect Standard In, Out and Error Practice

在这里插入图片描述

Pipe & Filter

Welcome back to searching
and analyzing text in Linux. In this lesson,
we look at how to pipe and filter output together to create
advanced automations. We’ve already seen
how to filter text, and we can redirect
STDOUT, STDERR, and STDIN, between
multiple commands on one command line with
what’s called piping. The syntax is basically
command 1 pipe command 2. What that means is
the output from command 1 is sent to command 2, and you can add as many pipes. I got in brackets there,
piped dot-dot-dot, which means you
could have command 2 send its output to command 3. Instead of the output from
command 1 going to STDOUT, it will go to command 2.

在这里插入图片描述

在命令行环境中,管道符号 |(竖线)用于将一个命令的输出作为另一个命令的输入。通过管道,可以将多个命令连接起来,形成一个命令链,实现更复杂的操作。

例如,假设有一个包含文本的文件 example.txt,我们可以使用 cat 命令显示文件内容,并通过管道将输出传递给 grep 命令来过滤特定的行:

cat example.txt | grep "pattern"

这个命令首先使用 cat 命令显示 example.txt 文件的内容,然后将输出传递给 grep 命令,grep 命令会筛选出包含 “pattern” 的行,并将它们显示在终端上。

管道符号 | 可以连接任意数量的命令,允许对数据进行复杂的处理和转换。

There’s also the Tee command. The Tee command
redirects STDOUT to the current terminal and
a file simultaneously, because sometimes you
still want the output to a file or you still want
the output to the STDOUT, even though you’re
redirecting it to a file, so Tee’s your option. Here we’re going to do the
word count command of file 1. Text in our example
and then we’re going to pipe it’s output
to the Tee command, and we pass in the name of
the file with the -a option. The -a says: Do not overwrite the files
instead append them to the given file
that’s passed in. We can also add a.i to ignore
any interrupt signals, which if someone’s
trying to break a program with Control
C for example, we can ignore that thing.

在这里插入图片描述

We can also create what
are called Here Docs. You’ve seen in some
programming languages have the same idea
with comments. Essentially, this
allows you to redirect multiple items into
a single command. They take the form of
the double less-than, followed by an
end-of-data keyword, and you make up with the
end-of-data keyword. An example here, I’m taking the cat command and I’m
piping to the cat command the document that the
end-of-data word is add text so that same add text word is right after the
double less-than, but it’s also at the end. The ADD TEXT won’t be included, just that this text is added by here doc
will be included. All right, a little review. Piping takes the output of one command and sends it as
input to another command. The Tee command sends standard out to both terminal on a file. A Here Document allows redirection of multiple
items into a command. Here Docs can be way more complicated than
what I showed you, I just wanted you to get
the basics down for now.

在这里插入图片描述

Here documents(又称为here文档或here脚本)是一种在shell脚本中包含多行文本的方法,它允许你在脚本中嵌入大段的文本内容,而无需创建一个单独的文件。在shell脚本中,here document以<<开始,后跟一个标识符(通常是一个没有其他特殊含义的字符串),然后是多行文本内容,最后以标识符结尾。示例如下:

#!/bin/bash# 创建一个名为example.txt的文件,包含一些文本内容
cat << END > example.txt
This is an example file.
It contains multiple lines of text.
END

在这个例子中,<< END 告诉shell开始一个here document,并将其内容放入 example.txt 文件中。文本内容会一直持续到 END 出现为止,这时here document结束。注意,在 <<END 之间的文本会被写入到 example.txt 文件中。

Quiz: Pipe & Filter Practice

在这里插入图片描述

Editing Text Files

Hello and welcome
back to searching and analyzing text in Linux. In this final lesson
of the module, we’re going to think
about editing text files. Let’s start off
with text editors. Text editors allow you to edit a text file without storing formatting
inside the text file. What I mean by that is if
you’ve used Microsoft Word or Google Writer or lots of other Word processors in
the old days WordPerfect. I’m sure if people
still use WordPerfect. If you try to look at that file, it’s got formatting information
everywhere inside of it. That formatting is
often in binary format. Sometimes it’s an XML, but that’s not good when
we’re trying to write code, for example, sometimes
configuration files. Text editors don’t
store any formatting. There are many text editors
available for Linux, we will look at two of
them, Nano and Vim.

在这里插入图片描述

Nano, which is really GNU Nano, was designed to be
a free replacement for the Pico text editor. Now if you’ve never used
the Pico text editor, don’t worry about it. But a lot of people did, and it’s a good
replacement for people. Its usage is essentially Nano
and then the file name that will bring up the
editor that you see in the right-hand side. There are four main sections. You have a title bar, the main body of the text, a status bar, and a shortcut
list to make things faster. Next, we have Vim. Vim is a highly
configurable text editor. It is included as VI
with most Linux distros. VI is a very popular editor
that was used in Unix. A lot of the old Unix
people that they know VI. My first text editor
in Unix was VI. It’s very powerful if
you understand it. Vim is stable and is
continually being developed. Includes many features. Some of them include persistent
multi-level undo trees, meaning you can
undo lots of times. It has a big plug-in system, so people can write plug-ins without having access
to the source code. They do have access
to the source code because them is open-source, but they don’t
need to change it. The support for hundreds of programming languages
and file formats. It’s got a very powerful
search and replace, and it integrates with
many other tools.

在这里插入图片描述

Let’s drill in a little
bit to Vim usage, there are two ways to start. You can either type
Vim in the filename or VI in the filename. Then, once you’re in the editor, there are three modes,
you’re in command mode, where you’re essentially got
commands like searching and replacing or deleting
a line of text. Insert mode, so one
of the commands puts you in insert mode
where you can move around, and you can change text
and then exiting out. There are also stream editors, stream editors allow
you to edit text without having to
use a text editor. You’re normally going to do
this on the command line. Stream editor modifies
text that is passed to it via file or
output from a pipeline. We talked about pipe and
filter in a previous lesson. Here, stream acts as a filter where your
piping text to it, or you’re passing a file. The editor uses special
commands to make text changes as a text streams through the
editor utility. There’s two we’ll think
about, SED and AWK. GNU is called GAWK.

在这里插入图片描述

Sed. Sed is simpler. It reads one text line at a
time from the input stream, matches text with the
supplied editor commands, and modifies those
texts as specified in the commands that outputs
them to standard out. The example usage here
I have is I’m going to replace all occurrences
of Aspen with Seamus. Seamus is my son, and I’m going to replace
Olmsted with Moran-Olmsted. Basically, this is
like a chores list. He’s going to do all
my chores after this. We’ll see I’ve got two
different commands delimited by a semicolon. This is going to be done
in the file in file.txt, and we’re passing the -e option. The -e basically says, the commands are
going to be passed following that e.
You can also do a -f. Where you store
the commands in a file, and you specify the file
that has the Sed commands.

在这里插入图片描述

sed 是一个流编辑器,用于在文本流(或文件)中进行文本处理和转换。它可以实现在文本中搜索、替换、删除、插入等操作,功能强大且灵活,常用于 shell 脚本和命令行中。

sed 的基本语法为:

sed [选项] '动作' 文件名

其中,选项是可选的,可以用来指定编辑器的行为,例如 -e 可以指定多个编辑动作,-i 可以直接修改文件内容而不是在标准输出中显示结果。动作是 sed 命令要执行的操作,可以是替换、删除、插入等操作,也可以是正则表达式匹配等。

一些常用的 sed 操作包括:

  • 替换:s/old/new/,用 new 替换文本中第一次出现的 old
  • 全局替换:s/old/new/g,用 new 替换文本中所有的 old
  • 删除:d,删除匹配到的行。
  • 打印:p,打印匹配到的行。

例如,要将文件中所有的 “apple” 替换为 “orange”,可以使用 sed 命令:

sed 's/apple/orange/g' filename

sed 还支持正则表达式匹配、多行编辑等复杂操作,具有很高的灵活性和强大的功能。

Gawk again, remember
Gawk stands for GNU Awk. There are four main features. You can define variables
to store data. You can use
arithmetic and string operators to work on data. You can use programming
structures such as loops or add logic
to your processing. You can create formatted
reports from data. Let’s think about some
simple variables here. $0 represents the
entire line of text. $1 is a variable representing
the first data field. $2 is a second data field, all up to $n, which would be the
nth data field. My example here we’re
taking an input from a file, cake.text. Anytime the 4th field
is equal to Aspen, so we’ve got the if statement. The if statement is a test. If it’s true, we’re going to change that 4th
column to Seamus, and then we print out the line. A little review here. Vim is the VI implementation
in most Linux distros. Sed processes lines of
text and runs commands. Gawk command has many features of typical programming
languages, like loops and branches. That’s it. See you in the lab.

在这里插入图片描述

Read through the following command references for commands we discussed in this lesson:

  • vim - https://ss64.com/bash/vi.html
  • sed - https://ss64.com/bash/sed.html
  • gawk - https://ss64.com/bash/gawk.html

Quiz: Editing Text Files Practice

在这里插入图片描述

在这里插入图片描述

Week 4 Lab

Use the slides from the 1st lesson reading and try each of the commands discussed in the cloud implementation of Linux. When you enter the cloud lab - please click the terminal menu and new terminal. This will give you a command line prompt in an Debian Linux shell.

Please try out these commands from the week:

  • cut
  • wc
  • tee
  • nano
  • vim
  • sed
  • awk

Also try out these concepts:

  • Basic Regular Expressions
  • Extended Regular Expressions
  • Redirect Standard Output
  • Redirect Standard Error
  • Redirect Standard Input
  • Pipe and Filter
  • Here Documents

Quiz: Module 4

是前面的quiz的集合,这里不再赘述。

后记

2024年4月3日开始学习这门课,截至2024年4月4日花费2天完成之。复习了一下Linux的常见命令,同时学习到一些之前没用过的命令,比如cut, wc, tee, grep, pr。总之,这门课是这个Specialization的第一门课,后面还有3门课程,希望自己能够完成这个专项。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/793250.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

软件设计师27--规范化理论

软件设计师27--规范化理论 考点1&#xff1a;规范化理论基本概念函数依赖规范化理论--Amstrong公理体系候选键主属性与非主属性例题&#xff1a; 考点2&#xff1a;范式判断规范化理论规范化理论 - 范式例题&#xff1a; 考点3&#xff1a;范式分解保持函数依赖分解无损分解模式…

第14章 数据结构与集合源码

一 数据结构剖析 我们举一个形象的例子来理解数据结构的作用&#xff1a; 战场&#xff1a;程序运行所需的软件、硬件环境 战术和策略&#xff1a;数据结构 敌人&#xff1a;项目或模块的功能需求 指挥官&#xff1a;编写程序的程序员 士兵和装备&#xff1a;一行一行的代码 …

基于opencv的猫脸识别模型

opencv介绍 OpenCV的全称是Open Source Computer Vision Library&#xff0c;是一个跨平台的计算机视觉库。OpenCV是由英特尔公司发起并参与开发&#xff0c;以BSD许可证授权发行&#xff0c;可以在商业和研究领域中免费使用。OpenCV可用于开发实时的图像处理、计算机视觉以及…

【前端面试3+1】11 http和https有何不同及https的加密过程、数组有哪些方法及作用、tcp三次握手四次挥手、【分发饼干】

一、http和https有何不同&#xff1f;https的加密过程 1、不同&#xff1a; HTTP和HTTPS的主要区别在于安全性。HTTP是超文本传输协议&#xff0c;是一种用于传输数据的协议&#xff0c;但是传输的数据是明文的&#xff0c;容易被窃听和篡改。而HTTPS是在HTTP基础上加入了SSL/T…

【ORB-SLAM3】Ubuntu20.04 使用 RealSense D435i 运行 ORB-SLAM3 时遇到的一些 Bug

【ORB-SLAM3】使用 RealSense D435i 跑 ORB-SLAM3 时遇到的一些 Bug 1 hwmon command 0x80( 5 0 0 0 ) failed (response -7 HW not ready)2 No rule to make target /opt/ros/noetic/lib/x86_64-linux-gnu/librealsense2.so, needed by ../lib/libORB_SLAM3.so 1 hwmon comman…

力扣108. 将有序数组转换为二叉搜索树

Problem: 108. 将有序数组转换为二叉搜索树 文章目录 题目描述思路复杂度Code 题目描述 思路 根据二叉搜索树中序遍历为一个有序序列的特点得到&#xff1a; 1.定义左右下标left&#xff0c;right分别指向有序序列的头尾&#xff1b; 2.每次取出left和right的中间节点mid&…

电脑上怎么压缩图片?三个处理方法介绍

随着我们现在使用图片的地方越来越多&#xff0c;我们处理图片的情况也比较多了&#xff0c;通过压缩图片大小可以使图片文件更小&#xff0c;从而减少存储空间和带宽的使用&#xff0c;同时也可以提高加载速度和性能。良好的图片压缩可以有效地减少文件大小&#xff0c;同时保…

深入浅出 -- 系统架构之单体架构

单体架构&#xff08;Monolithic Architecture&#xff09; 单体架构的定义 单体架构&#xff08;Monolithic Architecture&#xff09;是一种传统的软件架构模式&#xff0c;将整个应用程序作为一个单一的、统一的单元进行开发、部署和扩展。在单体架构中&#xff0c;所有的功…

JSP

概念&#xff1a;Java Server Pages&#xff0c;Java服务端页面 一种动态的网页技术&#xff0c;其中既可以定义HTML、JS、CSS等静态内容&#xff0c;还可以定义Java代码的动态内容 JSP HTML Java 快速入门 注&#xff1a;Tomcat中已经有了JSP的jar包&#xff0c;因此我们…

【yy讲解PostCSS是如何安装和使用】

&#x1f3a5;博主&#xff1a;程序员不想YY啊 &#x1f4ab;CSDN优质创作者&#xff0c;CSDN实力新星&#xff0c;CSDN博客专家 &#x1f917;点赞&#x1f388;收藏⭐再看&#x1f4ab;养成习惯 ✨希望本文对您有所裨益&#xff0c;如有不足之处&#xff0c;欢迎在评论区提出…

Coursera上托福专项课程01:TOEFL Reading and Listening Sections Skills Mastery 学习笔记

TOEFL Reading and Listening Sections Skills Mastery Course Certificate 本文是学习 https://www.coursera.org/learn/toefl-reading-listening-sections-skills-mastery 这门课的笔记&#xff0c;如有侵权&#xff0c;请联系删除。 文章目录 TOEFL Reading and Listening …

AI绘图:Stable Diffusion ComfyUI局部重绘与智能扩图全面教程

前言 在数字艺术创作中&#xff0c;局部重绘和智能扩图是两个非常重要的功能。局部重绘允许我们在保留原有图像的基础上&#xff0c;对特定区域进行修改或创新。而智能扩图则能够帮助我们在图像的边缘添加新的元素&#xff0c;从而扩展图像的内容。本文将详细介绍如何在Stable…

卷积篇 | YOLOv8改进之引入全维度动态卷积ODConv | 即插即用

前言:Hello大家好,我是小哥谈。ODConv是一种关注了空域、输入通道、输出通道等维度上的动态性的卷积方法,一定程度上讲,ODConv可以视作CondConv的延续,将CondConv中一个维度上的动态特性进行了扩展,同时了考虑了空域、输入通道、输出通道等维度上的动态性,故称之为全维度…

深入理解C/C++的内存管理

在C和C中&#xff0c;高效的内存管理是编写性能优化和资源高效利用程序的关键。本文将深入探讨C/C内存管理的各个方面&#xff0c;包括内存的分布、C语言和C中的动态内存管理方式&#xff0c;以及new和delete操作符的使用 C/C内存分布 C和C程序的内存可以分为以下几个区域&…

Transformer学习: Transformer小模块学习--位置编码,多头自注意力,掩码矩阵

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 Transformer学习 1 位置编码模块1.1 PE代码1.2 测试PE1.3 原文代码 2 多头自注意力模块2.1 多头自注意力代码2.2 测试多头注意力 3 未来序列掩码矩阵3.1 代码3.2 测试掩码 1 …

简约轻量-失信录系统源码

失信录系统-最新骗子收录查询系统源码 首页查询&#xff1a; 举报收录页&#xff1a; 后台管理页&#xff1a; 失信录系统 V1.0.0 更新内容&#xff1a; 1.用户查询,举报功能 2.界面独立开发 3.拥有后台管理功能 4.xss,sql安全过滤 5.平台用户查询 6.用户中心&#xff08;待完…

Flume进阶学习!

本文图片来自于8.flume实时监控文件hdfs sink使用演示_哔哩哔哩_bilibili Apache Flume 的启动过程及其配置文件和脚本 在官网下载的Flume的压缩包中&#xff0c;.lib文件有大量的jar包&#xff0c;按道理说只有.lib文件就可以运行Flume程序了。只不过需要java -jar命令还要加…

第16章 网络编程

一 网络编程概述 Java是 Internet 上的语言&#xff0c;它从语言级上提供了对网络应用程序的支持&#xff0c;程序员能够很容易开发常见的网络应用程序。 Java提供的网络类库&#xff0c;可以实现无痛的网络连接&#xff0c;联网的底层细节被隐藏在 Java 的本机安装系统里&am…

C++:递增递减运算符(16)

递增递减就是自加1或者自减1 &#xff0c; 但是还有前置递增&#xff0c;后置递增&#xff0c;前置递减&#xff0c;后置递减&#xff0c;两者的区别也大有不同&#xff0c;接下来就去看一下过程 a1 b1baa2 b2a1 b1baa2 b1a2 b2b--aa1 b1a2 b2ba--a1 b2 递增 前置递增 #includ…

JAVA基础03-scanner,输出,循环,if的使用以及eclipse的安装

目录 scanner的使用 if语句的使用 eclipse的使用 switch语句的使用 输出方法的使用 循环语句 scanner的使用 实现用户数据的交互&#xff0c;用户通过终端输入数据 注意&#xff1a;使用Scanner需要导包 在程序开头加上&#xff1a;import java.util.Scanner; //由于S…