Note: The second week of work, please organize the following topics in the 51cto blog, after completion, please submit the corresponding post link address in the answer bar, the submission format is as follows:
School Number + name + Post link address
eg:1+ Zhang San +650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/ Zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>http:// mageedu.blog.51cto.com/4265610/1794420
Content of this week's job:
1. What are the file management commands on Linux, their commonly used methods and their related examples?
Commands for file management are CP, MV, RM
Copy command: CP
Usage:
CP [-ADFILPRSU] source file (source) destination file (destination)
CP [ options] source1 source2 source3 .... Directory
Options and Parameters:
-A: equivalent to the meaning of-dr--preserve=all, keep the soft connection, recursive, keep the original properties of the file; (common)
-D: If the source file is the attribute of the linked file, the link file property is copied instead of the file itself;
-F: For force, if the target file already exists and cannot be opened, then try again after removing it;
-I: If the target file (destination) already exists, the action will be asked (commonly used) (also known as interactive) when overwriting
-L: Link file creation for hard link, not copy file itself;
-P: Copy the past with the properties of the file (permissions, user, time), instead of using the default attributes (backup is often used);
-R: Recursive continuous replication, used for directory replication behavior; (common)
-S: Copy as a symbolic link file (symbolic link), i.e. "shortcut" file;
-u:destination is copied only if the destination is newer than the source, or if the destination does not exist.
--preserve=all: In addition to the permissions related parameters of-p, also added SELinux properties, links, xattr, etc. also copied.
Mv
the MV command can not only move files or directories, but can also rename
How to use: mv [-FIU] source destination
MV [ options] Source1 source2 source3 .... Directory
Options and Parameters:
-f:force mandatory Meaning, if the target file already exists, will not be asked and directly covered;
-I: If the target file (destination) already exists, you will be asked to overwrite it!
- u: If the target file already exists and source is newer, update (update)
RM [-fir] File or directory
options and Parameters:
-F: The meaning of force, ignoring the non-existent file, no warning message appears;
-I: Interactive mode that asks the user whether or not to move before deleting
-R: Pass it back! Most commonly used in directories are deleted! This is a very dangerous option!!!
2. Bash's work characteristics the command execution status return value and command line expansion are involved in the content and its sample demonstration.
The basic features of bash:
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;
3. Use the command line expansion function to complete the following exercises:
(1), create/tmp directory: A_c, A_d, B_c, B_d
mkdir {A,b}/{c,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
Mkdir-p/tmp/mylinux/{Binboot/Grub,Devetc{rc.d/init.d,sysconfig/network-scripts },lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin },var,Lock,log,run }
# Tree mylinux/
mylinux/
├──bin
├──boot
│└──grub
├──dev
├──etcrc.d
│└──init.d
├──etcsysconfig
│└──network-scripts
├──lib
│└──modules
├──lib64
├──lock
├──log
├──proc
├──run
├──sbin
├──sys
├──tmp
├──usr
│└──local
│├──bin
│└──sbin
└──var
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.
To view metadata information using the STAT command
The touch command is used to modify the timestamp information for a file
-A: Modify only the last access time
5, how to define the alias of a command, how to reference the execution result of another command in the command?
Aliases with Command alias
By default, alias sets a command alias that is valid only for the current shell
Command reference:
Name= ' command ', name=$ (command)
6. Display 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/l*[0-9]*[[:lower:]]
7. Displays files or directories that start with any number in the/etc directory and end with a non-numeric number.
[0-9]*[^0-9]
8, Show/etc directory, start with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.
ls/etc/[^a-z][a-z]*
9. In the/tmp directory, create a file that starts with Tfile, followed by the current date and time, with a filename such as: tfile-2016-08-06-09-32-22.
touch/tmp/tfile-' Date +%y-%m-%d-%h-%m-%s '
10. 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/ETC/P*[^0-9]/tmp/mytest1/
11. Copy all files or directories ending with. D in the/etc directory into the/tmp/mytest2 directory.
cp/etc/*.d/tmp/mytest2/
12. 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/etc/{l, m,n}*.conf/tmp/mytest3/
Marco Linux training work for the second week