温馨提示×

linux aliases怎么禁用

小樊
49
2026-09-02 04:28:46
栏目: 智能运维

在 Linux 里,“禁用 alias”通常有几种场景,下面按常见情况给你说明:


1. 临时禁用某个 alias(当前 shell 有效)

使用 \command 绕过 alias:

\ls
command ls

这样可以忽略 ls 的 alias,直接执行原命令。


2. 当前 shell 中取消某个 alias

unalias

unalias ll

只影响当前 shell 会话。


3. 永久禁用 alias(不加载)

alias 一般定义在以下文件中:

  • ~/.bashrc
  • ~/.bash_aliases
  • ~/.zshrc(zsh)
  • /etc/bashrc/etc/profile(系统级)

方法:

  • 编辑对应文件,删除或注释掉 alias 行:
    # alias ll='ls -l'
    
  • 然后重新加载:
    source ~/.bashrc
    

4. 登录时完全不加载 alias

如果你不想加载任何 alias,可以:

  • 用非交互 shell:
    bash --norc
    
  • 或在脚本中使用:
    #!/bin/bash --norc
    

5. 查看当前有哪些 alias

alias

如果你能说明是 bash / zsh临时还是永久单个还是全部 alias,我可以给你更精确的命令。

0