1. What are the file management commands on Linux, their commonly used methods and their related examples?
File Management class commands: CP, MV, RM
CP command: Copy, from source file to destination file
Common options:
-I: Interactive replication, that is, before overwriting to remind users to confirm;
-F: Force overwrite the target file;
-R,-r: recursive copy directory;
-D: Copies the symbolic link file itself, not the source file it points to;
-a:-dr--preserve=all, archive, for archiving;
--preserv=
Mode: Permissions
Ownership: A group of owners and genera
Timestamps: Time stamp
Context: Security label
Xattr: Extended Properties
Links: Symbolic Links
All: All of the above properties
Where CP is also divided into single source replication and multi-source replication
Single source copy: CP [OPTION] ... [-T] SOURCE DEST
If Dest does not exist: The file is created in advance and the data stream of the source file is copied to dest;
If the dest exists: copy directly;
If the dest is a non-directory file: overwrite the target file;
If Dest is a directory file: first create a file with the same name as the source file in the Dest directory and copy its data stream;
Multi-source replication: CP [OPTION] ... SOURCE ... DIRECTORY
CP [OPTION] ...-t DIRECTORY SOURCE ...
If the dest does not exist: error;
If the dest exists: copy directly;
If Dest is a non-directory file: error;
If Dest is a directory file: Copy each file to the target directory separately and keep the original original;
MV Command: That is, move moves
MV [OPTION] ... [-T] SOURCE DEST
MV [OPTION] ... SOURCE ... DIRECTORY
MV [OPTION] ...-t DIRECTORY SOURCE:
Common options:
-I: interactive;
-f:force
RM command: Remove removed
RM [OPTION] ... FILE ...
Common options:
-i:interactive
-f:force
-r:recursive
Delete directory: Rm-rf/path/to/dir
Hazardous operation: RM-RF/*
2. Bash's work characteristics the command execution status return value and command line expansion are involved in the content and its sample demonstration.
Bash outputs this result with a status return value:
Success: 0
Failed: 1-255
When the command executes normally, some return the command returned value: According to the command and its function, the result is different;
For example:
Success:
Failed:
3. Use the command line expansion function to complete the following exercises:
(1), create A/tmp directory: A_c, A_d, B_c, B_d
(2), create/tmp/mylinux directory:
mylinux/
├──bin
├──boot
│└──grub
├──dev
├──etc
│├──rc.d
││└──init.d
│└──sysconfig
│└──network-scrip TS
├──lib
│└──modules
├──lib64
├──proc
├──sbin
├──sys
├──tmp
├──usr
│└──local
│ ──bin
│└──sbin
└──var
├──lock
├──log
└──run
[[email protected] ~]# mkdir-pv/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.
The metadata information for the file is: File: file name Size: Files of Block: block of data
IO BLOCK: The size of the data block of the file device: Device hardware Inode: Node number links: Hard links
Access: Permissions Uid: File belongs to main Gid: file group
Context: Environment access: Recently accessed Modify: Recent Changes change: Creation time
View Meta Data:
To modify the file timestamp:
Before change:
After the change:
5, how to define the alias of a command, how to reference the execution result of another command in the command?
Define aliases:
~]# alias Name= ' COMMAND '
Note: Valid only for the current shell process
To revoke an alias:
~]# Unalias NAME
Reference command Execution Result:
$ (COMMAND)
OrCOMMAND
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.
7. Displays files or directories that start with any number in the/etc directory and end with a non-numeric number.
8, Show/etc directory, start with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.
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-05-27-09-32-22.
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.
11. Copy all files or directories ending with. D in the/etc directory into the/tmp/mytest2 directory.
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.
If you have any questions, please do not mention
Linux File Management