1. What are the file management commands on Linux, their commonly used methods and their related examples?
CP Copy Command
-I: Interactive
-r,-r: Recursively copy all contents of a directory and content
-A: Archive, equivalent to-DR--preserve=all
-P: Preserve properties of copied files
-V: Show more information
-F: Forced replication
Example: cp/etc/inittab/tmp
MV Move Command
-I: Interactive
-F: Force move
Example: mv/etc/inittab/tmp
RM Delete command
-I: Interactive
-F: Strong delete
-R: Recursive delete
Example: rm/etc/inittab/tmp
LS View file
-L: Viewing files in long form
-A: View all files
-T: Arranged by time
-R: Flashback view File
Example: Ls-l/etc/inittab
Cat viewing the contents of a file
Example: Cat/etc/inittab View the contents of a file
2. Bash's work characteristics the command execution status return value and command line expansion are involved in the content and its sample demonstration.
echo $? View command execution status return value
0 indicates success
1 indicates failure
2-255 indicates an error
Command line expansion: ~, {}
~: Indicates the current user's home directory
CD ~: Indicates the home directory of the currently logged in user
Mkdir/tmp/{a,b}_{c,d} {} means expand
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/TMP/{A,B}_{C,D}
(2), create the/tmp/mylinux directory:
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 is the metadata information of the file, what does it mean, how to view it? How to modify timestamp information for a file.
Ls-l file name: You can view the metadata of files
Meta data information is:
File type: Permissions: Number of hard Links: Owner: Genus Group: Access time: File name
The timestamp of the file can be divided into Access time, modification time, change time
Touch file name indicates the timestamp of the modified file
5, how to define the alias of a command, how to reference the execution result of another command in the command?
Alias cdnet= "Cd/etc/sysconfig/network-scripts"
Ls-l/var | Wc-l using pipelines To reference the execution result of another command in a 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.
Cd/var
Ls-ld 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.
Cd/etc
Ls-ld [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.
Cd/etc
Ls-ld [^[:alpha:]][[:alpha:]]*
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.
Cd/tmp
Touch 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.
Mkdir/tmp/mytest1
Cd/etc
Cp-r P*[^0-9]/tmp/mytest1
11. Copy all files or directories ending with. D in the/etc directory into the/tmp/mytest2 directory.
Mkdir/tmp/mytest2
Cd/etc
Cp-r *.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.
Mkdir/tmp/mytest3
Cd/etc
Cp-r [L,m,n]*.conf/tmp/mytest3
This article from "11666688" blog, declined reprint!
Second week homework