windows wiki

clean and backup windows

settings–system–about–(right)advan_system_setting

Click the Windows menu and type ‘Disk Cleanup’ in the search bar to get started.

To disable transparency effects, open the Windows menu and type ‘Make Start, taskbar and Action Center transparent’. This will pull up the Color Settings. From here you can choose to switch off transparency.

To reset your PC, go to Start > Settings > Update & Security > Recovery > Reset this PC > Get Started. Then, select Keep my files, choose cloud or local, change your settings, and set Restore preinstalled apps? to No.
One of the benefits of this new approach is that Windows attempts to recover from a previously created system image or – failing that – using a special series of install files that download the latest version of Windows during the reinstall process.

type: recovery drive into the search field on the taskbar and hit Enter. Or select the option to create from the results at the top or click Open from the app description section.

A system image is another way to say “full backup,” as it contains a copy of everything on the computer, including the installation, settings, apps, and files.
Quick note: You’ll also receive a prompt to create a system repair disc, but because most devices no longer include an optical drive, you can skip it. If you have to restore the machine, you can use a USB installation media to access the recovery enviroment.
Connect the drive with the full backup to the device.
Connect the Windows 10 USB bootable drive to the computer.
On the “Windows Setup” page, click the Next button.
Click the Repair your computer option from the bottom-left corner of the screen.
Click the Troubleshoot option.

The downside is that personal files and desktop apps won’t come along for the ride, but you should already be backing up your personal files separately. At the very least, a recovery drive wil bring Windows 10 back to a bootable and working state.
However, if preserving your personal files is absolutely necessary, a System Image Backup is another recovery option. This method allows you to create an image of your entire Windows environment, including your personal files and applications.

windows desktop management

multiple desktops

The idea of virtual desktops is straightforward: Instead of just a single desktop, you create a second, third, fourth, and so on. On each desktop, you arrange individual programs or combinations of apps you want to use for a specific task. Then, when it’s time to tackle one of those tasks,
you switch to the virtual desktop and get right to work.


windows snap

Drag the top window border (not the title bar) to the top edge of the screen, or drag the
bottom border to the bottom edge of the screen. With either action, when you reach the
edge, the window snaps to full height without changing its width. When you drag the
border away from the window edge, the opposite border snaps to its previous position.

Snap side-by-side Windows at different widths

The secret is to snap the first window and immediately drag its inside edge to adjust the
window to your preferred width. Now grab the title bar of the window you want to see
alongside it and snap it to the opposite edge of the display. The newly snapped window
expands to fill the space remaining after you adjusted the width of the first window.


Keyboard shortcuts and gestures for resizing and moving windows

Task Keyboard shortcut Gesture
Maximize window Windows key+ Up Arrow Drag title bar to top of screen
Resize window to full screen height without changing its width Shift+Windows key+Up Arrow Drag top or bottom border to edge of screen
Restore a maximized or full-height window Windows key+Down Arrow Drag title bar or border away from screen edge
Minimize a restored window Windows key+Down Arrow Click the Minimize button
Snap to the left half of the screen Windows key+Left Arrow* Drag title bar to left edge
Snap to the right half of the screen Windows key+Right Arrow* Drag title bar to right edge
Move to the next virtual desktop Ctrl+Windows key+Left/Right Arrow Three-finger swipe on precision touchpad; none for mouse
Move to the next monitor Shift+Windows Key+Left/Right Arrow Drag title bar
Minimize all windows except the active window (press again to restore windows previously minimized with this shortcut) Windows key+Home “Shake” the title bar
Minimize all windows Windows key+M
Restore windows after minimizing Shift+Windows key+M

disk management

Windows key+X Open the Quick Link menu
right click windows start icon

extend/shrink volumes
adjust the sizes of your partitions. increase or reduce the size of the seleted partition

扩展/压缩 卷

virtual file library
library is colletion of certain kinds of files based on a theme. they work in virtual manner: the files aren’t literally stored in these libraries, they are merely colloted and linked to the library.



taskbar jump lists

taskbar jump lists for quick access to documents and folders

a jump list is the official name of the menu that appears when you right-click to a taskbar button.
Each Jump List includes commands to open the program, to pin the program to the taskbar (or unpin it), and to close all open windows represented by the button.

In addition, for programs developed to take advantage of this feature, Jump Lists can include shortcuts to common tasks that can be performed with that program,

such as New Window or New InPrivate Window on a Microsoft Edge Jump List.

For Microsoft Office programs, Adobe Acrobat, and other similarly document-centric programs, Jump Lists also typically include links
to recently opened files.


font smoothing

using font smoothing to make text easier on the eyes

to check or change your font-somoothing settings, type cleartype in the search box and then click Ajust ClearType Text


performance

On modern hardware with even a moderate graphics processor, these options make little or
no difference in actual performance. The loss of animation can be disconcerting, in fact, as you
wonder where a particular item went when you minimized it. These options offer the most payoff on older devices with underpowered graphics hardware.

Alt text


file explore

Use the date navigator to zoom through time
If you click a date heading, the filter options display a date navigator like the one shown
next, with common date groupings available at the bottom of the list. You can also click
Select A Date Or Date Range and use the calendar to filter the file list that way

Alt text

Use check boxes to simplify file selection
File Explorer offers two modes of file and folder selection—with and without check boxes.
You can switch between them by means of the Item Check Boxes command on the View tab.
With check boxes on, you can select multiple items that are not adjacent to one another by
clicking or tapping the check box for each one in turn; to remove an item from the selection,
clear its check box. In either case, there’s no need to hold down the Ctrl key


To scrub a file of unwanted metadata, select one or more files in File Explorer, click
Home > Properties > Remove Properties.


Whatever text you type as a search term must appear at the beginning of a word, not in
the middle. Thus, entering des returns items containing the words desire, destination, and
destroy but not undesirable or saddest.

Search terms are not case sensitive. Thus, entering Bott returns items with Ed Bott as a tag
or property, but the results also include files containing the words bottom and bottle.

To search for an exact phrase, enclose the phrase within quotation marks. If you enter two
or more words without using quotes, the search results list includes items that contain all
of the words individually.

Alt text

Advanced queries support the following types of search parameters, which can be combined
using search operators:
● File contents. Keywords, phrases, numbers, and text strings
● Kinds of items. Folders, documents, pictures, music, and so on
● Data stores. Specific locations in the Windows file system containing indexed items
● File properties. Size, date, tags, and so on

Searching by item type or kind

To search for files with a particular file name extension, you can simply enter the extension in
the search box, like this:
.ext
(Note that this method of searching does not work for .exe or .msc files.) The results include files
that incorporate the extension in their contents as well as in their file names—which might or
might not be what you want. You’ll get a more focused search by using the ext: operator, including an asterisk wildcard and a period like this:
ext:
.txt

NOTE
As with many properties, you have more than one way to specify an exact file name
extension. In addition to ext:, you can use fileext:, extension:, or fileextension:.

File name extensions are useful for some searches, but you’ll get even better results using two
different search properties: Type and Kind. The Type property limits your search based on the
value found in the Type field for a given object. Thus, to look for files saved in any Microsoft
Excel format, type this term in the search box:
type:excel
To find any music file saved in MP3 format, type this text in the search box:
type:mp3
To constrain your search to groups of related file types, use the Kind property, in the syntax
kind:=value. Enter kind:=doc, for example, to return text files, Microsoft Office documents,
Adobe Acrobat documents, HTML and XML files, and other document formats. This search term
also accepts folder, pic, picture, music, song, program, and video as values to search for.

You can specify a folder or library location by using folder:, under:, in:, or path:. Thus,
folder:documents restricts the scope of the search to your Documents library, and in:videos mackie finds all files in the Videos library that contain Mackie in the file name or any property.

Searching for item properties

You can search on the basis of any property recognized by the file system. (The list of available
properties for files is identical to the ones we discuss in “Layouts, previews, and other ways to
arrange files” in Chapter 9.) To see the whole list of available properties, switch to Detail view in
File Explorer, right-click any column heading, and then click More. The Choose Details dialog
box that appears enumerates the available properties.
When you enter text in the search box, Windows searches file names, all properties, and indexed
content, returning items where it finds a match with that value. That often generates more
search results than you want. To find all documents of which Jean is the author, omitting documents that include the word Jean in their file names or content, you type author:jean in the
search box. (To eliminate documents authored by Jeanne, Jeannette, or Jeanelle, add an equal
sign and enclose jean in quotation marks: author:=”jean”.)
When searching on the basis of dates, you can use long or short forms, as you please. For example, the search values
modified:9/29/16
and
modified:09/29/2016
are equivalent. (If you don’t mind typing the extra four letters, use datemodified: instead.)
To search for dates before or after a particular date, use the less-than (<) and greater-than (>)
operators. For example,
modified:>09/30/2015
searches for dates later than September 30, 2015. Use the same two operators to specify file
sizes below and above some value.
Use two periods to search for items within a range of dates. To find files modified in September
or October 2016, type this search term in the Start menu search box:
modified:9/1/2016..10/31/2016
You can also use ranges to search by file size. The search filters suggest some common ranges
and even group them into neat little buckets, so you can type size: and then click Medium to
find files in the range 100 KB to 1 MB.
Again, don’t be fooled into thinking that this list represents the full selection of available sizes.
You can specify an exact size range—using operators such as >, >=, <, and <=. (Also, you can use
the “..” operator.) For example, size:0 MB..1 MB is the same as size:<=1 MB. You can specify
values using bytes, KB, MB, or GB.

Using multiple criteria for complex searches

You can use the Boolean operators AND, OR, and NOT to combine or negate criteria in the
search box. These operators need to be spelled in capital letters (or they will be treated as ordinary text). In place of the AND operator, you can use a plus sign (+), and in place of the NOT
operator, you can use a minus sign (–). You can also use parentheses to group criteria; items
in parentheses separated by a space use an implicit AND operator. Table 10-1 provides some
examples of combined criteria.
Table 10-1 Some examples of complex search values

This search value Returns
Siechert AND Bott Items in which at least one indexed element (property,file name, or an entire word within its contents) begins with or equals Siechert and another element in the same item begins with or equals Bott
title:(“report” NOT draft) Items in which the Title property contains the word report and does not contain a word that begins with draft
tag:tax AND author:Doug Items authored by Doug that include Tax in the Tags field
tag:tax AND author:(Doug OR Craig) AND modified:<1/1/18 Items authored by Doug or Craig, last modified before January 1, 2018, with Tax in the Tags field

NOTE

When you use multiple criteria based on different properties, an AND conjunction is
assumed unless you specify otherwise. The search value tag:Ed Author:Carl is equivalent
to the search value tag:Ed AND Author:Carl.

Using wildcards and character-mode searches

File-search wildcards can be traced back to the dawn of Microsoft operating systems, well
before the Windows era. In Windows 10, two of these venerable operators are alive and well:
● The asterisk (), also known as a star operator, can be placed anywhere in the search string
and will match zero, one, or any other number of characters. In indexed searches, which
treat your keyword as a prefix, this operator is always implied at the end; thus, a search for
voice turns up voice, voices, and voice-over. Add an asterisk at the beginning of the search
term (**voice
), and your search also turns up any item containing invoice or invoices. You
can put an asterisk in the middle of a search term as well, which is useful for searching
through folders full of data files that use a standard naming convention. If all your
invoices start with INV, followed by an invoice number, followed by the date (INV-0038-
20180227
, for example), you can produce a quick list of all 2018 invoices by searching for
INV*2018*.

