“This is the 8th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

Cancels the command alias function

 #01 Cancel command alias method: use \
   [root@fu ~]# \cp /mnt/test.txt /tmp/

Copy the code
 #02 Command alias method: Execute commands using absolute paths
   [root@fu ~]# which cp # Check the user's absolute path
      alias cp='cp -i'
     	/bin/cp
   [root@fu ~]# /bin/cp /mnt/test.txt /tmp/
Copy the code

Added: How to customize the alias in the system

01.Step 1: Set the alias [root@fu ~]# alias oldboy='echo oldboysh02'Step 2: Perform alias function tests [root@fu ~]# oldboy
   oldboysh02
   [root@fu ~]# alias | grep "oldboy" grep filters
   alias oldboy='echo oldboysh02'
Copy the code
  02.Permanent alias Step 1: Set the alias [root@fu ~]# alias oldboy='echo oldboysh02'Vim /etc/profile <-- Load the configuration command file (this file will be read with each reboot)alias oldboy='echo oldboysh02'Another option: place temporary commands into a file echo"alias oldboy='echo oldboysh02'">>/etc/profile Added: head2 -/etc/profile Check the first two lines of the file2 -/etc/profile View the last two lines of the file step 3: load identify the Settings in the /etc/profile file source /etc/profile Step 4: Test [root@fu ~]# oldboy
   oldboysh02
   [root@fu ~]# 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 oldboy='echo oldboysh02'
   alias rm='rm -i'
   alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
   [root@fu ~]# alias|grep oldboy
   alias oldboy='echo oldboysh02'
Copy the code

Enterprise practice: Insure dangerous RM commands (alias)

The first mileage: configure the aliasalias rm='echo" datainfo can not del"'Second milestone: Start editing a file to make the alias feature permanent echo"alias rm='echo" datainfo can not del"'" >>/etc/profile
   [root@fu data]# tail -1 /etc/profile
   alias rm='echo datainfo can not del'The third mile: load the configuration file source /etc/profile the fourth mile: disable the alias function of the default system (rm) PS: some default configurations in the system, do not delete them when editing, you can temporarily comment out vim /root/.bashrc#alias rm='rm -i'Common mistakes:01.Don't list the quotes must be commandsalias rm='Do not delete.'Error funny configuration method02.Do not list quotation marks in English formatalias rm='echo rm command do not use'
Copy the code