Second week Linux micro jobs

Source: Internet
Author: User

1. What are the file management commands on Linux, their commonly used methods and their related examples?

For:

File Management:

CP, MV, RM


Copy command: CP

CP [OPTION] ... [-T] SOURCE DEST

CP [OPTION] ... SOURCE ... DIRECTORY

CP [OPTION] ...-t DIRECTORY SOURCE ...


CP SRC DEST

SRC is a file:

If the target does not exist: Creates a new dest and fills the contents of SRC into the dest;

If the directory exists:

If Dest is a file: overwrites the contents of SRC into the dest;

It is recommended to use the-I option for the CP command;

If Dest is a directory: Create a new file with the same name as the original file under Dest, and populate the contents of SRC with the new file;


CP SRC ... DEST

Src... : Multiple Files

Dest must exist and be directory, other situations will be error;


CP SRC DEST

SRC is the directory:

Use option at this time:-R


If Dest does not exist: creates the specified directory and copies all files in the SRC directory to dest;

If dest exists:

If Dest is a file: Error

If Dest is a directory:


Common options:

-I: Interactive

-R,-r: recursively copy directories and all internal content;

-A: Archive, equivalent to-DR--preserv=all

-d:--no-dereference--preserv=links

--preserv[=attr_list]

Mode: Permissions

Ownership: Belong to the main group

Timestamp

Links

Xattr

Context

All

-P:--preserv=mode,ownership,timestamp

-V:--verbose

-F:--force


Mv:move, moving files

MV [OPTION] ... [-T] SOURCE DEST

MV [OPTION] ... SOURCE ... DIRECTORY

MV [OPTION] ...-t DIRECTORY SOURCE ...

Common options:

-I: Interactive

-F: Mandatory


Rm:remove, deleting

RM [OPTION] ... FILE ...


Common options:

-I: Interactive

-F: Force delete

-R: Recursive


Rm-rf


Text Editor: Nano

Full Screen Editor



2. Bash's work characteristics the command execution status return value and command line expansion are involved in the content and its sample demonstration. Command line expansion

~: Expand to the user's home directory

~username: Expand the home directory for the specified user

{}: Can host a comma-delimited list and expand it to multiple paths

/tmp/{a,b} =/tmp/a,/tmp/b

/tmp/{tom,jerry}/hi =/tmp/tom/hi,/tmp/jerry/hi


(5) Execution result status of the command

Success

Failed


Bash uses a special variable $? Save the execution status result of the most recent command:

0: Success

1-255: Failure

Program execution has two types of results:

The return value of the program;

The execution status result of the program;650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/9A/7E/ Wkiol1lwpyvjpp7haacszhtynm4340.png "alt=" Wkiol1lwpyvjpp7haacszhtynm4340.png "style=" FONT-FAMILY:SANS-SERIF; font-size:16px; "/>


3. Use the command line expansion function to complete the following exercises:

(1), create/tmp directory: A_c, A_d, B_c, B_d

(2), create the/tmp/mylinux directory:

mylinux/

├──bin

├──boot

│└──grub

├──dev

├──etc

│├──rc.d

││└──init.d

│└──sysconfig

│└──network-scripts

├──lib

│└──modules

├──lib64

├──proc

├──sbin

├──sys

├──tmp

├──usr

│└──local

│├──bin

│└──sbin

└──var

├──lock

├──log

└──run

Answer: (1)

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9A/7E/wKioL1lWSPaggSjsAABt9VJFCDY783.png "title=" XUBPP@DRB0DT@Q] $P 6 ' 7r~4.png "alt=" Wkiol1lwspaggsjsaabt9vjfcdy783.png "style=" padding:0px;margin:0px; Vertical-align:top;border:none; "/>

(2):

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9A/7E/wKiom1lWTD3AlJ9TAAB5AzFt3Bc519.png "title=" $ Gcnumr9z8bfy6%zgof ' ${r.png "alt=" Wkiom1lwtd3alj9taab5azft3bc519.png "style=" padding:0px;margin:0px; Vertical-align:top;border:none; "/>

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9A/7E/wKiom1lWTQGh3RZPAAA7mbCy0XM416.png "title=" $AS 3 ' K_KZTR (N) ' h{8 ' @6{o.png "alt=" Wkiom1lwtqgh3rzpaaa7mbcy0xm416.png "style=" Padding:0px;margin:0px;vertical-align: Top;border:none; "/>


4, what is the metadata information of the file, what does it mean, how to view it? How to modify timestamp information for a file.

For:

. Three timestamps:

Access time: Atime, read and write file contents

Modify Time: Modified, Mtime, change file contents (data)

Change time: Changing times, ctime, meta data changes

Time stamp for modified file: Touch

Touch [OPTION] ... FILE ...

-a:only Atime

-m:only Mtime

-S STAMP:

[[Cc]yy] MMDDHHMM[.SS]

-C: If the file does not exist, it is not created


5, how to define the alias of a command, how to reference the execution result of another command in the command?

A: Define an alias for a command, for example: Alias die = ' Rm-rf '

Setting an alias for an instruction

Syntax: # alias name= ' command line '

Parameters:
-P: Print the aliases that appear (unique parameters)
If no parameters are added, all current alias settings are listed

Usage:
# alias cp= ' Cp-i ' or alias l= ' ll ';


The command is Ficonfig eth0, and the variable is IP:
#!/bin/bash
ip= ' ifconfig eth0 '
Echo $ip
This assigns the command generated string to the IP, Echo $ip, see the result of the command execution





This article is from the "11822904" blog, please be sure to keep this source http://11832904.blog.51cto.com/11822904/1943622

Second week Linux micro jobs

Related Article

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.