Experiment four to experiment 12

Source: Internet
Author: User

Iv. Linux directory structure and file Basic operations 1, the Linux file organization directory structure.Linux is a tree-shaped directory structure to build the entire systemLinux disks are "hung on" (mounted on) the directoryeach directory can not only use the file system of the local disk partition, but also the file system on the network. FHS (English: Filesystem Hierarchy Standard Chinese: File system hierarchy Standards)

2, relative path and absolute path.

Knowledge Points:

Go to the top level directory:$ cd ..

Go to your "home" directory:$ cd ~       # 或者 cd /home/<你的用户名>

Use to pwd get the current path

Absolute Path , the full path to the root "/" directory as the starting point for the directory you want to go to

The expression form , such as: /usr/local/bin , represents the Bin directory in the local directory in the USR directory under the root directory.

relative path, relative to the path of your current directory, the relative path is the current directory . starting point, the directory you want to end,

The expressions are as follows: usr/local/bin (this assumes your current directory is the root directory).

Experiment:

3, the movement of files, copying, renaming, editing and other operations. 1. Create a new blank file

touchCreate a blank file with a command

Create a blank file named Test, because you do not have permissions in other directories, so you need to cd ~ switch back to the user's /home/shiyanlou directory first:

New Catalog

Use the Make mkdir directories command to create an empty directory or to specify permission properties for creating a directory

2. Copying and Copying files

Use cp the (copy) command to copy a file or directory to the specified directory.

3. Delete deleted files

rmDelete a file or directory using the (remove files or directories) command:

Using rm Delete directly will display a prompt,

To ignore this hint, delete the file directly, you can use the -f parameter to force delete

Delete Directory

As with the copy directory, to delete a directory, you also need to add -r or -R parameter

4. Move file and file rename move file

Use mv the (move or rename files) command to move the file (cut).

There is a PROBLEM:!!!!!

5. View File Usage cat, tacAnd nlcommand to view files

catFor positive sequence display, tac reverse display.

Standard input and output: when we execute a shell command line normally will automatically open three standard files, namely standard input file (stdin), default corresponding to the terminal's keyboard, standard output file (STDOUT) and standard error output file (stderr), All two files correspond to the screen being redirected to the terminal so that we can see the output directly. The process will get input data from the standard input file, output normal output data to the standard output file, and send the error message to the standard error file.

-nParameter Display line number

nlcommand, add line numbers and print

A few common parameters:

-b : 指定添加行号的方式,主要有两种:    -b a:表示无论是否为空行,同样列出行号("cat -n"就是这种方式)    -b t:只列出非空行的编号并列出(默认为这种方式)-n : 设置行号的样式,主要有三种:    -n ln:在行号字段最左端显示    -n rn:在行号字段最右边显示,且不加 0    -n rz:在行号字段最右边显示,且加 0-w : 行号字段占用的位数(默认为 6 位)
Use moreAnd lesscommand paging to view files

tailcommand, and have to mention it a very good parameter -f , this parameter can be implemented to read the contents of a file and display. This allows us to dynamically view the role of the log as real-time monitoring

6. View File types

You typically use file commands to view the types of files

7. Edit the file

Dedicated command-line editor such as (Emacs,vim,nano)

Homework:

Experiment Five, environment variable and file find one, environment variable

Use declare the command to create a variable named tmp:

Take the value of a variable, using echo commands and $ symbols (the $ symbol is used to denote a value that refers to a variable, and beginners often forget to enter it):

Variable names can only be English letters, numbers, or underscores, and cannot begin with a number.

Environment variables are scoped to larger than custom variables

The environment variables of the Shell Act on itself and its child processes.

There are three types of environment variables that we will typically relate to:

    • The current shell process private user-defined variables, such as the TEMP variable we created above, are only valid in the current shell.
    • The built-in variables of the Shell itself.
    • An environment variable exported from a custom variable.

There are also three commands related to the above three environment variables,, set , env export . These three commands are similar and can be used to print related environment variables, except that they are related to different ranges of environment variables, as described in the following table:

Command Description
set Displays all environment variables for the current shell, including built-in environment variables (related to shell appearance, etc.), user-defined variables, and exported environment variables
env Displays the environment variables that are relevant to the current user, and lets the command run in the specified environment
export Displays variables that are exported from the Shell to an environment variable, and can also be exported to a custom variable as an environment variable

3. Search path and order of commands

4. Add a custom path to the "path" environment variable

Each user's home directory has a Shell that executes a configuration script by default each time it starts to initialize the environment, including adding some user-defined environment variables, and so on. Zsh profile is, the .zshrc corresponding Bash configuration file is.bashrc

5. Modifying and deleting existing variable variables

There are several ways to modify variables:

How variables are set Description
${变量名#匹配字串} Start the match from the back to delete the shortest data matching the matched string
${变量名##匹配字串} Start the match from the back to delete the longest data matching the matched string
${变量名%匹配字串} Match from tail forward to delete the shortest data matching string
${变量名%%匹配字串} Match from tail forward to delete maximum data matching string
${变量名/旧的字串/新的字串} Replace the first string that matches the old string with a new string
${变量名//旧的字串/新的字串} Replace all strings that match the old string with a new string

For example, modify the environment variables we added to PATH earlier.

Second, search documents

Search-related commands are commonly used in the following sections,,, whereis which find locate .

whereisOnly binary (-B), man Help file (-m), and source code file (-s) can be searched. You can use the command if you want to get a more comprehensive search result locate .

    • whichSmall and fine

whichitself is a shell built-in command that we typically use which to determine if a specified software is installed because it only PATH searches for the command from the path specified by the environment variable:

    • findFine and Thin

findShould be the most powerful of these commands, not only can be found by file type, file name and can be based on the properties of the file (such as the file's timestamp, file permissions, etc.) to search.

Note the path to the Find command is the first parameter, and the basic command format is find [path] [option] [action]

Homework:

"Digital Rain" in the "Matrix" movie full of screen code, you can also easily achieve this effect in Linux

Experiment six, document packaging and compression experiment introduction

The use of Zip,rar,tar is described in the compression/decompression tools commonly used on Linux.

One, file packaging and decompression 1. zipCompression Packager

In the first line of the command, the -r parameter indicates that the recursive package contains the entire contents of the subdirectory, and the -q parameters are expressed in quiet mode, that is, not outputting information to the screen, -o indicating the output file, followed by packaging the output filename immediately thereafter. Later use du the command to view the size of the packaged file

2. Use unzipcommand to unzip the zip file

Do not want to unzip just want to view the contents of the compressed package you can use the -l parameters

Use -O the (English letter, capital O) parameter to specify the encoding type:

3. rarPackage Compression command
    • To create a compressed package or add a file to a compressed package from a specified file or directory:
    • Use a parameters to add a directory to an archive, which is created automatically if the file does not exist.

Homework: When it's cold, it's good to have a stove.

Experiment VII, File system operation and Disk Management one, simple file system operation 1. View disk and directory capacity use the DF command to view the capacity of the disk

Ii. Simple Disk Management 1. Introduction to creating a virtual Disk DD command

Mount a disk to a directory tree using the Mount command to establish an association of mirroring with a loopback device with the Losetup command

Then use mkfs the formatting of each partition

Homework

cowsaycommand that allows you to print a paragraph in the terminal in the form of an animal speaking.

Experiment four to experiment 12

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.