In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use alias to achieve the Linux system Recycle Bin function, the editor feels very practical, so share with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.
In fact, I didn't answer the questions raised by others when I went to the interview, and then he reminded me that I once saw a command: alias, this command can rename your command, that is to say, the cd you enter may not be cd, and the rm you enter can also be other commands. Later, I looked it up on the Internet and thought it was quite reliable.
[alias]
Format: alias [- p] [name [= value].] Note that spaces cannot be included between'= 'and the string.
Usage:
1. Displays all aliases for the current setting:
two。 To show only the meaning of an alias, you can enter alias name, such as:
3. To set an alias for the command, enter the new alias command = 'original command options / parameters', such as:
4. Cancel command alias: unalias
The following content is reproduced in
Https://blog.csdn.net/u014057054/article/details/52126494
People who have been engaged in server maintenance all know the power of rm and rm-rf, and they are not careless in implementation, and they feel that they are not recognized by their relatives. At first, I didn't feel the power of rm. After rm lost my workload for a few days yesterday, I found that rm is a double-edged sword. Fortunately, my server takes snapshots, which makes me lose only one day's workload.
By personally experiencing the power of rm, I have to add a recycle bin in the future Linux maintenance and even in the production environment. I hope all of you children's shoes can keep a habit of having a recycle bin like me. Do not take a chance because you are very careful, "often walk by the river where there are wet shoes."
All right, let's start our way to create the Recycle Bin.
Start
First create a folder in your home directory to save the deleted files
Mkdir-p ~ / .Trash
Modify the .bashrc file
Vi / .bashrc
Add the following after the .bashrc file
Alias rm=trash
Alias rl='ls ~ / .Trash'
Alias ur=undelfile
Undelfile ()
{
Mv-I / .Trash/$@. /
}
Trash ()
{
Mv $@ ~ / .Trash/
}
Cleartrash ()
{
Read-p "Clear trash? [n]" confirm
[$confirm = ='y'] | | [$confirm = ='Y'] & & / usr/bin/rm-rf ~ / .Trash/*
}
Save after adding, and execute source command to take effect
Source / .bashrc
Use
You can now use the rm (delete), ur (undo), rl (list recycle bin), cleartrash (empty recycle bin) commands.
# Delete a folder, and all files under helloworld are moved to the Recycle Bin
$rm helloworld
# Delete a file
$rm abc.txt
# undo abc.txt
$ur abc.txt
# undo the helloworld folder
$ur helloworld
# list the Recycle Bin
$rl
# empty the Recycle Bin
Cleartrash
All right, focus on practice, this is a very important configuration, very important, I hope you don't do this like I've been through, or sometimes you really want to cry.
The above is how to use alias to achieve the Linux system Recycle Bin function, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.