linux - 如何在 *nix 中登录时运行脚本?

标签 linux bash macos unix shell

我知道我曾经知道如何执行此操作,但是...如何在 unix 登录时运行脚本(bash 可以)?

最佳答案

来自 wikipedia Bash

When Bash starts, it executes the commands in a variety of different scripts.

When Bash is invoked as an interactive login shell, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

When a login shell exits, Bash reads and executes commands from the file ~/.bash_logout, if it exists.

When an interactive shell that is not a login shell is started, Bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force Bash to read and execute commands from file instead of ~/.bashrc.

关于linux - 如何在 *nix 中登录时运行脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/97137/

相关文章:

linux - 使用并行端口中断

c - JACK C + Ubuntu (GNU/Linux) 录音/播放编程

c - linux下如何获取随机文件?包括子目录

linux - Linux内核中init进程是如何启动的?

linux - 使用 bash 从文本文件中提取单词

macos - "Cannot create asynchronous query while in a write transaction"异常

c - 统计信息未显示正确的 inode 号

linux - nvcc 从命令行而不是从 shell 运行

objective-c - Retina 显示屏的字体大小

c - 奇怪的 C 编译器,出现错误 "ld: duplicate symbol _main"