![轻松访问自制程序](https://linux22.com/image/998913/%E8%BD%BB%E6%9D%BE%E8%AE%BF%E9%97%AE%E8%87%AA%E5%88%B6%E7%A8%8B%E5%BA%8F.png)
我有一个名为 Log 的程序。我想运行 log,但通常我必须转到 ~ 目录并使用命令./Log
。我该如何做才能使用该命令Log
从任何目录执行相同的操作?我必须将其添加到吗/usr/bin
?谢谢!
这是我的 ~/.profile 文件:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
alias log=/home/sqidman310/Log
答案1
最简单的方法(不是唯一的方法)是在你的 bash 配置文件中创建一个别名。
~/.profile
只需添加它并填写你的具体信息
alias log=/path/to/log