● The question mark (?) is a more focused wildcard. In index searches, it matches exactly
one character in the exact position where it’s placed. Using the naming scheme defined
in the previous item, you can use the search term filename:INV-????-2018* to locate any
file in the current location that has a 2018 date stamp and an invoice number (between
hyphens) that is exactly four characters long.
To force Windows Search to use strict character matches in an indexed location, type a tilde (~)
as the first character in the search box, followed immediately by your term. If you open your
Documents library and type ~??v in the search box, you’ll find any document whose file name
contains any word that has a v in the third position, such as saved, level, and, of course, invoice.
This technique does not match on file contents.


Sharing files, printers, and other resources over a local network

Understanding sharing and security models in Windows

Much like Windows 7, Windows 10 offers two ways to share file resources, whether you’re doing
so locally or over the network:
● Public folder sharing. When you place files and folders in your Public folder or its subfolders, those files are available to anyone who has a user account on your computer.
Each person who signs in has access to his or her own profile folders (Documents, Music,
and so on), and everyone who signs in has access to the Public folder. (You need to dig a
bit to find the Public folder, which—unlike other profiles—doesn’t appear under Desktop
in the left pane of File Explorer. Navigate to C:\Users\Public. If you use the Public folder
often, pin it to the Quick Access list in File Explorer.)
By default, all users with an account on your computer can sign in and create, view, modify, and delete files in the Public folders. The person who creates a file in a Public folder (or
copies an item to a Public folder) is the file’s owner and has Full Control access. All others
who sign in locally have Modify access.
Settings in Advanced Sharing Settings (accessible from Settings > Network & Internet,
discussed in the next section) determine whether the contents of your Public folder are
made available on your network and whether entering a user name and password is
required for access. If you turn on password-protected sharing, only network users who
have a user account on your computer (or those who know the user name and password
for an account on your computer) can access files in the Public folder. Without passwordprotected sharing, everyone on your network has access to your Public folder files if you
enable network sharing of the Public folder.
You can’t select which network users get access, nor can you specify different access levels
for different users. Sharing via the Public folder is quick and easy—but it’s inflexible.
● Advanced sharing. By choosing to share folders or files outside the Public folder, you
can specify precisely which user accounts are able to access your shared data, and you
can specify the types of privileges those accounts enjoy. You can grant different access
privileges to different users. For example, you might enable some users to modify shared
files and create new ones, enable other users to read files without changing them, and
lock out still other users altogether.

You don’t need to decide between sharing the Public folder and sharing specific folders,
because you can use both methods simultaneously. You might find that a mix of sharing styles
works best for you; each has its benefits:
● Sharing specific folders is best for files you want to share with some users but not with
others—or if you want to grant different levels of access to different users
● Public folder sharing provides a convenient, logical way to segregate your personal documents, pictures, music, and so on from those you want to share with everyone who uses your
computer or your network.

Configuring your network for sharing

If you plan to share folders and files with other users on your network, you need to take a few preparatory steps. (If you plan to share only with others who use your computer by signing in locally,
you can skip these steps. And if your computer is part of a domain, some of these steps—or their
equivalent in the domain world—must be done by an administrator on the domain controller. We
don’t cover those details in this book.)

  1. Be sure that all computers use the same workgroup name. With modern versions of
    Windows, this step isn’t absolutely necessary, although it does improve network discovery
    performance.
  2. Be sure that your network’s location is set to Private. This setting makes it possible for
    other users to discover shared resources and provides appropriate security for a network in a
    home or an office. For details, see “Setting the network location,” earlier in this chapter.
  3. Be sure that Network Discovery is turned on. This should happen automatically when
    you set the network location to Private, but you can confirm the setting—and change it if
    necessary—in Advanced Sharing Settings, which is shown in Figure 13-18. To open Advanced
    Sharing Settings, go to Settings > Network & Internet; on the Status page, click Sharing Options.

Alt text

Figure 13-18 After you review settings for the Private profile, click the arrow by All Networks
(below Guest Or Public) to see additional options.

  1. Select your sharing options. In Advanced Sharing Settings, make a selection for each of
    the following network options. You’ll find the first option under the Private profile; to view
    the remaining settings, expand All Networks.
    ■ File And Printer Sharing. Turn on this option if you want to share specific files or
    folders, the Public folder, or printers; it must be turned on if you plan to share any
    files (other than media streaming) over your network.
    The mere act of turning on file and printer sharing does not expose any of your
    computer’s files or printers to other network users; that occurs only after you make
    additional sharing settings.
    ■ Public Folder Sharing. If you want to share items in your Public folder with all
    network users (or, if you enable password-protected sharing, all users who have a
    user account and password on your computer), turn on Public folder sharing. If you
    do so, network users will have read/write access to Public folders. With Public folder
    sharing turned off, anyone who signs in to your computer locally has access to Public folders, but network users do not.
    ■ Media Streaming. Turning on media streaming provides access to pictures, music,
    and video through streaming protocols that can send media to computers or to
    other media playback devices. In an era where most people stream their music
    collections from services like Spotify, this option is increasingly esoteric and nearly
    irrelevant.
    ■ File Sharing Connections. Leave this option set to 128-bit encryption, which has
    been the standard for most of this century.
    ■ Password Protected Sharing. When password-protected sharing is turned on,
    network users cannot access your shared folders (including Public folders, if shared)
    or printers unless they can provide the user name and password of a user account
    on your computer. With this setting enabled, when another user attempts to access
    a shared resource, Windows sends the user name and password that the person
    used to sign in to her own computer. If that matches the credentials for a local user
    account on your computer, the user gets immediate access to the shared resource
    (assuming permissions to use the resource have been granted to that user account).
    If either the user name or the password does not match, Windows asks the user to
    provide credentials.
    With password-protected sharing turned off, Windows does not require a user
    name and password from network visitors. Instead, network access is provided by
    using the Guest account. As we explain in Chapter 11, “Managing user accounts,
    passwords, and credentials,” this account isn’t available for interactive use but can
    handle these tasks in the background.
  2. Configure user accounts. If you use password-protected sharing, each person
    who accesses a shared resource on your computer must have a user account on your
    computer. Use a Microsoft account or, for a local account, use the same user name as
    that person uses on his or her own computer and the same password as well. If you do
    that, network users will be able to access shared resources without having to enter their
    credentials after they’ve signed in to their own computer.

Sharing files and folders from any folder

Whether you plan to share files and folders with other people who share your computer or
those who connect to your computer over the network (or both), the process for setting up
shared resources is the same as long as the Sharing Wizard is enabled. We recommend you use
the Sharing Wizard even if you normally disdain wizards. It’s quick, easy, and certain to make
all the correct settings for network shares and NTFS permissions—a sometimes-daunting task
if undertaken manually. After you configure shares with the wizard, you can always dive in and
make changes manually if you need to. (Although it’s possible to use the Advanced Sharing
options to configure network sharing independently of NTFS permissions, we don’t recommend
that technique and do not cover it in this edition.)
To be sure the Sharing Wizard is enabled, open File Explorer Options. (Type folder in the search
box, and then choose File Explorer Options. Or, in File Explorer, click View > Options.) In the dialog box that appears, shown next, click the View tab. Near the bottom of the Advanced Settings
list, see that Use Sharing Wizard (Recommended) is selected:

Alt text

With the Sharing Wizard at the ready, follow these steps to share a folder or files:

  1. In File Explorer, select the folders or files you want to share. (You can select multiple
    objects.)
  2. Right-click and choose Give Access To > Specific People. (In versions before 1709, the
    command is Share With.) Alternatively, click or tap the Share tab and then click Specific
    People in the Share With box. You might need to click the arrow in the Share With box to
    display Specific People. The File Sharing dialog box appears, as shown in Figure 13-19.

Alt text

Figure 13-19 For each name in the list other than the owner, you can click the arrow to set the
access level—or remove that account from the list.
3. In the entry box, enter the name or Microsoft account for each user with whom you want
to share. You can type a name in the box or click the arrow to display a list of available
names; then click Add. Repeat this step for each person you want to add.
The list includes all users who have an account on your computer, plus Everyone. Guest
is included if password-protected sharing is turned off. If you want to grant access to
someone who doesn’t appear in the list, click Create A New User, which takes you to User
Accounts in Control Panel.

NOTE
If you select Everyone and you have password-protected sharing enabled, the user
must still have a valid account on your computer. However, if you turned off passwordprotected sharing, network users can gain access only if you grant permission to
Everyone or to Guest.

  1. For each user, select a permission level. Your choices are
    ■ Read. Users with this permission level can view shared files and run shared programs, but they cannot change or delete files. Selecting Read in the Sharing Wizard is equivalent to setting NTFS permissions to Read & Execute.
    ■ Read/Write. Users assigned the Read/Write permission have the same privileges you do as owner: they can view, change, add, and delete files in a shared folder. Selecting Read/Write sets NTFS permissions to Full Control for this user.

    NOTE
    You might see other permission levels if you return to the Sharing Wizard after you set up sharing. Contribute indicates Modify permission. Custom indicates NTFS permissions other than Read & Execute, Modify, or Full Control. Mixed appears if you select multiple items and they have different sharing settings. Owner, of course, identifies the owner of the item.

  2. Click Share. After a few moments, the wizard displays a page like the one shown in Figure
    13-20.

  3. In the final step of the wizard, you can do any of the following:
    ■ Send an email message to the people with whom you’re sharing. The message
    includes a link to the shared items.
    ■ Copy the network path to the Clipboard. This is handy if you want to send a link via
    another application, such as a messaging app. (To copy the link for a single item in
    a list, right-click the share name and choose Copy Link.)
    ■ Double-click a share name to open the shared item.
    ■ Open File Explorer with your computer selected in the Network folder, showing
    each network share on your computer.
    When you’re finished with these tasks, click Done.

Alt text

Figure 13-20 The Sharing Wizard displays the network path for each item you shared.
Creating a share requires privilege elevation, but after a folder has been shared, the share is
available to network users no matter who is signed in to your computer—or even when nobody
is signed in.

Inside OUT
Use advanced sharing to create shorter network paths
Confusingly, when you share one of your profile folders (or any other subfolder of
%SystemDrive%\Users), Windows creates a network share for the Users folder—not for
the folder you shared. This behavior isn’t a security problem; NTFS permissions prevent
network users from seeing any folders or files except the ones explicitly shared. But it
does lead to some long Universal Naming Convention (UNC) paths to network shares.
For example, sharing the PDW subfolder of Documents (as shown in Figure 13-16) creates the network path \CARL-SURFACE\Users\Carl\Documents\PDW. If this same folder
had been anywhere on your computer outside the Users folder, no matter how deeply
nested, the network path would instead be \CARL-SURFACE\PDW. Other people to
whom you granted access wouldn’t need to click through a series of folders to find the
files in the intended target folder.
Network users, of course, can map a network drive or save a shortcut to your target
folder to avoid this problem. But you can work around it from the sharing side, too: Use
advanced sharing to share the folder directly. (Do this after you’ve used the Sharing
Wizard to set up permissions.) And while you’re doing that, be sure the share name you
create doesn’t have spaces. Eliminating them makes it easier to type a share path that
works as a link.

