Linux simulates Windows to create a recycling bin[Copy link]
First, create your Recycle Bin folder: mkdir ~/.trash (it can also be any other directory, or directly use the /tmp directory) and then add alias rm="mv -target-directory ~/.trash" to the ~/.bashrc file, and then use source ~/.bashrc to make the new alias effective. For a slightly more advanced method, you can use the following alias: alias rm="mv –verbose -f –backup=numbered –target-directory ~/.trash/" This command adds verbose parameters and backup parameters. When deleting files, information about all operations will be given, and when deleted files have duplicate names, a number will be automatically added to the backup file to prevent duplicate files from being overwritten. On the other hand, these files are not actually deleted and cannot free up your space. You need to clean up files in the ~/.trash directory at any time. The Linux scp command is used to copy files and directories between Linux. Here is a detailed introduction on how to use it. There are two ways to use it: copying from local to remote and from remote to local. Here are some specific examples: ================== Linux scp command ================ scp can copy files between two Linux hosts; Basic command format: scp [optional parameters] file_source file_target ====== Copy from local to remote====== * Copy file: * Command format: scp local_file remote_username@remote_ip:remote_folder or scp local_file remote_username@remote_ip:remote_file or scp local_file remote_ip:remote_folder or scp local_file remote_ip:remote_file The first and second specify the username, and the password needs to be entered after the command is executed. The first only specifies the remote directory, and the file name remains unchanged. The second specifies the file name; : The 3rd and 4th ones do not specify a username. After the command is executed, you need to enter the username and password. The 3rd one only specifies the remote directory, and the file name remains unchanged. The 4th one specifies the file name. * Examples: scp /home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/music scp /home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/music/001.mp3 scp /home/space/music/1.mp3 www.cumt.edu.cn:/home/root/others/music scp /home/space/music/1.mp3 www.cumt.edu.cn:/home/root/others/music/001.mp3 * Copy directory: * Command format: scp -r local_folder remote_username@remote_ip:remote_folder or scp -r local_folder remote_ip:remote_folder The first one specifies the username, and the password is required after the command is executed; The second one does not specify the username, and the username and password are required after the command is executed; * Example: scp -r /home/space/music/ root@www.cumt.edu.cn:/home/root/others/ scp -r /home/space/music/ www.cumt.edu.cn:/home/root/others/ The above command copies the local music directory to the remote others directory, that is, after the copy, there is a ../others/music/ directory on the remote side====== Copy from remote to local====== To copy from remote to local, just swap the order of the last two parameters of the command that copies from local to remote; For example: scp root@www.cumt.edu.cn:/home/root/others/music /home/space/music/1.mp3 scp -r www.cumt.edu.cn:/home/root/others/ /home/space/music/ The simplest application is as follows: scp local username@IP address: filename1 remote username@IP address: filename2 [local username@IP address:] can be left blank, but you may need to enter the password corresponding to the remote username. Several parameters that may be useful: -v has the same meaning as -v in most Linux commands, used to display progress. It can be used to view connections, authentication, or configuration errors. -C enables compression options. -P selects the port. Note that -p has been used by rcp. -4 forces the use of IPV4 addresses. -6 forces the use of IPV6 addresses. The usage of the Linux scp command should be able to satisfy everyone's use of copying Linux files and directories.