HowTo: Linux Limit A Specific User's Shell Account Network Bandwidth Using Bash Shell and Trickle

www.‮.iruttual‬com
HowTo: Linux Limit A Specific User's Shell Account Network Bandwidth Using Bash Shell and Trickle

To limit the network bandwidth of a specific user's shell account on a Linux system, you can use the trickle utility. Trickle is a simple bandwidth shaper that can be used to limit the network bandwidth of specific programs.

Here's how you can use trickle to limit the network bandwidth of a specific user's shell account:

  1. Install trickle:
sudo apt-get install trickle
  1. Open the .bashrc file for the user whose network bandwidth you want to limit:
nano ~/.bashrc
  1. At the end of the .bashrc file, add the following line to limit the user's network bandwidth to a specific rate:
alias trickle='trickle -d <rate>'

Replace <rate> with the desired rate in kilobits per second (kbps). For example, to limit the user's network bandwidth to 128 kbps, you would use the following line:

alias trickle='trickle -d 128'
  1. Save the changes to the .bashrc file and exit.

  2. Log out and log back in for the changes to take effect.

Now, when the user runs a command, it will be limited to the specified network bandwidth rate. For example, to limit the wget command to 128 kbps, the user can use the following command:

trickle wget http://example.com/file.zip

Note that this method only works for programs that are run from the command line. It will not work for programs that use a GUI or programs that run in the background.

Created Time:2017-10-29 22:08:43  Author:lautturi