Stopping or changing sharing of a file or folder

If you want to stop sharing a particular shared file or folder, select it in File Explorer and on the
Share tab, click Remove Access (Stop Sharing in versions before 1709). Or right-click and choose
Give Access To > Remove Access. Doing so removes access control entries that are not inherited.
In addition, the network share is removed; the folder will no longer be visible in another user’s
Network folder.
To change share permissions, right-click and choose Give Access To > Specific People. In the
File Sharing dialog box (shown earlier in Figure 13-15), you can add users, change permissions,
or remove users. (To stop sharing with a user, click the permission level by the user’s name and
choose Remove.)

Working with mapped network folders

Mapping a network folder makes it appear to applications as though the folder is part of your
own computer. Windows assigns a drive letter to the mapped folder, making the folder appear
like an additional hard drive. You can still access a mapped folder in the conventional manner by navigating to it through the Network folder. But mapping gives the folder an alias—the
assigned drive letter—that provides an alternative means of access.
To map a network folder to a drive letter, follow these steps:

  1. Open This PC in File Explorer, and on the ribbon’s Computer tab, click Map Network Drive.
    (Alternatively, after you open a computer in the Network folder, right-click a network
    share and choose Map Network Drive.)

    Alt text

  2. Select a drive letter from the Drive list. You can choose any letter that’s not already in use.

  3. In the Folder box, type the path to the folder you want or, more easily, click Browse and
    navigate to the folder.

  4. Select Reconnect At Sign-In if you want Windows to connect to this shared folder
    automatically at the start of each session.

  5. If your regular sign-in account doesn’t have permission to connect to the resource, select
    Connect Using Different Credentials. (After you click Finish, Windows asks for the user
    name and password you want to use for this connection.)

  6. Click Finish.
    In File Explorer, the “drive” appears under This PC.
    If you change your mind about mapping a network folder, right-click the folder’s icon in your
    This PC folder. Choose Disconnect on the resulting shortcut menu, and the connection will be
    severed.

Connecting to a network printer

To use a printer that has been shared, open the Network folder in File Explorer and double-click
the name of the server to which the printer is attached. If the shared printers on that server
are not visible, return to the Network folder, click to select the server, and then, on the ribbon’s
Network tab, click View Printers. Right-click the printer and choose Connect. Alternatively, from
the Devices And Printers folder, click Add A Printer and use the Add Printer Wizard to add a network printer.


disk part

UNDERSTANDING DISK-MANAGEMENT TERMINOLOGY

The current version of Disk Management has simplified somewhat the arcane language of
disk administration. Nevertheless, it’s still important to have a bit of the vocabulary under
your belt. The following terms and concepts are the most important:
● Volume. A volume is a disk or subdivision of a disk that is formatted and available
for storage. If a volume is assigned a drive letter, it appears as a separate entity in File
Explorer. A hard disk can have one or more volumes.
● Mounted drive. A mounted drive is a volume that is mapped to an empty folder on
an NTFS-formatted disk. A mounted drive does not get a drive letter and does not
appear separately in File Explorer. Instead, it behaves as though it were a subfolder on
another volume.
● Basic disk and dynamic disk. The two principal types of hard-disk organization in
Windows are called basic and dynamic:
■ A basic disk can be subdivided into as many as four partitions. (Disks that
have been initialized using a GUID Partition Table can have more than four.)
All volumes on a basic disk must be simple volumes. When you use Disk Management to create new simple volumes, the first three partitions it creates are
primary partitions. The fourth is created as an extended partition using all
remaining unallocated space on the disk. An extended partition can be organized into as many as 2,000 logical disks. In use, a logical disk behaves exactly
like a primary partition.
■ A dynamic disk offers organizational options not available on a basic disk. In
addition to simple volumes, dynamic disks can contain spanned or striped
volumes. These last two volume types combine space from multiple disks. We
expect that very few of our readers will ever use dynamic disks.
● Simple volume. A simple volume is a volume contained entirely within a single
physical device. On a basic disk, a simple volume is also known as a partition.
● Spanned volume. A spanned volume is a volume that combines space from physically separate disks, making the combination appear and function as though it were a
single storage medium.
● Striped volume. A striped volume is a volume in which data is stored in 64-KB strips
across physically separate disks to improve performance.
● Active partition, boot partition, and system partition. The active partition is the
one from which an x86-based computer starts after you power it up. The first physical hard disk attached to the system (Disk 0) must include an active partition. The
boot partition is the partition where the Windows system files are located. The system partition is the partition that contains the bootstrap files that Windows uses to
start your system and display the boot menu.


Beginning with version 1703, Windows 10 includes new display code that improves rendering for some older desktop apps that previously looked a little blurry on high-DPI displays. If
you notice that a desktop program isn’t scaling properly, you can use another new option that
debuted in version 1703 to change its behavior. Find the program’s executable file, right-click to
open its properties dialog box, click Change High DPI Settings on the Compatibility tab, select
the Override High DPI Scaling Behavior setting, and change it to System (Enhanced). This setting overrides the way the selected program handles DPI scaling, eliminating the use of bitmap
stretching and forcing the application to be scaled by Windows:

Alt text

Windows 10 supports scaling factors from 100 percent all the way to 450 percent, with most elements of the user interface looking crystal-clear even at the highest scaling levels. That includes
Start, Cortana, File Explorer, and the Windows taskbar.

Windows registry

The Windows registry is the central storage location that contains configuration details for
hardware, system settings, services, user customizations, applications, and every detail—large
and small—that makes Windows work.

Understanding the Registry Editor hierarchy

Registry Editor (Regedit.exe) offers a unified view of the registry’s contents as well as tools for
modifying its contents. You’ll find this important utility on the All Apps list, under the Windows
Administrative Tools category. It also shows up when you use the search box. Alternatively, you
can type regedit at a command prompt or in the Run dialog box. Registry Editor has been virtually unchanged since the last century. However, beginning in version 1703, you might have
noticed some small but long-needed improvements: an address bar, new keyboard shortcuts
for traversing the registry, and the addition of a View-menu command with which you can
select the font for displaying the registry.
Figure 19-5 shows a (mostly) collapsed view of the Windows 10 registry, as seen through Registry Editor.
The Computer node appears at the top of the Registry Editor tree listing. Beneath it, as shown
here, are five root keys: HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE,
HKEY_USERS, and HKEY_CURRENT_CONFIG. For simplicity’s sake and typographical convenience, this book, like many others, abbreviates the root key names as HKCR, HKCU, HKLM,
HKU, and HKCC, respectively.
Root keys, sometimes called predefined keys, contain subkeys. Registry Editor displays this structure in a hierarchical tree in the left pane. In Figure 19-5, for example, HKLM is open, showing its
top-level subkeys.

Alt text
Figure 19-5 The registry consists of five root keys, each of which contains many subkeys.

Subkeys, which we call keys for short, can contain subkeys of their own, which in turn can
be expanded as necessary to display additional subkeys. The address bar near the top of the
Registry Editor window shows the full path of the currently selected key: Computer\HKLM
HARDWARE\DESCRIPTION\System\BIOS, in the previous figure.

NOTE
One of the Registry Editor changes introduced in version 1703 is the address bar. In it,
you can type a registry path and press Enter to jump directly to that key, much as you
can for jumping to a folder in File Explorer. For the root keys, you can type the full name
or the commonly used abbreviations described earlier.

To go to the address bar and select its current content, press Alt+D or Ctrl+L, the same
keyboard shortcuts that work in File Explorer as well as most web browsers. Previous
versions of Registry Editor displayed the path in a status bar at the bottom of the screen,
but you couldn’t edit it or select it for copying.

The contents of HKEY_LOCAL_MACHINE define the workings of Windows itself, and its subkeys
map neatly to several hives we mentioned at the start of this section. HKEY_USERS contains an
entry for every existing user account (including system accounts), each of which uses the security identifier, or SID, for that account.

The remaining three predefined keys don’t exist, technically. Like the file system in Windows—
which uses junctions, symlinks, and other trickery to display a virtual namespace—the registry
uses a bit of misdirection (implemented with the REG_LINK data type) to create these convenient representations of keys that are actually stored within HKEY_LOCAL_MACHINE and
HKEY_USERS:
● HKEY_CLASSES_ROOT is merged from keys within HKLM\Software\Classes and HKEY_
USERS\sid_Classes (where sid is the security identifier of the currently signed-in user).
● HKEY_CURRENT_USER is a view into the settings for the currently signed-in user account,
as stored in HKEY_USERS\sid (where sid is the security identifier of the currently signed-in
user).
● HKEY_CURRENT_CONFIG displays the contents of the Hardware Profiles\Current subkey
in HKLM\SYSTEM\CurrentControlSet\Hardware Profiles.
Any changes you make to keys and values in these virtual keys have the same effect as if you
had edited the actual locations. The HKCR and HKCU keys are generally more convenient to use.

Registry values and data types

Every key contains at least one value. In Registry Editor, that obligatory value is known as the
default value. Many keys have additional values. The names, data types, and data associated
with values appear in the right pane.

The default value for many keys is not defined. You can think of an empty default value as a
placeholder—a slot that could hold data but currently does not.

All values other than the default always include the following three components: name, data
type, and data. Figure 19-6, for example, shows customized settings for the current user’s
lock screen. (Note the full path to this key in the address bar at the top of the Registry Editor
window.)

The SlideshowEnabled value (near the bottom of the list) is of data type REG_DWORD. The
data associated with this value (on the system used for this figure) is 0x00000000. The prefix 0x
denotes a hexadecimal value. Registry Editor displays the decimal equivalent of hexadecimal
values in parentheses after the value.

Alt text

Selecting a key on the left displays all its values on the right.
The registry uses the following data types:
● REG_SZ. The SZ indicates a zero-terminated string. This variable-length string can contain
Unicode as well as ANSI characters. When you enter or edit a REG_SZ value, Registry Editor terminates the value with a 00 byte for you.
● REG_BINARY. The REG_BINARY type contains binary data—0s and 1s.
● REG_DWORD. This data type is a “double word”—that is, a 32-bit numeric value.
Although it can hold any integer from 0 to 232, the registry often uses it for simple Boolean values (0 or 1) because the registry lacks a Boolean data type.
● REG_QWORD. This data type is a “quadruple word”—a 64-bit numeric value.
● REG_MULTI_SZ. This data type contains a group of zero-terminated strings assigned to a
single value.
● REG_EXPAND_SZ. This data type is a zero-terminated string containing an unexpanded
reference to an environment variable, such as %SystemRoot%. (For information about
environment variables, see “Interacting with PowerShell” earlier in this chapter.) If you
need to create a key containing a variable name, use this data type, not REG_SZ.

Internally, the registry also uses REG_LINK, REG_FULL_RESOURCE_DESCRIPTOR, REG_
RESOURCE_LIST, REG_RESOURCE_REQUIREMENTS_LIST, and REG_NONE data types. Although you might occasionally see references in technical documentation to these data types, they’re
not visible or accessible in Registry Editor

Identifying the elements of a .reg file

