리눅스 명령어 별칭 alias, unalias

Jmnote (토론 | 기여)님의 2014년 4월 6일 (일) 09:50 판 (→‎실습)

alias
앨리어스, 에일리어스, 알리아스
unalias
언앨리어스

1 alias

  • 리눅스 bash 단축 별칭 조회/지정 명령어

2 unalias

  • 리눅스 bash 단축 별칭 해제 명령어

3 alias 목록

CentOS
[root@jmnote ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
Ubuntu
root@Ubuntu01:~# alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

4 실습

[root@jmnote ~]# alias | grep mv
alias mv='mv -i'
[root@jmnote ~]# unalias mv
[root@jmnote ~]# alias | grep mv
[root@jmnote ~]#
→ unalias의 효과는 현재 세션에만 유효하다. 새로 SSH 접속하거나 재부팅하면 원복된다.

그 이유는 다음과 같이 alias를 지정하는 스크립트가 실행되기 때문...

[root@jmnote ~]# grep -Hn ^alias ~/.bashrc
/root/.bashrc:5:alias rm='rm -i'
/root/.bashrc:6:alias cp='cp -i'
/root/.bashrc:7:alias mv='mv -i'
[root@jmnote ~]# grep -Hn ^alias /etc/profile.d/*.sh
/etc/profile.d/colorls.sh:38:alias ll='ls -l --color=auto' 2>/dev/null
/etc/profile.d/colorls.sh:39:alias l.='ls -d .* --color=auto' 2>/dev/null
/etc/profile.d/colorls.sh:40:alias ls='ls --color=auto' 2>/dev/null
/etc/profile.d/which2.sh:4:alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

5 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}