"리눅스 명령어 별칭 alias, unalias"의 두 판 사이의 차이

 
(사용자 3명의 중간 판 12개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{소문자}}
{{다른뜻|SQL 별칭}}
;alias
;alias
;앨리어스, 에일리어스, 알리아스
;앨리어스, 에일리어스, 알리아스
7번째 줄: 7번째 줄:


==alias==
==alias==
*리눅스 bash 단축 별칭 조회/지정 명령어
* 리눅스 bash 단축 별칭 조회/지정 명령어
* 흔히 [[~/.bashrc]]에 추가하여 설정함


;alias 설정 조회
;alias 설정 조회
<source lang='bash'>
<syntaxhighlight lang='bash'>
alias
alias
</source>
</syntaxhighlight>


;alias 추가
;alias 추가
<source lang='bash'>
<syntaxhighlight lang='bash'>
alias 단축명='실행할명령어'
alias 단축명='실행할명령어'
</source>
</syntaxhighlight>


==unalias==
==unalias==
23번째 줄: 24번째 줄:


;단축명 해제
;단축명 해제
<source lang='bash'>
<syntaxhighlight lang='bash'>
unalias 단축이름
unalias 단축이름
</source>
</syntaxhighlight>


==alias 목록==
==alias 목록==
;CentOS
;CentOS
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# alias
[root@zetawiki ~]# alias
alias cp='cp -i'
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias l.='ls -d .* --color=tty'
38번째 줄: 39번째 줄:
alias rm='rm -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
</source>
</syntaxhighlight>


;Ubuntu
;Ubuntu
<source lang='dos'>
<syntaxhighlight lang='console'>
root@Ubuntu01:~# alias
root@Ubuntu01:~# alias
alias egrep='egrep --color=auto'
alias egrep='egrep --color=auto'
50번째 줄: 51번째 줄:
alias ll='ls -alF'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias ls='ls --color=auto'
</source>
</syntaxhighlight>


==실습==
==실습==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# alias | grep mv
[root@zetawiki ~]# alias | grep mv
alias mv='mv -i'
alias mv='mv -i'
[root@jmnote ~]# unalias mv
[root@zetawiki ~]# unalias mv
[root@jmnote ~]# alias | grep mv
[root@zetawiki ~]# alias | grep mv
[root@jmnote ~]#  
[root@zetawiki ~]#  
</source>
</syntaxhighlight>
:→ unalias 명령어로 mv에 대한 alias를 삭제하였다.
:→ unalias 명령어로 mv에 대한 alias를 삭제하였다.
:→ unalias의 효과는 현재 세션에만 유효하다. 새로 SSH 접속하거나 재부팅하면 원복된다.
:→ unalias의 효과는 현재 세션에만 유효하다. 새로 SSH 접속하거나 재부팅하면 원복된다.
그 이유는 다음과 같이 alias를 지정하는 스크립트가 실행되기 때문...
그 이유는 다음과 같이 alias를 지정하는 스크립트가 실행되기 때문...
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# grep -Hn ^alias ~/.bashrc
[root@zetawiki ~]# grep -Hn ^alias ~/.bashrc
/root/.bashrc:5:alias rm='rm -i'
/root/.bashrc:5:alias rm='rm -i'
/root/.bashrc:6:alias cp='cp -i'
/root/.bashrc:6:alias cp='cp -i'
/root/.bashrc:7:alias mv='mv -i'
/root/.bashrc:7:alias mv='mv -i'
</source>
</syntaxhighlight>
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# grep -Hn ^alias /etc/profile.d/*.sh
[root@zetawiki ~]# 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: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: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/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'
/etc/profile.d/which2.sh:4:alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[ll]]
{{z컬럼3|
*[[.bashrc]]
* [[리눅스 ll]]
*[[type]]
* [[리눅스 type]]
*[[bash 빌트인 명령어]]
* [[리눅스 command]]
*[[/root/.bashrc]]
* [[bash 빌트인 명령어]]
*[[/etc/profile.d/colorls.sh]]
* [[.bashrc]]
*[[/etc/profile.d/which2.sh]]
* [[/root/.bashrc]]
*[[리눅스 cp 강제로 덮어쓰기]]
* [[리눅스 newaliases]] (메일 별칭 재구축)
*[[파워쉘 Get-Alias]]
* [[/etc/profile.d/colorls.sh]]
*[[리눅스 newaliases]]
* [[/etc/profile.d/which2.sh]]
* [[리눅스 cp 강제로 덮어쓰기]]
* [[파워쉘 Get-Alias]]
}}


[[분류: 리눅스]]
[[분류: 리눅스]]
[[분류: alias]]
[[분류: Bash 빌트인]]
[[분류: Bash 빌트인]]

2022년 10월 25일 (화) 14:03 기준 최신판

  다른 뜻에 대해서는 SQL 별칭 문서를 참조하십시오.
alias
앨리어스, 에일리어스, 알리아스
unalias
언앨리어스, 어네일리어스

1 alias[ | ]

  • 리눅스 bash 단축 별칭 조회/지정 명령어
  • 흔히 ~/.bashrc에 추가하여 설정함
alias 설정 조회
alias
alias 추가
alias 단축명='실행할명령어'

2 unalias[ | ]

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

3 alias 목록[ | ]

CentOS
[root@zetawiki ~]# 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@zetawiki ~]# alias | grep mv
alias mv='mv -i'
[root@zetawiki ~]# unalias mv
[root@zetawiki ~]# alias | grep mv
[root@zetawiki ~]#
→ unalias 명령어로 mv에 대한 alias를 삭제하였다.
→ unalias의 효과는 현재 세션에만 유효하다. 새로 SSH 접속하거나 재부팅하면 원복된다.

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

[root@zetawiki ~]# 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@zetawiki ~]# 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 }}