As you review the examples shown in the two figures, note the following characteristics of .reg
files:
● Header line. The file begins with the line “Windows Registry Editor Version 5.00.” When
you merge a .reg file into the registry, Registry Editor uses this line to verify that the file
contains registry data. Version 5 (the version used with Windows 7 and later versions,
including Windows 10) generates Unicode text files, which can be used with all supported
versions of Windows as well as the now-unsupported Windows XP and Windows 2000.
● Key names. Key names are delimited by brackets and must include the full path from the
root key to the current subkey. The root key name must not be abbreviated. (Don’t use
HKCU, for example.) Figure 19-7 shows only one key name, but you can have as many as
you want.
● The default value. Undefined default values do not appear in .reg files. Defined default
values are identified by the special character @. Thus, a key whose default REG_SZ value
was defined as MyApp would appear in a .reg file this way:
“@”=”MyApp”
● Value names. Value names must be enclosed in quotation marks, whether or not they
include space characters. Follow the value name with an equal sign.

● Data types. REG_SZ values don’t get a data type identifier or a colon. The data directly
follows the equal sign. Other data types are identified as shown in Table 19-5.
Table 19-5 Data types identified in .reg files
Data type | Identifier
REG_BINARY | hex
REG_DWORD | dword
REG_QWORD | hex(b)
REG_MULTI_SZ | hex(7)
REG_EXPAND_SZ | hex(2)
A colon separates the identifier from the data. Thus, for example, a REG_DWORD value
named “Keyname” with value data of 00000000 looks like this:
“Keyname”=dword:00000000
● REG_SZ values. Ordinary string values must be enclosed in quotation marks. A backslash
character within a string must be written as two backslashes. Thus, for example, the path
C:\Program Files\Microsoft Office\ is written like this:
“C:\Program Files\Microsoft Office\“
● REG_DWORD values. DWORD values are written as eight hexadecimal digits, without
spaces or commas. Do not use the 0x prefix.
● All other data types. Other data types—including REG_EXPAND_SZ, REG_MULTI_SZ,
and REG_QWORD—appear as comma-delimited lists of hexadecimal bytes (two hex
digits, a comma, two more hex digits, and so on). The following is an example of a REG_
MULTI_SZ value:
“Addins”=hex(7):64,00,3a,00,5c,00,6c,00,6f,00,74,00,00,75,00,73,00,5c,00,
31,00,32,00,33,00,5c,00,61,00,64,00,64,00,64,00,69,00,6e,00,73,00,5c,00,
64,00,71,00,61,00,75,00,69,00,2e,00,31,00,32,00,61,00,00,00,00,00,00,00
● Line-continuation characters. You can use the backslash as a line-continuation character. The REG_MULTI_SZ value just shown, for example, is all one stream of bytes. We
added backslashes and broke the lines for readability, and you can do the same in your
.reg files.
● Line spacing. You can add blank lines for readability. Registry Editor ignores them.
● Comments. To add a comment line to a .reg file, begin the line with a semicolon.

如何卸载windows的服务?卸载服务?

找到一个需要卸载的服务

双击打开

Alt text

如何我们需要复制下来这个服务的名称

Alt text

然后再cmd下输入 sc delete 服务名称来卸载服务

输入完成之后回车即可

卸载完成

Alt text

安装到服务器的Windows Service卸载的时候出错了,结果在服务列表中就一直驻留,并且系统进程一直在运行,怎么都杀不掉。

最后终于找到办法了:

1.常规做法,批处理命令卸载

Net Stop ServiceName
sc delete ServiceName
pause

2.如果还是没办法,那就继续尝试

a.找到系统注册表,删掉服务的注册表信息,通常路径在:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services 找到你的Service服务的名字,然后把整个文件夹删掉

b.如果还是在继续运行,service列表中还显示的话,用管理员权限打开cmd 命令 sc delete serviceName,如果提示 “the specified service is marked as deletion”。

导致windows service不能部署,也不能被删除,使用 SC 命令也不奏效。确实冒了一把冷汗。经过10几分钟的折腾,终于弄明白了:原来是windows service database缓存的原因,reboot server可以完美解决问题。但实际上我们可以尝试:

  1. 关闭所有windows service控制面板。

  2. 查找windows service的PID:SC queryex service_name

  3. 杀掉进程:taskkill /PID service_pid /f

这样就再也不用担心windows service部署了。

至此就可以完全卸载掉了。

Win10的序列号查询

