Memo/CLI (Linux&cmd)

[Linux] 리눅스 명령어 단축어 설정 - alias

cassan 2023. 6. 25. 18:18

요약

  • home/(root 또는 계정명)/.bashrc 또는 .bash_profile 파일 에 alias 추가

사용하려는 파일은 각자 상황에 맞춰서 적용. (단 .bash_profile 파일의 경우 갱신절차 . .bash_profile 필요)

[/home/oracle]$ pwd  # 현재 계정명이 oracle임 
/home/oracle 
[/home/oracle]$ ls -la
total 60
drwx------. 6 oracle dba   4096 Jun 12 05:02 .
drwxr-xr-x. 3 root   root    20 May  6 11:40 ..
-rw-------. 1 oracle dba   2460 Jun 11 22:58 .bash_history
-rw-r--r--. 1 oracle dba     18 Aug  2  2022 .bash_logout
-rw-r--r--. 1 oracle dba    729 Jun 12 05:02 .bash_profile  <<<<< ✅
-rw-r--r--. 1 oracle dba    376 Aug  2  2022 .bashrc        <<<<< ✅
 ... 
[/home/oracle]$ vi .bash_profile 
 ... 
alias d2='df -h'
 ...
[/home/oracle]$ . .bash_profile  # 갱신
[/home/oracle]$ d2
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             1.3G     0  1.3G   0% /dev
tmpfs                1.3G     0  1.3G   0% /dev/shm
tmpfs                1.3G  8.6M  1.3G   1% /run
tmpfs                1.3G     0  1.3G   0% /sys/fs/cgroup
/dev/mapper/ol-root  183G   17G  167G   9% /
/dev/sda1           1014M  275M  740M  28% /boot
tmpfs                265M     0  265M   0% /run/user/54321

아래는 bashrc 파일 설정

반응형