Linux之CentOS設定別名與屏蔽別名

來源:互聯網
上載者:User

標籤:bsp   符號   tail   roo   操作   圖片   host   生效   --   

一、環境

CentOS6.8

二、設定別名

◆別名功能:讓grep符合的關鍵字高亮

1、臨時生效

[[email protected] ~]#alias grep="grep --color=auto"
[[email protected] ~]#alias //檢查

2、永久生效

方法一  編輯/etc/profile【對所有使用者生效(永久的)】

[[email protected] ~]#echo "alias grep=‘grep --color=auto‘">>/etc/profile
[[email protected] ~]#tail -1 /etc/profile
[[email protected] ~]#source /etc/profile

方法二  編輯/etc/.bashrc【只對當前所登陸的使用者生效(永久的)】

[[email protected] ~]#echo "alias grep=‘grep --color=auto‘">>/.bashrc
[[email protected] ~]#tail -1 .bashrc
[[email protected] ~]#source .bashrc

三、預設設定別名帶來的問題

當從某個目錄下cp或mv某個檔案到另一個目錄下的時候,如果該目錄下存在與移動檔案同名的檔案,會輸出是否覆蓋此檔案的提示讓操作者選擇,這是因為CentOS系統事先預設配置了某些命令別名(1-1)。如果複製或移動某個目錄下的檔案到另一個目錄下存在大量需要覆蓋檔案名稱,那麼這將使得cp或mv命令操作顯得特別繁瑣(1-2)。

圖1-1

圖1-2

 

四、屏蔽別名的方法

1、執行命令時用命令的絕對路徑

2、命令前面加"\"符號

 

Linux之CentOS設定別名與屏蔽別名

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.