Second week homework

Source: Internet
Author: User

1. Linux What are the file management class commands on, their common usage methods, and their associated example demos.

Answer: CP Usage:

CP [OPTION] ... [-T] SOURCE destcp [OPTION] ... SOURCE ... DIRECTORYCP [OPTION] ...-t DIRECTORY SOURCE ...

Common options:

- I. : Interactive

- R ,-R: recursively replicate directories and all internal content:

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

- D :--no-dereference--preserv=links

--preserve[=attr_list]

Default defaults include properties: Mode, ownership, timestamps

If Use = contains the following attribute, the corresponding property is included

mode: Permissions

Ownership: belong to the group of main genera

Timestamp: time Stamp

links : Link Properties

xattr: Extended Properties

Context : Security Context

All  

- P : equivalent to--preserve

- v :--verbose

- F : Force

RM Usage:

RM [OPTION] ... FILE ...

Common options

- I. : Interactive

- R : Delete directory files recursively

- F : Force Delete without confirmation

Example: rm-rf/tmp/*

MV Usage:

MV SOURCE ... DEST

If there are multiple sources of movement, then the target must be a directory

Common options:

- I. : Interactive

- F : Force

Default mv= "Mv-i"

2. Bash the command execution status return value and command-line expansion are involved in the work feature and its example demonstration.

A: The command execution success status return value is 0, the command execution failure status return value is 1~255;

Bash of the command line expand content:

~ : 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

3 , use the command-line deployment feature to complete the following exercises:

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

mkdir {AB}_{CD}

(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

Mkdir-p/tmp/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}

3. What are the metadata information for a file, what does it mean, and how to view it? How to modify timestamp information for a file.

A: Stat can view the metadata information of a file, including the location, size, block size, file type, save location, inode location, access rights, contextual information, Atime, Mtime, CTime, and other information.

Use touch to modify the timestamp information for a file.

Touch Usage:

Touch[option] ... FILE ...

Common options

-A : Change only atime

- M : Change only mtime

- T STAMP : Change to the appropriate timestamp

[[Cc]yy] MMDDHHMM[.SS]

- C : If the file does not exist, it is not created and changes its timestamp if it exists

4. How do I define an alias for a command, and how do I refer to the execution result of another command in a command?

A: Define command aliases using the command alias:

ALIAS[-P] [Name[=value] ...]

The execution result method that references another command in a command can have the following two methods depending on the scenario:

Method 1: Use management |

Cat/etc/fstab |wc-l

Method 2: Use the inverse quotation marks

mkdir/tmp/tfile-' Date +%f-%h-%m-%s '

5. displays all files or directories in the/var directory that start with L, end with a lowercase letter, and have at least one digit (can have other characters) appear in the middle.

ls-d/var/1*[0-9]*[[:lower:]]

6. displays files or directories that start with any number in the/etc directory and end with a non-numeric number.

Ls-d/etc/[0-9]*[^0-9]

7. displays a file or directory that starts with a non-letter, followed by a letter and any character of any length, in the/etc directory.

Ls-d/etc/[^a-za-z][[:alpha:]]*

8. in the/tmp directory, create a file that begins with Tfile, followed by the current date and time, with a filename such as tfile-2016-08-06-09-32-22.

mkdir/tmp/tfile-' Date +%f-%h-%m-%s '

9. copy all the files or directories in the/etc directory to the/tmp/mytest1 directory that begin with P and do not end with a number.

Cp-a/etc/p*[^0-9]/tmp/mytest1

10. Copy all files or directories ending with. D in the/etc directory into the/tmp/mytest2 directory.

Cp-a/etc/*.d/tmp/mytest2

A , copy all files in the/etc/directory that begin with L or M or N and end with. conf to the/TMP/MYTEST3 directory.

Cp-a/etc/[lmn]*.conf/tmp/mytest3

Second week homework

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.