In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What's an alias?
A large number of commands will be used in the process of administering and maintaining Linux systems. Some long commands or usages are often used. It is not advisable to type a long command or usage repeatedly and frequently. This can be simplified by using aliases.
Linux system under some commands such as rm cp mv, etc. These commands are delete mobile and the like to be cautious when using, you can also set aliases to carry out some reminders in disguise
simply put
1. Give warning before using dangerous commands cp rm mv
2. Complex commands are easier to use
Problem: configure alias do not use rm for rm, that is, when running rm command, the system prompts do not use rm.
1. The command to output do not use rm to the screen interface is echo.
[root@liuhao ~]# echo "do not use rm"do not use rm[root@liuhao ~]#
2. View existing aliases
[root@liuhao ~]# alias alias cp='cp -i'alias l.= 'ls -d .* --color=auto'alias ll='ls -l --color=auto'alias ls='ls --color=auto'alias mv='mv -i'alias rm='rm -i'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
3.1 Configure aliases for rm do not use rm
[root@liuhao ~]# alias rm='echo do not use rm'
Note: = Enter characters directly without spaces on both sides
3.2 check
[root@liuhao ~]# alias alias cp='cp -i'alias l.= 'ls -d .* --color=auto'alias ll='ls -l --color=auto'alias ls='ls --color=auto'alias mv='mv -i'alias rm='echo do not use rm'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'[root@liuhao ~]# rm /data/oldboy.txt do not use rm /data/oldboy.txt[root@liuhao ~]#
Note: The alias has been configured successfully, but only for this connection. The alias will be invalid after the xshell connection is disconnected or the system is restarted.
4.1 Make configured aliases permanent
[root@liuhao ~]# vim /etc/profile
vim editor G means straight to the bottom o (lowercase o) means another line below the current line
When you enter vim, press capital G and then lowercase O.
Enter the following command to ensure that it is at the lowest end
##alias rm='echo do not use rm'
4.2 Check whether the input is successful and output the last two lines of the file with tail
[root@liuhao ~]# tail -2 /etc/profile##alias rm='echo do not use rm'[root@liuhao ~]#
5. Make configuration effective source
[root@liuhao ~]# source /etc/profile[root@liuhao ~]# rm /data/oldboy.txt do not use rm /data/oldboy.txt[root@liuhao ~]#
6. Modify/root/.bashrc
[root@liuhao ~]# vim /root/.bashrc#alias rm='rm -i'alias cp='cp -i'alias mv='mv -i'
Add #to alias rm='rm -i' as shown above and exit vim and save
7.rm has set up alias state how to delete things
7.1 Now directly use rm status
[root@liuhao ~]# rm /data/oldboy.txt do not use rm /data/oldboy.txt[root@liuhao ~]# rm -f /data/oldboy.txt do not use rm -f /data/oldboy.txt[root@liuhao ~]# rm -r /data/oldboy.txt do not use rm -r /data/oldboy.txt[root@liuhao ~]#
You cannot delete files directly using RM
7.2 How to delete files
method one
[root@liuhao ~]# \rm /data/oldboy.txt \means temporarily cancel alias
methodology II
[root@liuhao ~]# which rm[root@liuhao ~]# /bin/rm /data/liuhao.txt
which rm can view the absolute path of the rm command
summary
The above is a small series to introduce you to the Linux system for command configuration alias, I hope to help you, if you have any questions please give me a message, small series will reply to you in time. Thank you very much for your support!
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.