Setting default nice value for a program on linux

Instead of messing up your /usr/bin and getting hosed every update, why not use a ~/.local/bin ?

## one-time setup
mkdir -p ~/.local/bin
# prepend new path to PATH to give it priority
echo 'PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
# then open new terminal or
source ~/.bashrc

## create a wrapper script
# $@ is there to passthrough args.
echo 'nice -10' `which firefox` '$@' > ~/.local/bin/firefox
# make it executable
chmod +x ~/.local/bin/firefox

# check sanity
which firefox
cat `which firefox`

You have to work around a bit.

First get the full path of the firefox binary:

which firefox
/usr/bin/firefox

Now, move that to, for example, firefox-original:

mv /usr/bin/firefox /usr/bin/firefox-original

Now, create a small handler script called /usr/bin/firefox that will be called instead of the original firefox binary:

cat /usr/bin/firefox
#!/bin/bash

exec nice - n 10 /usr/bin/firefox-original "$@"

Finally make the script executable:

chmod 755 /usr/bin/firefox

Now everytime firefox is started, that script executes the binary with a nice value of 10. The $@ just means to pass all the arguments of the script to the binary.