Linux Second week blog
1.LinuxWhat are the file management class commands on, their common usage methods, and their associated example demos.
CP, MV, RM
1. Copy command: CP
CP [Option] ... [-T] SRC ( source ) DEST ( purpose )
dest, dest
dest is the file that will src content covered to Span style= "FONT-SIZE:12PX;" >dest at this point it is proposed as CP -i options.
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 in DEST )
Example: cp/etc/fstab/tmp/out.tmp (out.tmp for file)
Cp/etc/fstab/tmp/out (out for directory)
CP [Option] ... SRC(original file)... ( multiple files) directory(new directory) (which directory is copied to )
if src is a multiple file,directory must be present and directory, and other cases are wrong.
cp src DEST src is the directory:
Use the option at this time: -R (Recursive recursion )
if dest does not exist create the specified directory, copy SRC all directories in the directory to DEST in
if dest exist:
if dest is the file, then the error
if dest is a directory, it is copied to this directory
Common options:
- I.: Interactive
- R: recursively copy a directory and all its internal content
-A : Archive , equivalent -dr--preserv=all ( that is, preserve the properties of the source file or directory, including the owner, the owning group, permissions, and time)
-D:--no-dereference--preserv=links ( If the original file is a link, keep the original link format)
--preserv=[attr_list] ( reserved property)
mode: Permissions
Ownership: belong to the group of main genera
timestamp : Time Stamp
Links: links
xattr : Special Properties
Context: Context
All : All
-P =--preserve=mode, ownership, timestamp
- v Show more information
- T The target can be placed on the front when copying
- F--force Force replication ( Dangerous)
such as: cp/etc/apache2/tmp/apache2 (/etc/apache2,/tmp/apache2 as directory,)
cp-p/var/tmp/a.txt./temp/( reserved property)
2. Move File command: MV
MV [Option] ... [_t] SOURCE DEST to move the original file to the target file, which is renamed
mv {Option] ... SOURCE ... Directory to move source files to the destination file directory
MV [Option] ...-tdirectory SOURCE will be DIRECTORY as a moving target
Option
- I. Interactive , Prompt Action
- F forcing
such as: MV Test.log Test1.txt (renamed to test.txt)
MV test1.txttemp/( move to temp directory)
3. Delete command:RM
RM [OPTION] ... FILE ...
Common options:
- I.: Interactive
- F : Force Delete
- R: Recursive
rm-f A.log ( forcibly delete files)
rm-r tmp/( Delete tmp directory and its subdirectories and files)
2.bashthe command execution status return value and command-line expansion are involved in the work feature and its example demonstration.
Bash There are two kinds of command execution result states: Success / failed , Bash Use special variables $? to save the execution status result of the most recent command. 0 for success,1-255 represents various failures.
Bash the command line expansion: with {} means that you can host a comma-delimited list and expand it to multiple paths
such as: /tmp/{a,b}=/tmp/a,/tmp/b
/TMP/{A,B}/C=/TMP/A/C,/TMP/B/C
3. Use the command line expansion feature to complete the following exercises:
(1) , creating / tmp under the directory: A_c, A_d, B_c, B_d
Mkdir/tmp/{a,b}{_c,_d}
(2) , creating /tmp/mylinux under the directory:
mylinux/
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/88/02/wKioL1fnuqGAydlyAAA0YpzxD-Y814.png "title=" QQ picture 20160925195151.png "alt=" Wkiol1fnuqgaydlyaaa0ypzxd-y814.png "/>
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}
4. 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.
metadata contains information such as permissions, size, owner, group, and modification time of the file, available ls-l command to view. Use the Touch command to modify the timestamp information. Example:touch-t [yyyymmddhhmm] FILE
5. How do I define an alias for a command, and how do I refer to the execution result of another command in a command?
Use alias define individual names, alias aliasname = Command + option
To use a pipe to reference another command to execute the result , as ps-ef |grep httpd
6.Show/ varall the directories under theLA file or directory that begins with a lowercase letter ending with at least one digit (which can have other characters) appear in the middle.
ls/var/l*[[:d Igit:]]*[[:lower:]]
7.Show/ etcdirectory, a file or directory that begins with any number and ends in a non-numeric number.
ls/etc/[[:d igit:]]*[^[:d igit:]]
8.Show/ etcdirectory, beginning with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.
ls/etc/[^[:alpha:]][[:alpha:]]*
9.in the/ tmpdirectory under Create toTfileThe file, followed by the current date and time, has a filename such as:tfile-2016-08-06-09-32-22.
Touch tfile-' date+%y-%m-%d-%h-%m-%s '
.Copy/ etcall the directories under thePA file or directory that ends in a non-numeric/tmp/mytest1the directory.
cp/etc/p*[^[:d igit:]]/tmp/mytest1/
One by one .Copy/ etcall the directories under the. Dend of file or directory to/tmp/mytest2the directory.
Cp-r/etc/*.d/tmp/mytest2
.Copy/etc/all the directories under theLormorNbegins with the. confend of file to/tmp/mytest3the directory.
cp/etc/[lmn]*.conf/tmp/mytest3/
Linux Blog next week