本机的Win10的序列号很容易查出来,按“Win”+ “R”,运行powershell,然后执行以下命令:
(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey

输入法

半角状态就是说输入法状态条中,那半月形变为圆形时为全角这时输入的英文字母及数字与汉字等大,半角当然是输入法状态条中为半月形时的状态了,这时输入的英文字母及数字不与汉字等大为汉字一半(全角占用两个字节)。

Cygwin

Cygwin是一个在windows平台上运行的类UNIX模拟环境,是Cygnus Solutions公司开发的自由软件(该公司开发的著名工具还有eCos,不过现已被Redhat收购)。它对于学习UNIX/Linux操作环境,或者从UNIX到Windows的应用程序移植,或者进行某些特殊的开发工作,尤其是使用GNU工具集在Windows上进行嵌入式系统开发,非常有用。随着嵌入式系统开发在国内日渐流行,越来越多的开发者对Cygwin产生了兴趣。

基于 LDAP 的 AD 域服务器搭建及其使用

1.1 AD 域服务

什么是目录(directory)呢?

日常生活中使用的电话薄内记录着亲朋好友的姓名、电话与地址等数据,它就是 telephone directory(电话目录);计算机中的文件系统(file system)内记录着文件的文件名、大小与日期等数据,它就是 file directory(文件目录)。

如果这些目录内的数据能够由系统加以整理,用户就能够容易且迅速地查找到所需的数据,而 directory service(目录服务)提供的服务,就是要达到此目的。在现实生活中,查号台也是一种目录;在 Internet 上,百度和谷歌提供的搜索功能也是一种目录服务。

Active Directory 域内的 directory database(目录数据库)被用来存储用户账户、计算机账户、打印机和共享文件夹等对象,而提供目录服务的组件就是 Active Directory (活动目录)域服务(Active Directory Domain Service,AD DS),它负责目录数据库的存储、添加、删除、修改与查询等操作。一般适用于一个局域网内。

在 AD 域服务(AD DS)内,AD 就是一个命名空间(Namespace)。利用 AD,我们可以通过对象名称来找到与这个对象有关的所有信息。

在 TCP/IP 网络环境内利用 Domain Name System(DNS)来解析主机名与 IP 地址的对应关系,也就是利用 DNS 来解析来得到主机的 IP 地址。除此之外,AD 域服务也与 DNS 紧密结合在一起,它的域命名空间也是采用 DNS 架构,因此域名采用 DNS 格式来命名,例如可以将 AD 域的域名命名为 moonxy.com。

1.2 AD域对象与属性

AD 域内的资源以对象(Object)的形式存在,例如用户、计算机与打印机等都是对象,而对象则通过属性(Attriburte)来描述其特征,也就是说对象本身是一些属性的集合。例如,创建一个账户张三,则必须添加一个对象类型(object class)为用户的对象(也就是用户账户),然后在这个用户账户内输入张三的姓名、登录账户、电话号码和电子邮件等信息,这其中的用户账户就是对象,而姓名、登录账户等数据就是该对象的属性,张三就是对象类型为用户(user)的对象。

1.3 AD 域控制器 DC

AD 域服务(AD DS)的目录数据存储在域控制器(Domain Controller,DC)内。一个域内可以有多台域控制器,每台域控制器的地位几乎是平等的,它们各自存储着一份几乎完全相同的 Active Directory。当在任何一台域控制器内添加了一个用户账户后,此账户默认被创建在此域控制器的 Active Directory,之后会自动被复制(replicate)到其他域控制器的 Active Directory,以便让所有域控制器内的 Active Directory 数据都能够同步(synchronize)。

当用户在域内某台计算机登录时,会由其中一台域控制器根据其 Active Directory 内的账户数据,来审核用户输入的账户与密码是否正确。如果是正确的,用户就可以登录成功;反之,会被拒绝登录。域控制器是由服务器级别的额计算机来扮演的,例如 Windows Server 2012 和 Windows Server 2008 R2 等。

通常,域控制器的 Active Directory 数据库是可以被读写的,除此之外,还有 Active Directory 数据库是只可以读取、不可以被修改的只读域控制器(Read-Only Domain Controller,RODC)。例如,某子公司位于远程网络,如果安全措施并不像总公司一样完备,则可以使用 RODC。

1.4 LDAP

LDAP(Lightweight Directory Access Protocol),轻量目录访问协议,是一种用来查询与更新 Active Directory 的目录服务通信协议。AD 域服务利用 LDAP 命名路径(LDAP naming path)来表示对象在 AD 内的位置,以便用它来访问 AD 内的对象。

LDAP 数据的组织方式:

Alt text

LDAP 名称路径如下:

Alt text

标识名称(distinguished Name,DN):它是对象在 Active Directory 内的完整路径,DN 有三个属性,分别是 CN,OU,DC。

DC (Domain Component):域名组件;

CN (Common Name):通用名称,一般为用户名或计算机名;

OU (Organizational Unit):组织单位;

例如,如上用户账户,其 DN 为:

CN=张三,OU=Web前端组,OU=软件开发部,DC=moonxy,DC=com

其中 DC(Domain Component)表示 DNS 域名中的组件,例如 moonxy.com 中的 moonxy 与 com;OU为组织单位(Organization Unit);CN为通用名称(Common Name),一般为用户名或服务器名。除了DC与OU之外,其他都利用CN来表示,例如用户与计算机对象都属于CN。上述DN表示法中的 moonxy.com 为域名,软件研发部、Web前端组都是组织单位。此 DN 表示账户张三存储在 moonxy.com\软件研发部\Web前端组路径中。

相对标识名称(Relative Distinguished Name,RDN):RDN用来代表DN完整路径中的部分路径,例如上面路径中的 CN=张三与 OU=Web前端组等都是 RDN。

Base DN:LDAP 目录树的最顶部就是根,也就是所谓的 “Base DN”,如 “DC=moonxy,DC=com”。

除了 DN 与 RDN 这两个对象名称外,另外还有如下两个名称:

全局唯一标识符(Global Unique Identifier,GUID):GUID 是一个128位的数值,系统会自动为每个对象指定一个唯一的GUID。虽然可以改变对象的名称,但是其GUID永远不会改变。

用户主体名称(User Principal Name,UPN):每个用户还可以有一个比DN更短、更容易记忆的 UPN,例如上面的张三隶属于 moonxy.com,则其 UPN 可以为 zhangsan@moonxy.com。用户登录时所输入的账户名最好是 UPN,因为无论此用户的账户被移动到哪一个域,其 UPN 都不会改变,因此用户可以一直使用同一个名称来登录。

AD 与 LDAP 的关系:LDAP 是一种用来访问 AD 数据库的目录服务协议,AD DS 会通过 LDAP 名称路径来表示对象在 AD 数据库中的位置,以便用它来访问 AD 数据库内的对象。LDAP 的名称路径包括有 DN、RDN。

openLDAP(Linux),Active Directory(Microsoft)等是对 LDAP 目录访问协议的具体实现,除了实现协议的功能,还对它进行了扩展。

1.5 全局编录

虽然在域树内的所有域共享一个 Active Directory,但是 Active Directory 数据却分散在各个域内,而每个域仅存储该域本身的数据。因此,为了让用户、应用程序能够快速找到位于其他域内的资源,在 AD 域服务器内设计了全局编录(Global Catalog,GC)。

全局编录的数据存储在域控制器内,这台域控制器被称为全局编录服务器,它存储着林内所有域的 AD 内的每个对象。不过只存储对象的部分属性,这些属性都是常用来搜索的属性,例如用户的电话号码、登录账户名等。全局编录让用户即使不知道对象位于哪一个域内,仍然可以快速的找到所需的对象。

用户登录时,全局编录服务器还负责提供该用户所属的通用组的信息;用户利用 UPN 登录时,它会负责提供该用户隶属于哪一个域的信息。

一个林内的所有域树共享相同的全局编录,而林内的第一台域控制器默认就是全局编录服务器。必要时,也可以另外指派其他域控制器来当做全局编录服务器。

VMWare window server修改密码

VMWare——window server 2008/2012 administrator 密码忘记,设置重置密码
用VMWare安装window server 2008或者2012忘记密码后,想要修改密码满麻烦的。

以下过程是我成功修改密码的过程:

1.首先需要需要链接一个ISO文件

Alt text

需要特别注意把“启用连接”勾上,这个地方坑了我好长时间。不勾上,系统启动没办法CD-ROM Drive进入的。

2.关闭虚拟机。以下面的方式打开虚拟机:

Alt text

3进入BIOS界面—>选择Boot:确保启动方式是以CD-ROM Driver

Alt text

4.然后重新启动。重新启动后,会进入到安装系统界面。

Alt text

5.点击下一步,在下一个界面左下面,第一行:Repair your computer(修复你的计算机),点击这个;

Alt text

6.之后会进入到选择界面,选择Troubleshoot(故障排除):

Alt text

7.之后新的界面Advanced options(高级选项),选择Command Prompt(命令提示)选项:

Alt text

8.这个时候会出现一个命令提示框,需要输入以下命令:

d:(注:根据实际情况,系统盘文件放置的位置)
cd windows\system32
ren Utilman.exe Utilman.exe.old
copy cmd.exe Utilman.exe

Alt text

Alt text

8.关闭命令提示框,点击Continue(继续);当出现欢迎界面,点击Windows key +U:

Alt text

9.出现命令,输入以下命令:net user administrator “new password”,关闭提示框,这个时候就可以使用你新设的密码登录了。

Alt text

以上步骤成功修改了vmware虚拟机window server 2008/2012的密码。

VMware网络连接模式

VMware网络连接模式——桥接模式、NAT模式以及仅主机模式的介绍和区别
  在使用VMware Workstation(以下简称:VMware)创建虚拟机的过程中,配置虚拟机的网络连接是非常重要的一环,当我们为虚拟机配置网络连接时,我们可以看到如下图所示的几种网络连接模式:桥接模式、NAT模式、仅主机模式、自定义网络连接模式。那么这几种网络连接模式都各自有什么主要用途,它们之间又有哪些区别呢?

Alt text

  磨刀不误砍柴工,为了更好地使用虚拟机,了解这几种连接模式的主要用途以及它们之间的区别是非常有必要的。在这里,我们就以下面的网络连接示意图为例来进行相关介绍。

Alt text

  在VMware中,虚拟机的网络连接主要是由VMware创建的虚拟交换机(也叫做虚拟网络)负责实现的,VMware可以根据需要创建多个虚拟网络。在Windows系统的主机上,VMware最多可以创建20个虚拟网络,每个虚拟网络可以连接任意数量的虚拟机网络设备;
  在Linux系统的主机上,VMware最多可以创建255个虚拟网络,但每个虚拟网络仅能连接32个虚拟机网络设备。
VMware的虚拟网络都是以”VMnet+数字”的形式来命名的,例如 VMnet0、VMnet1、VMnet2……以此类推(在Linux系统的主机上,虚拟网络的名称均采用小写形式,例如 vmnet0 )。
  当我们安装VMware时,VMware会自动为3种网络连接模式各自创建1个虚拟机网络:VMnet0(桥接模式)、VMnet8(NAT模式)、VMnet1(仅主机模式)。此外,我们也可以根据需要自行创建更多的虚拟网络。

VMware 桥接模式
  VMware桥接模式,也就是将虚拟机的虚拟网络适配器与主机的物理网络适配器进行交接,虚拟机中的虚拟网络适配器可通过主机中的物理网络适配器直接访问到外部网络(例如图中所示的局域网和Internet,下同)。简而言之,这就好像在上图所示的局域网中添加了一台新的、独立的计算机一样。因此,虚拟机也会占用局域网中的一个IP地址,并且可以和其他终端进行相互访问。桥接模式网络连接支持有线和无线主机网络适配器。如果你想把虚拟机当做一台完全独立的计算机看待,并且允许它和其他终端一样的进行网络通信,那么桥接模式通常是虚拟机访问网络的最简单途径。

VMware NAT模式
  NAT,是Network Address Translation的缩写,意即网络地址转换。NAT模式也是VMware创建虚拟机的默认网络连接模式。使用NAT模式网络连接时,VMware会在主机上建立单独的专用网络,用以在主机和虚拟机之间相互通信。虚拟机向外部网络发送的请求数据”包裹”,都会交由NAT网络适配器加上”特殊标记”并以主机的名义转发出去,外部网络返回的响应数据”包裹”,也是先由主机接收,然后交由NAT网络适配器根据”特殊标记”进行识别并转发给对应的虚拟机,因此,虚拟机在外部网络中不必具有自己的IP地址。从外部网络来看,虚拟机和主机在共享一个IP地址,默认情况下,外部网络终端也无法访问到虚拟机。

  此外,在一台主机上只允许有一个NAT模式的虚拟网络。因此,同一台主机上的多个采用NAT模式网络连接的虚拟机也是可以相互访问的。

  前面我们已经提到,默认情况下,外部网络无法访问到虚拟机,不过我们也可以通过手动修改NAT设置实现端口转发功能,将外部网络发送到主机指定端口的数据转发到指定的虚拟机上。比如,我们在虚拟机的80端口上”建立”了一个站点,只要我们设置端口转发,将主机88端口上的数据转发给虚拟机的80端口,就可以让外部网络通过主机的88端口访问到虚拟机80端口上的站点。

VMware 仅主机模式
  仅主机模式,是一种比NAT模式更加封闭的的网络连接模式,它将创建完全包含在主机中的专用网络。仅主机模式的虚拟网络适配器仅对主机可见,并在虚拟机和主机系统之间提供网络连接。相对于NAT模式而言,仅主机模式不具备NAT功能,因此在默认情况下,使用仅主机模式网络连接的虚拟机无法连接到Internet(在主机上安装合适的路由或代理软件,或者在Windows系统的主机上使用Internet连接共享功能,仍然可以让虚拟机连接到Internet或其他网络)。

  在同一台主机上可以创建多个仅主机模式的虚拟网络,如果多个虚拟机处于同一个仅主机模式网络中,那么它们之间是可以相互通信的;如果它们处于不同的仅主机模式网络,则默认情况下无法进行相互通信(可通过在它们之间设置路由器来实现相互通信)。

自定义网络连接配置
  利用 WMware 提供的虚拟网络连接组件,你还可以创建复杂的虚拟网络。在这里我们不对其进行详细介绍,你可以参考官方文档,然后通过VMware提供的虚拟网络编辑器来创建虚拟网络。

形象的说:
  桥接模式的虚拟机,就像一个在路由器”民政局”那里”上过户口”的成年人,有自己单独的居住地址,虽然和主机住在同一个大院里,但好歹是有户口的人,可以大摇大摆地直接和外面通信。
  NAT模式的虚拟机,纯粹就是一个没上过户口的黑户,路由器”民政局”根本不知道有这么个人,自然也不会主动和它通信。即使虚拟机偶尔要向外面发送点的信件,都得交给主机以主机的名义转发出去,主机还专门请了一位叫做NAT的老大爷来专门负责这些虚拟机的发信、收信事宜。
仅主机模式的虚拟机,纯粹是一个彻彻底底的黑奴,不仅没有户口、路由器”民政局”不知道这么号人,还被主机关在小黑屋里,连信件也不准往外发。

cpu缓存

如果数据写入 Cache 之后,内存与 Cache 相对应的数据将会不同,这种情况下 Cache 和内存数据都不一致了,于是我们肯定是要把 Cache 中的数据同步到内存里的。


写直达

保持内存与 Cache 一致性最简单的方式是,把数据同时写入内存和 Cache 中,这种方法称为写直达(Write Through)。

如果数据已经在 Cache 里面,先将数据更新到 Cache 里面,再写入到内存里面;
如果数据没有在 Cache 里面,就直接把数据更新到内存里面。


写回

为什么缓存没命中时,还要定位 Cache Block?这是因为此时是要判断数据即将写入到 cache block 里的位置,是否被「其他数据」占用了此位置,如果这个「其他数据」是脏数据,那么就要帮忙把它写回到内存。

Alt text


在多核心的 CPU 里,每个核心都有各自的 L1/L2 Cache,而 L3 Cache 是所有核心共享使用的。

CPU 都是多核的,由于 L1/L2 Cache 是多个核心各自独有的,那么会带来多核心的缓存一致性(Cache Coherence) 的问题

要保证做到下面这 2 点:

第一点,某个 CPU 核心里的 Cache 数据更新时,必须要传播到其他核心的 Cache,这个称为写传播(Write Propagation);
第二点,某个 CPU 核心里对数据的操作顺序,必须在其他核心看起来顺序是一样的,这个称为事务的串行化(Transaction Serialization)。

C 号核心先收到了 A 号核心更新数据的事件,再收到 B 号核心更新数据的事件,因此 C 号核心看到的变量 i 是先变成 100,后变成 200。
而如果 D 号核心收到的事件是反过来的,则 D 号核心看到的是变量 i 先变成 200,再变成 100,虽然是做到了写传播,但是各个 Cache 里面的数据还是不一致的。
保证 C 号核心和 D 号核心都能看到相同顺序的数据变化,比如变量 i 都是先变成 100,再变成 200,这样的过程就是事务的串行化。

要实现事务串行化,要做到 2 点:

CPU 核心对于 Cache 中数据的操作,需要同步给其他 CPU 核心;
要引入「锁」的概念,如果两个 CPU 核心里有相同数据的 Cache,那么对于这个 Cache 数据的更新,只有拿到了「锁」,才能进行对应的数据更新。


写传播的原则就是当某个 CPU 核心更新了 Cache 中的数据,要把该事件广播通知到其他核心。最常见实现的方式是总线嗅探(Bus Snooping)。

总线嗅探只是保证了某个 CPU 核心的 Cache 更新数据这个事件能被其他 CPU 核心知道,但是并不能保证事务串行化。


基于总线嗅探机制实现了事务串行化,也用状态机机制降低了总线带宽压力,这个协议就是 MESI 协议,这个协议就做到了 CPU 缓存一致性。

MESI 协议其实是 4 个状态单词的开头字母缩写,分别是:

Modified,已修改
Exclusive,独占
Shared,共享
Invalidated,已失效

「已修改」状态就是我们前面提到的脏标记,代表该 Cache Block 上的数据已经被更新过,但是还没有写到内存里。而「已失效」状态,表示的是这个 Cache Block 里的数据已经失效了,不可以读取该状态的数据。

「独占」和「共享」状态都代表 Cache Block 里的数据是干净的,也就是说,这个时候 Cache Block 里的数据和内存里面的数据是一致性的。

「独占」和「共享」的差别在于,独占状态的时候,数据只存储在一个 CPU 核心的 Cache 里,而其他 CPU 核心的 Cache 没有该数据。

在「独占」状态下的数据,如果有其他核心从内存读取了相同的数据到各自的 Cache ,那么这个时候,独占状态下的数据就会变成共享状态。

「共享」状态代表着相同的数据在多个 CPU 核心的 Cache 里都有,所以当我们要更新 Cache 里面的数据的时候,不能直接修改,而是要先向所有的其他 CPU 核心广播一个请求,要求先把其他核心的 Cache 中对应的 Cache Line 标记为「无效」状态,然后再更新当前 Cache 里面的数据。

例子

当 A 号 CPU 核心从内存读取变量 i 的值,数据被缓存在 A 号 CPU 核心自己的 Cache 里面,此时其他 CPU 核心的 Cache 没有缓存该数据,于是标记 Cache Line 状态为「独占」,此时其 Cache 中的数据与内存是一致的;
然后 B 号 CPU 核心也从内存读取了变量 i 的值,此时会发送消息给其他 CPU 核心,由于 A 号 CPU 核心已经缓存了该数据,所以会把数据返回给 B 号 CPU 核心。在这个时候, A 和 B 核心缓存了相同的数据,Cache Line 的状态就会变成「共享」,并且其 Cache 中的数据与内存也是一致的;
当 A 号 CPU 核心要修改 Cache 中 i 变量的值,发现数据对应的 Cache Line 的状态是共享状态,则要向所有的其他 CPU 核心广播一个请求,要求先把其他核心的 Cache 中对应的 Cache Line 标记为「无效」状态,然后 A 号 CPU 核心才更新 Cache 里面的数据,同时标记 Cache Line 为「已修改」状态,此时 Cache 中的数据就与内存不一致了。
如果 A 号 CPU 核心「继续」修改 Cache 中 i 变量的值,由于此时的 Cache Line 是「已修改」状态,因此不需要给其他 CPU 核心发送消息,直接更新数据即可。
如果 A 号 CPU 核心的 Cache 里的 i 变量对应的 Cache Line 要被「替换」,发现 Cache Line 状态是「已修改」状态,就会在替换前先把数据同步到内存。

小数

乘 2 取整法,将十进制中的小数部分乘以 2 作为二进制的一位,然后继续取小数部分乘以 2 作为下一位,直到不存在小数为止。
Alt text

进程

运行状态(Running):该时刻进程占用 CPU;
就绪状态(Ready):可运行,由于其他进程处于运行状态而暂时停止运行;
阻塞状态(Blocked):该进程正在等待某一事件发生(如等待输入/输出操作的完成)而暂时停止运行,这时,即使给它CPU控制权,它也无法运行;
当然,进程还有另外两个基本状态:

创建状态(new):进程正在被创建时的状态;
结束状态(Exit):进程正在从系统中消失时的状态;

Alt text

NULL -> 创建状态:一个新进程被创建时的第一个状态;
创建状态 -> 就绪状态:当进程被创建完成并初始化后,一切就绪准备运行时,变为就绪状态,这个过程是很快的;
就绪态 -> 运行状态:处于就绪状态的进程被操作系统的进程调度器选中后,就分配给 CPU 正式运行该进程;
运行状态 -> 结束状态:当进程已经运行完成或出错时,会被操作系统作结束状态处理;
运行状态 -> 就绪状态:处于运行状态的进程在运行过程中,由于分配给它的运行时间片用完,操作系统会把该进程变为就绪态,接着从就绪态选中另外一个进程运行;
运行状态 -> 阻塞状态:当进程请求某个事件且必须等待时,例如请求 I/O 事件;
阻塞状态 -> 就绪状态:当进程要等待的事件完成时,它从阻塞状态变到就绪状态;


线程

同一个进程内多个线程之间可以共享代码段、数据段、打开的文件等资源,但每个线程各自都有一套独立的寄存器和栈,这样可以确保线程的控制流是相对独立的。

线程与进程最大的区别在于:线程是调度的基本单位,而进程则是资源拥有的基本单位。
所以,所谓操作系统的任务调度,实际上的调度对象是线程,而进程只是给线程提供了虚拟内存、全局变量等资源。

当进程拥有多个线程时,这些线程会共享相同的虚拟内存和全局变量等资源,这些资源在上下文切换时是不需要修改的;

Ubuntu 18.04修改默认源为国内源

安装Ubuntu 18.04后,使用国外源太慢了,修改为国内源会快很多。

修改阿里源为Ubuntu 18.04默认的源

备份/etc/apt/sources.list

备份

1
cp /etc/apt/sources.list /etc/apt/sources.list.bak

在/etc/apt/sources.list文件前面添加如下条目

添加阿里源

1
2
3
4
5
6
7
8
9
10
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

最后执行如下命令更新源

更新

1
2
sudo apt-get update
sudo apt-get upgrade

另外其他几个国内源如下:
中科大源

中科大源

1
2
3
4
5
6
7
8
9
10
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

163源

163源

1
2
3
4
5
6
7
8
9
10
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

清华源

清华源

1
2
3
4
5
6
7
8
9
10
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

docker

配置文件、启动命令
应用程序、环境变量
第三方软件库和依赖包
运行时环境
操作系统

例子

前端 Vue
后端 SprintBoot
DB MySql

开发环境、测试环境

NodeJS
npm依赖
java运行时环境
第三方依赖(springboot)
mysql数据库
环境变量、启动脚本
配置Redis(缓存)
配置Nginx

原理

虚拟机
Alt text

docker
Alt text

Alt text

New Linux installations, installed using the wsl –install command, will be set to WSL 2 by default.

You can list your installed Linux distributions and check the version of WSL each is set to by entering the command: wsl -l -v in PowerShell or Windows Command Prompt.

To change or reset your password, open the Linux distribution and enter the command: passwd. You will be asked to enter your current password, then asked to enter your new password, and then to confirm your new password.


If you forgot the password for your Linux distribution:

Open PowerShell and enter the root of your default WSL distribution using the command: wsl -u root

If you need to update the forgotten password on a distribution that is not your default, use the command: wsl -d Debian -u root, replacing Debian with the name of your targeted distribution.

Once your WSL distribution has been opened at the root level inside PowerShell, you can use this command to update your password: passwd <username> where <username> is the username of the account in the distribution whose password you’ve forgotten.

You will be prompted to enter a new UNIX password and then confirm that password. Once you’re told that the password has updated successfully, close WSL inside of PowerShell using the command: exit.


wsl --shutdown


Install VS Code and the WSL extension

Install the Remote Development extension pack. This extension pack includes the WSL extension, in addition to the Remote - SSH, and Dev Containers extensions, enabling you to open any folder in a container, on a remote machine, or in WSL.

This Remote Development extension pack includes four extensions:

Remote - SSH - Work with source code in any location by opening folders on a remote machine/VM using SSH. Supports x86_64, ARMv7l (AArch32), and ARMv8l (AArch64) glibc-based Linux, Windows 10/Server (1803+), and macOS 10.14+ (Mojave) SSH hosts.
Remote - Tunnels - Work with source code in any location by opening folders on a remote machine/VM using a VS Code Tunnel (rather than SSH).
Dev Containers - Work with a separate toolchain or container based application by opening any folder mounted into or inside a container.
WSL - Get a Linux-powered development experience from the comfort of Windows by opening any folder in the Windows Subsystem for Linux.


Install Docker Desktop on Windows

When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected or not depending on your choice of backend.

If your system only supports one of the two options, you will not be able to select which backend to use.


dockfile

docker compose

example

Create an empty project directory.

cd my_wordpress/

Create a docker-compose.yml file that starts your WordPress blog and a separate MySQL instance with volume mounts for data persistence:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.4-focal
# If you really want to use MySQL, uncomment the following line
#image: mysql:8.0.27
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
volumes:
- wp_data:/var/www/html
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db_data:
wp_data:

run docker compose up -d from your project directory.

Bring up WordPress in a web browser
If you are using Docker Desktop for Mac or Docker Desktop for Windows, you can use http://localhost as the IP address, and open http://localhost:80 in a web browser.


phpmyadmin

All of the following examples will bring you phpMyAdmin on http://localhost:8080 where you can enjoy your happy MySQL administration.

服务器:db

Usage with docker-compose and arbitrary server
This will run phpMyAdmin with the arbitrary server option - allowing you to specify any MySQL/MariaDB server on the login page.

version: ‘3.1’

1
2
3
4
5
6
7
8
9
10
services:


phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
- PMA_ARBITRARY=1

Mount the volume containing your themes or plugins to the proper directory; and then apply them through the “wp-admin” UI. Ensure read/write/execute permissions are in place for the user:

Themes go in a subdirectory in /var/www/html/wp-content/themes/
Plugins go in a subdirectory in /var/www/html/wp-content/plugins/

mysql

docker run -d --name mysql_1 -p 3307:3306 -e TZ=Asia/Shanghai -e MYSQL_ROOT_PASSWORD=123 mysql

$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
… where some-mysql is the name you want to assign to your container, my-secret-pw is the password to be set for the MySQL root user and tag is the tag specifying the MySQL version you want.


Using a custom MySQL configuration file

If /my/custom/config-file.cnf is the path and name of your custom configuration file, you can start your mysql container like this (note that only the directory path of the custom config file is used in this command):

$ docker run --name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag

This will start a new container some-mysql where the MySQL instance uses the combined startup settings from /etc/mysql/my.cnf and /etc/mysql/conf.d/config-file.cnf, with settings from the latter taking precedence.

Configuration without a cnf file
Many configuration options can be passed as flags to mysqld. This will give you the flexibility to customize the container without needing a cnf file. For example, if you want to change the default encoding and collation for all tables to use UTF-8 (utf8mb4) just run the following:

$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

docker run -d

-d
deamon后台服务

-p 宿主机端口:虚拟机端口
port
虚拟机端口取决于应用程序

-v 数据卷:容器目录
/var/lib/docker/volumes/
-v 宿主机目录:容器目录
volumn
双向映射

Alt text

-e KEY=VALUE
environment

Repository:TAG

volume

Alt text

mysql

1
2
3
4
5
6
7
8
9
docker run -d \
--name mysql \
-p 3306:3306 \
-e TZ=Asia/Shanghai \
-e MYSQL_ROOT_PASSWORD=123 \
-v /root/mysql/data:/var/lib/mysql \
-v /root/mysql/init:docker-entrypoint-initdb.d \
-v /root/mysql /conf:etc/mysql/conf.d \
mysql

If /my/custom/config-file.cnf is the path and name of your custom configuration file, you can start your mysql container like this (note that only the directory path of the custom config file is used in this command):

$ docker run –name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
This will start a new container some-mysql where the MySQL instance uses the combined startup settings from /etc/mysql/my.cnf and /etc/mysql/conf.d/config-file.cnf, with settings from the latter taking precedence.


Initializing a fresh instance
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order.


Create a data directory on a suitable volume on your host system, e.g. /my/own/datadir.

$ docker run --name some-mysql -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag

Alt text

openjdk:11.0-jre-buster

1
2
3
4
5
6
7
8
9
10
11
12
13
14
FROM ubuntu:16:04
# JDK安装目录
ENV JAVA_DIR=/usr/local
# copy jdk 和 java项目包
COPY ./jdk8.tar.gz $JAVA_DIR/
COPY ./docker-demo.jar /tmp/app.jar
# install jdk
RUN cd $JAVA_DIR \ && tar -xf ./jdk8.tar.gz \ && mv ./jdk1.8.0_144 ./java8
# environment variable
ENV JAVA_HOME=$JAVA_DIR/JAVA8
ENV PATH=$PATH:$JAVA_HOME/bin
# JAVA项目启动命令
ENTRYPOINT ["java", "-jar", "/app.jar"]

1
2
3
4
5
6
7
FROM openjdk:11.0-jre-buster

#设置系统时区

COPY docker-demo.jar /app.jar

ENTRYPOINT ["java", "-jar", "/app.jar"]

docker build -t myImage:1.0 .
-t -> 镜像起名
. -> dock file所在目录

network

Alt text

加入自定义网络的容器可以通过容器名互相访问

Alt text

docker run -d --name app_server_name --network custom_network_name docker_image_name

intall Appache,PHP and MySQL on ubuntu

In this tutorial we are going to learn how to configure Ubuntu 18.04 server as a web server using the Ubuntu LAMP stack, which includes the Apache web server, PHP programming Language and MySQL/MariaDB Database Server.

We will start by installing and configuring Apache web server, then we will install PHP, MySQL Server and phpMyAdmin web interface.

Install and Configure Apache web server on Ubuntu 18.04
Apache is the most popular and stable web server for Ubuntu Linux. The Apache HTTP server for Ubuntu 18 provided by the apache2 package. To install apache2 on Ubuntu, open the terminal and execute:

1
2
sudo apt-get update
sudo apt-get install apache2

That is all you need to do. Now, open a web browser from a remote computer and type the IP address of your Ubuntu server in the address bar.

You will get the Apache2 Ubuntu Default Page.

Install and Configure Apache web server on Ubuntu 18.04
The apache2.conf file is the main configuration file which you can find under the /etc/apache2/ directory.
The /var/www/html is the default DocumentRoot, You can immediately serve static HTML website by putting the contents (e.g. HTML, images, CSS, JavaScript and etc.) into the /var/www/html directory.
Creating Apache Virtual Hosts
Virtual Hosting are a way of serving multiple websites from a single server. Every website will have their own configuration and separate Document Root to host website contents.

Creating an Apache Virtual Host is a simple task. For this demonstration, I am going to create a new virtual host for the example.com domain. The /var/www/example.com directory going to be the DocumentRoot.

First create the DocumentRoot:

sudo mkdir /var/www/example.com

Create the Virtual Host configuration file inside the /etc/apache2/sites-available/ folder (Filename must end with ‘.conf’ extension).

sudo vim /etc/apache2/sites-available/example.com.conf

Add following VirtualHost configuration:

1
2
3
4
5
6
7
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save the file, enable the new site and reload the Apache web server:

sudo a2ensite example.com.conf
sudo systemctl reload apache2
And now our web server is ready to serve <www.example.com> website. Of Course we still don’t have anything in our DocumentRoot and you also need to configure DNS records to point your domain name to the server IP address.

To test virtual host without DNS, create an index.html file inside the DocumentRoot and entry to the hosts file on your local computer, pointing <www.example.com> to your Ubuntu server IP address.

Install PHP programming Language
PHP is a programming language for developing web applications and essential part of the Ubuntu LAMP Stack. To install PHP on Ubuntu 18.04, Run:

sudo apt-get update
sudo apt-get install php

The php package will install the “php7.2” as well as “libapache2-mod-php7.2” module that required to work with Ubuntu Apache web server.

After the installation is complete, we need to restart the apache server:

sudo systemctl restart apache2.service
To test the PHP installation, create an index.php file under the /var/www/html folder and add the phpinfo() function:

1
2
3
<?php
phpinfo();
?>

Then access the index.php by typing http://your-server-ip/index.php in the web browser (e.g. 192.168.1.100/index.php). You should get information page that displays PHP configuration settings on your Ubuntu 18.04 Server.

Install MySQL Server on Ubuntu 18.04
Next, we are going to install MySQL Server as our Database server. Installing MySQL Server on Ubuntu 18.04 is straightforward. Open the terminal update the package list and install the mysql-server package:

sudo apt-get install mysql-server
(If you want to Install MariaDB, install the mariadb-server package instead of mysql-server package).

After the installation has finished, Log in to the MySQL console with the following command:

sudo mysql
Note that the MySQL server on Ubuntu use auth_socket plugin to authenticate mysql root and does not need a password for connecting as a root user. If you want to enable password authentication, click on the following link to learn how to set the MySQL root password on Ubuntu 18.04.

Install phpMyAdmin on Ubuntu 18.04
phpMyAdmin is a web based graphical user interface to manage MySQL/MariaDB Database server. To install phpMyAdmin on Ubuntu 18.04 Server, Run:

sudo apt-get update
sudo apt-get install phpmyadmin
When asked to choose web server that should be automatically configured to run phpMyAdmin, select apache2 by pressing the space bar on the keyboard.

Install phpMyAdmin on Ubuntu 18.04
After the installation completes, you can access phpMyAdmin at http://server-ip/phpmyadmin or http://domain-name/phpmyadmin.

Now you have a fully functional web server up and running with Apache, MySQL and PHP programming language.

Summary
In this tutorial we learned how to install Lamp stack on Ubuntu 18.04 server. The LAMP stack stands for Linux Apache MySQL and PHP, it is a web hosting platform for Linux to server web pages using http protocol.

hexo icarus setup

hexo command

Usage: hexo <command>

Commands:
clean Remove generated files and cache.
config Get or set configurations.
deploy Deploy your website.
generate Generate static files.
help Get help on a command.
init Create a new Hexo folder.
list List the information of the site
migrate Migrate your site from other system to Hexo.
new Create a new post.
publish Moves a draft post from _drafts to _posts folder.
render Render files with renderer plugins.
server Start the server.
version Display version information.

Global Options:
–config Specify config file instead of using _config.yml
–cwd Specify the CWD(change working diretory)
–debug Display all verbose messages in the terminal
–draft Display draft posts
–safe Disable all plugins and scripts
–silent Hide output on console

hexo install and setup

Install Hexo

Once all the requirements are installed, you can install Hexo with npm:

$ npm install -g hexo-cli

setup

Once Hexo is installed, run the following commands to initialize Hexo in the target <folder>.

1
2
3
hexo init <folder>
cd <folder>
npm install

eg:

1
2
hexo init .
npm install

icarus install and setup

INSTALL from source

Download the source code tarball from the GitHub and extract it to your Hexo site’s theme directory. Alternatively, you can use Git to clone the Icarus repository to the themes directory:

Git Bash/Shell

git clone https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus -b <version number> --depth 1

You can omit -b <version number> to get the latest development version of Icarus. Leave –depth 1 out if you want to download full Git commit history of Icarus as well.

eg:

git clone https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus --depth 1

icarus setup

  1. 要将themes/icarus文件夹中的 package.json 中的 dependencies 内容拷贝并添加到主目录的package.json 中

  2. Next, activate Icarus in your site’s _config.yml file:

    _config.yml

    1
    theme: icarus

    or use the hexo command to change the theme to Icarus:
    Shell command:
    hexo config theme icarus

  3. 然后

    npm install

  4. use the hexo command to change the theme to Icarus:

    Shell
    hexo config theme icarus

  5. 这时根据提示

    1
    2
    3
    ERROR Package hexo-renderer-stylus's version (3.0.0) does not satisfy the required version (^2.0.0).
    ERROR Please install the missing dependencies your Hexo site root directory:
    ERROR npm install --save hexo-renderer-stylus@^2.0.0

git setup

create a new repository on the command line

eg:

1
2
3
4
5
6
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/lucfe2010/lucfe-hexo-private-1.git
git push -u origin main

注意提示

1
2
3
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.

清除icarus主题文件夹的 GIT 和 GITHUB

使用 windows file explore删除 icarus主题文件夹 中的.git文件夹

然后

git rm -r –cached .
git add .

git 用法

git init
git add .
git commit -m “first commit”
git branch -M main
git push -u origin main

git remote

git remote -v:列出当前仓库中已配置的远程仓库,并显示它们的 URL。

  • git remote add
    git remote add <remote_name> <remote_url>
    添加一个新的远程仓库。指定一个远程仓库的名称和 URL,将其添加到当前仓库中。如
    git remote add lucfe-clone https://github.com/lucfe2010/lucfe-hexo-61.git
    git remote add origin https://github.com/lucfe2010/lucfe-private-91.git

  • git remote remove
    git remote remove <remote_name>
    git remote remove origin

hexo config

basic config

language

language 是与主题相关的

site url

change the url to the website url of your own
url: http://lucfe2010.github.io/lucfe-hexo

Permalinks
You can specify the permalinks for your site in _config.yml or in the front-matter for each post.

Variables
Besides the following variables, you can use any attributes in the permalink.

:category -> Categories. If the post is uncategorized, it will use the default_category value.

eg

Change
permalink: ':year/:month/:day/:title/'
to
permalink: ':title/'

Global Asset Folder

Global Asset Folder
Assets are non-post files in the source folder, such as images, CSS or JavaScript files. For instance, If you are only going to have a few images in the Hexo project, then the easiest way is to keep them in a source/images directory. Then, you can access them using something like ![](/images/image.jpg).

For vscode copy images

Use vscode open the source folder as project folder to create and edit the posts

change the the image relative path link
assets/images/<post title>/*.jpg
or
../../assets/images/<post title>/*.jpg
to the project directory absolute path link
/assets/images/<post title>/*.jpg

dont use Post Asset Folder

or any kind of post asset image link plugin, there are lots of bugs!

hexo server

With the release of Hexo 3, the server has been separated from the main module. To start using the server, you will first have to install hexo-server.

$ npm install hexo-server --save

Once the server has been installed, run the following command to start the server. Your website will run at http://localhost:4000 by default. When the server is running, Hexo will watch for file changes and update automatically so it’s not necessary to manually restart the server.

$ hexo server

Static Mode

In static mode, only files in the public folder will be served and file watching is disabled. You have to run hexo generate before starting the server. Usually used in production.

$ hexo server -s

Git deploy

  1. Install hexo-deployer-git.
    $ npm install hexo-deployer-git --save

  2. Edit _config.yml (with example values shown below as comments):

    1
    2
    3
    4
    5
    deploy:
    type: git
    repo: <repository url> # https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
    branch: [branch]
    message: [message]
    Option Description Default
    repo URL of the target repository
    branch Branch name. gh-pages (GitHub)
    message Customize commit message. Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }}
    token Optional token value to authenticate with the repo. Prefix with $ to read token from environment variable

    eg

    1
    2
    3
    4
    5
    deploy:
    type: git
    repo: https://github.com/lucfe2010/lucfe-hexo.git
    branch: master
    message:
  3. Deploy your site hexo clean && hexo deploy.

    • You will be prompted with username and password of the target repository, unless you authenticate with a token or ssh key.
    • hexo-deployer-git does not store your username and password. Use git-credential-cache to store them temporarily.
  4. Navigate to your repository settings and change the “Pages” branch to gh-pages (or the branch specified in your config). The deployed site should be live on the link shown on the “Pages” setting.

  5. 注意在部署的REPOSITORY主目录下加入.jekyll文件

  • 部署步骤
    每次部署的步骤,可按以下三步来进行。

    hexo clean

    hexo generate

    hexo deploy

注意

.deploy_git 文件夹不能删除,会造成push错误文件夹。
如果删除了,要重新卸载并安装hexo-deployer-git.
$ npm uninstall hexo-deployer-git --save
$ npm install hexo-deployer-git --save

icarus config

设置你站点的logo。 此logo会显示在导航栏和页脚。 logo配置的值既可以是你的logo图片的路径或URL地址:

_config.icarus.yml
logo: /img/logo.svg
也可以像下面这样设置成文字:

1
2
logo:
text: My Beautiful Site

本站设为

1
2
logo:
text: Lucfe Knowledges

Favicon

你可以在head配置中指定你的网站favicon的路径或URL地址。

1
2
head:
favicon: /img/favicon.svg

RSS

你可以通过head部分的rss设置来添加RSS链接信息。

1
2
head:
rss: /path/to/atom.xml

本站设为

1
2
head:
rss: /atom.xml

导航栏

navbar部分定义了导航栏中的菜单与链接。 你可以通过向menu设置项中添加<链接名>: <链接URL>的方式添加任意导航栏菜单链接。 如要向导航栏右侧添加链接,请向links设置项中添加<链接名>: <链接URL>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
navbar:
# 导航栏菜单项
menu:
Home: /
Archives: /archives
Categories: /categories
Tags: /tags
About: /about
# 导航栏右侧的链接
links:
GitHub: 'https://github.com'
Download on GitHub:
icon: fab fa-github
# url: 'https://github.com/ppoffice/hexo-theme-icarus'
url: 'https://github.com/lucfe2010/lucfe-hexo'

你也可以使用FontAwesome图标来作为纯文字链接的替换,格式如下:

链接格式

1
2
3
<链接名>:
icon: <FontAwesome图标的class名>
url: <链接URL>

页脚

footer部分定义了页脚右侧的链接。 链接的配置格式与navbar中links的配置格式完全一致。

你也可以在页脚展示自定义版权文字:\

1
2
footer:
copyright: 用💖发电

文章

封面 & 缩略图

若要为文章添加封面图,请在文章的front-matter中添加cover选项:

post.md

1
2
3
4
title: Icarus快速上手
cover: /gallery/covers/cover.jpg
---
Post content...

类似地,你也可以在文章的front-matter中为文章设置缩略图:

post.md

1
2
3
4
5
title: Icarus快速上手
thumbnail: /gallery/thumbnails/thumbnail.jpg

---
Post content...

文章的缩略图会显示在归档页面和最新文章挂件中。

如果你在front-matter中使用的是图片的路径,你需要确保它是绝对或者相对于你的source目录的路径。 例如,为使用<your blog>/source/gallery/image.jpg作为缩略图,你需要在front-matter中使用/gallery/image.jpg作为图片路径。

文章许可协议

你可以在你的文章/页面的底部展示你的作品的使用许可,许可链接可以是文字或者图标。 这里的配置与导航栏或者页脚的links配置一致:

1
2
3
4
5
6
7
article:
# 文章许可协议
licenses:
Creative Commons:
icon: fab fa-creative-commons
url: 'https://creativecommons.org/'
'CC BY-NC-SA 4.0': 'https://creativecommons.org/licenses/by-nc-sa/4.0/'

一些元数据

  • 文章阅读时间
    你可以将article部分的readtime设置为true来显示文章字数统计以及预计阅读时间。

  • 文章更新时间
    若要显示文章的更新时间,请在文章的front_matter中设置updated时间:

post.md

1
2
3
4
5
title: Icarus快速上手
updated: 2020-04-01 00:00:00

---
Post content...

然后,将主题配置文件的article部分的update_time设置为true:

你也可以将update_time设置为false来隐藏所有文章的更新时间,或设置为auto而在文章的更新时间 与发布时间相同时隐藏更新时间。

  • 文章许可协议
    你可以在你的文章/页面的底部展示你的作品的使用许可,许可链接可以是文字或者图标。 这里的配置与导航栏或者页脚的links配置一致:

wiget挂件

页面挂件的安装配置。 若要同时展示多个挂件,只需在主题配置的widgets数组中添加多个挂件配置。 它们会按照定义的顺序出现。 每个挂件必须包含type(挂件类型)与position(挂件展示位置)设置项。 示例如下:

1
2
3
4
5
6
7
8
9
widgets:
-
type: ... # 挂件1
position: left
...
-
type: ... # 挂件2
position: right
...

布局配置文件

布局配置文件遵循着与主题配置文件相同的格式和定义。 _config.post.yml中的配置对所有文章生效,而_config.page.yml中的配置对所有自定义页面生效。 这两个文件将覆盖主题配置文件中的配置。

例如,你可以在_config.post.yml中把所有文章变为两栏布局:

1
2
3
4
5
6
7
8
9
10
widgets:
-
type: recent_posts
position: left
-
type: categories
position: left
-
type: tags
position: left

同时所有其他页面仍保持三栏布局:

1
2
3
4
5
6
7
8
9
10
widgets:
-
type: recent_posts
position: left
-
type: categories
position: right
-
type: tags
position: right

作者资料卡profile

  • 你可以启用作者资料卡挂件来展示文章作者/网站站长的信息。 资料卡的配置如下所示:

如果你希望使用Gravatar而不是avatar配置项作为头像图片,请在gravatar项填入 你的Gravatar邮箱地址并在avatar一项中留空;

本站使用的如下

Alt text

  • social_links可以采用如下两种格式:

图标形式:

1
2
3
4
<链接名称>:
icon: <FontAwesome5_图标的_HTML_class名称>
url: <链接的URL地址>

文字形式:

<链接名称>: <链接的URL地址>

文章目录 toc

需要开启目录的文章头部加入toc: true:

1
2
3
4
title: 一篇有目录的文章
toc: true
---
文章内容...

其他

最新文章 recent posts
文章归档 archives
文章分类 categories
文章标签 tags
1
2
3
4
5
6
7
widgets:
-
position: right
type: tags
order_by: name # 可选项。按名称(name)或长度(length)来排序。加上`-`前缀来倒序排列。
amount: 20 # 可选项。最多显示的标签数量。留空以显示所有标签。
show_count: true # 可选项。是否显示标签名称右侧的文章数量。
1
2
3
4
5
6
7
8
widgets:
-
position: left
type: links
# 友站名称与链接
links:
Hexo: 'https://hexo.io'
Bulma: 'https://bulma.io'
plugin widgets
Google Feedburner

Google即将关闭Feedburner的邮件订阅功能。 你可以切换到follow.it挂件或者其他邮件订阅服务。

Google AdSense

在Google AdSense上新建广告。 然后,复制广告HTML代码中的data-ad-client和data-ad-slot值分别填入到挂件配置的client_id和slot_id项中。 示例如下:

1
2
3
4
5
6
widgets:
-
position: left
type: adsense
client_id: ca-pub-xxxxxxxx
slot_id: xxxxxxx
install and set hexo-generator-feed

install

$ npm install hexo-generator-feed --save

You can configure this plugin in _config.yml.

1
2
3
4
5
6
7
8
9
10
11
12
13
feed:
enable: true
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date
icon: /assets/images/rss_icon_l.png
autodiscovery: true
template:

Alt text

follow.it
  1. 使用诸如hexo-generator-feed此类的Hexo插件生成 你的Hexo网站的RSS源。

    https://lucfe2010.github.io/lucfe-hexo/atom.xml

  2. 在FOLLOW.IT 网站一步步
    “定义关注表单设计”(Define the follow form’s design)页面上already have a form

    复制action=后双引号中的链接。 把你复制的action链接粘贴到挂件配置中的action_url设置项。

  3. 在”连接你的源到follow.it账户“(Connect your feed to a follow.it account)页面上,在输入框中填入你将要用来注册follow.it账户 和管理订阅者的邮箱地址。

  4. 你会收到一封来自follow.it的邮件。 在那封邮件中搜索<meta name="follow_it-verification-code" content="******"/>并复制content=后双引号中的content的值。 将你复制的值粘贴到挂件设置中的verification_code设置项。

    Alt text

  5. 回到你收到的第一封邮件并点击”点击这里来认领“(Click here to claim it)链接来认领你的订阅源。

Alt text

icarus plugin seting

Google Analytics

追踪代码(Tracking Code)界面上找到Tracking ID的值,例如”UA-12345678-0”. 将其填写到主题配置的plugins > google_analytics > tracking_id即可开启Google Analytics插件。

用户评论

disqus

在评论服务首页的右上角点击“编辑配置”(Edit Settings)按钮。

Alt text

在“为你的站点配置Disqus”(Configure Disqus for Your Site)页面上找到“Shortname”的值, 复制到主题配置的评论配置项中。 例如,下面截图中的“Shortname”为my-hexo-blog-1:

Alt text

畅言

Alt text

复制appid与conf的值到主题配置的对应配置项中。 例如,如下的HTML代码:

1
2
3
4
5
6
7
8
9
<!--PC版-->
<div id="SOHUCS" sid="..."></div>
<script charset="utf-8" type="text/javascript" src="https://cy-cdn.kuaizhan.com/upload/changyan.js" ></script>
<script type="text/javascript">
window.changyan.api.config({
appid: '????appid????',
conf: 'prod_xxxxxxxxxxxxxxxxxxxxxxx'
});
</script>

对应到主题配置为:

1
2
3
4
comment:
type: changyan
app_id: appid
conf: prod_xxxxxxxxxxxxxxxxxxxxxxx

分享按钮

share this

copy the src URL from the HTML code fragment to the share button configuration.

Alt text

For example, the following ShareThis code:

<script type="text/javascript" src="https://platform-api.sharethis.com/js/sharethis.js#property=xxxxxxxxxxxxx&product=inline-share-buttons" async="async"></script>

maps to the following theme configuration:

1
2
3
share:
type: sharethis
install_url: https://platform-api.sharethis.com/js/sharethis.js#property=xxxxxxxxxxxxx&product=inline-share-buttons

for china web connecting

disable these plugins

business or payment
feedburn
google ad sense
google analytics
sharethis
changyan comments
disqus commnets
cookie consent
follow.it

article licsence links
footer links
navbar links

CDN提供商 change cdn provider

内置CDN提供商
目前,Icarus提供如下的内置CDN服务提供商:

JavaScript库CDN
cdnjs.com (cdnjs)
jsDelivr (jsdelivr)
UNPKG (unpkg)
loli.net (loli)
Web字体CDN
Google Fonts (google)
loli.net (loli)
font.im (fontim)
中国科学技术大学 (ustc)
FontAwesome图标CDN
FontAwesome 5 (fontawesome)
loli.net (loli)

默认的CDN服务提供商配置为:

1
2
3
4
providers:
cdn: jsdelivr
fontcdn: google
iconcdn: fontawesome

修改为:

1
2
3
4
providers:
cdn: cdnjs
fontcdn: loli
iconcdn: loli