endaaman.com

2016-10-15

Tips

Linuxで一般ユーザーのPATHにsbinが通ってないとき

Bashでも

bash: ifconfig: command not found

Zshでも

$ ifconfig
zsh: command not found: ifconfig

みたいな感じになるときは、~/.bashrc~/.zshrcを編集するのではなく、まず/etc/profileを覗いてみるべきである。そうすると

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

©2024 endaaman.com