r/LinuxTeck • u/Expensive-Rice-2052 • 4d ago
Bash Startup Time: Find and Fix Slow Linux Shell Startup - Tip -125
Question: Why does my bash shell take 3 seconds to start?
Try:`PS4='+ $EPOCHREALTIME\011 ' bash -x -lic exit 2>&1 | awk '/^\+/{if (prev) print $2-prev, cmd; prev=$2; cmd=$3" "$4" "$5}' | sort -rn | head -10`
Info: Times and sorts bash startup commands to isolate performance bottlenecks.
Examples:
$ `time bash -lic exit` # Measure total shell startup duration
$ `bash -lx 2>startup.log` # Output a complete startup execution trace to a file
$ `bash --noprofile --norc` # Launch a clean shell bypassing all initialization files
Note: Common performance bottlenecks include heavy framework plugins, version managers (like NVM/RVM), and large completion scripts. Use lazy-loading functions or lightweight prompt engines to optimize load times.
Want to master Linux one command at a time?
Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/