Tag Info

Hot answers tagged

10

iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 15 --connlimit-mask 32 -j REJECT --reject-with tcp-reset will reject connections above 15 from one source IP. sudo iptables -A INPUT -m state --state RELATED,ESTABLISHED -m limit --limit 150/second --limit-burst 160 -j ACCEPT In this 160 new connections (packets really) are ...


9

While it can be an abuse for memory, it isn't for CPU: when a CPU is idle, a running process (by "running", I mean that the process isn't waiting for I/O or something else) will take 100% CPU time by default. And there's no reason to enforce a limit. Now, you can set up priorities thanks to nice. If you want them to apply to all processes for a given user, ...


7

As someone who is using a btrfs filesystem with Arch Linux for almost 2 years now I can safely say that there does not seem to be a practical limit on the number of snapshots that can be easily reached. There are some caveats though. btrfs filesystem can lead to fragmentation. It is therefore advisable to use the online defragmentation feature built into ...


6

The timeout command will do this for you, i.e. timeout 10s command It will kill command after 10 seconds. Instead of s for seconds, you can also use m for minutes, h for hours or d for days.


5

There is big difference between them. ulimit -e only set the RLIMIT_NICE, which is a upper bound value to which the process's nice value can be set using setpriority or nice. renice alters the priority of running process. Doing strace: $ cat test.sh #!/bin/bash ulimit -e 19 Then: $ strace ./test.sh ................................................... ...


5

He's saying it's bound by a 64-bit type, which has a maximum value of (2 ^ 64) - 1 unsigned, or (2 ^ 63) - 1 signed (1 bit holds the sign, +/-). The type is not FILE; it's what the implementation uses to track the offset into the file, namely off_t, which is a typedef for a signed 64-bit type.1 (2 ^ 63) - 1 = 9223372036854775807. If a terabyte is 1000 ^ ...


5

Did you look at cgroups? There is some information on the Arch Wiki about them. Read the section about cpu.shares, it looks like it's doing what you need, and they can operate on a user-level, so you can limit all user processes at once.


5

You would not necessarily see error messages in your systems log, when chromium is overstepping some limits. Try starting chromium from a terminal (rather than clicking on icon), so that you can see any potential error messages in the terminal. What you are describing seems to be similar to this bugreport. The solution should be to increase the limits ...


4

Increase hard/soft limit. /etc/security/limits.conf Thus far a limit of 8192 seems to be enough. 4096 have proven to be to small. Optionally only increase hard limit (if needed) and do: ulimit -Sn 8192 from shell in which Chrome is started. Note that the use of (the somewhat wide spread) way: sudo sh -c "ulimit -n 8192 && exec su -i ...


4

The value can only be extended up to a theoretical maximum of 32768 for 32 bit systems or 4194304 for 64 bit. From man 5 proc: /proc/sys/kernel/pid_max This file (new in Linux 2.5) specifies the value at which PIDs wrap around (i.e., the value in this file is one greater than the maximum PID). The default value for this file, 32768, results in the ...


4

Probably a limit of the terminal device line discipline internal line editor buffer. You should be able to enter long lines by pressing Ctrl+D in the middle of it (so the currently entered part be sent to cat and the line editor flushed), or by disabling that line editor altogether. For instance, if using zsh: STTY=-icanon cat > file Note that then ...


3

You want the following rules in your iptables to answer both requirements in your question: iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT iptables -t filter -I INPUT -p tcp --dport 80 -m state \ --state RELATED,ESTABLISHED -j ACCEPT # Adjust "--connlimit-above NN" to limit the maximum connections per IP # that you need. iptables -t filter -I ...


3

pv doesn't know about the system power states. All it sees is that the clock changed by a very large amount at some point. My guess is that pv doesn't care if the amount of time between two clock readouts suddenly gets large and just calculates the throughput based on the time interval. Since the interval is very large, it appears that the throughput is ...


3

You need to use the connlimit modules which allows you to restrict the number of parallel TCP connections to a server per client IP address (or address block). /sbin/iptables -I INPUT -p tcp --syn --dport 80 -m connlimit \ --connlimit-above 10 -j DROP


3

I assume you're not describing your real-world scenario: not only do you want to copy hundreds of thousands of files, but you want to sleep for hundreds of thousands of seconds... wtf?!? Anyway: while IFS= read -r file1 IFS= read -r file2 do cp "$file1" "${file1##*/}-backup" cp "$file2" "${file2##*/}-backup" sleep 1 done < inputFile


2

I am not sure if this answers your question, but I found this perl script that claims to do exactly what you are looking for. The script implements its own system for enforcing the limits by waking up and checking the resource usage of the process and its children. It seems to be well documented and explained, and has been updated recently. As slm said in ...


2

For memory, what you are looking for is ulimit -v. Note that ulimit is inherited by child processes, so if you apply it to the login shell of the user at the time of login, it applies to all his processes. If your users all use bash as login shell, putting the following line in /etc/profile should cause all user processes to have a hard limit of 1 gigabyte ...


2

You should probably take a look inside /etc/pam.d/sudo file and check if pam_limits.so is required in it or in any of the other files it includes. For example, the /etc/pam.d/sudo file in my system looks like below. #%PAM-1.0 auth required pam_env.so readenv=1 user_readenv=0 auth required pam_env.so readenv=1 envfile=/etc/default/locale ...


2

You need to complete some more steps to increase max open files in ubuntu. Edit /etc/pam.d/common-session and append below line session required pam_limits.so Restart your system to apply the changes. You can set limits to all users on system by adding below lines. * soft nofile 10000 * hard nofile 30000 And reboot the ...


2

scp itself has no such feature. With GNU parallel you can use the sem command (from semaphore) to arbitrarily limit concurrent processes: sem --id scp -j 50 scp ... For all processes started with the same --id, this applies a limit of 50 concurrent instances. An attempt to start a 51st process will wait (indefinitely) until one of the other processes ...


2

I am not aware of any size limits for here-doc. I'm running kernel 3.9.1 and I've been experiencing the same issue here: when pasting large chunks of text in terminal some lines are truncated or missing. I found out (after some googling) that if you turn off line editing, pasting works fine (discussion here: Pasting large amounts of text into ...


1

Sorry: I have not noticed the "txt file" with the "hundreds thousands of lines". This is just a naif solution... for a in test*; do ls -l $a; if [[ $((i++ % 2)) != 0 ]]; then sleep 1; fi; done Update: Explanation and (partially update to txt file with filenames). ...reformating: for a in `cat file.txt` do cp "$a" "$a-backup" ## REPLACE ...


1

Split urls into one file per host. Then run 'parallel -j5' on each file. Or sort urls and insert a delimiter '\0' when a new host is met, then split on '\0' and remove '\0' while passing that as a block to a new instance of parallel: sort urls.txt | perl -pe '(not m://$last:) and print "\0";m://([^/]+): and $last=$1' | parallel -j10 --pipe --rrs -N1 ...


1

ulimit is trying to increase the the maximum usage of those resources above that configured for the entire system by sysctl. Furthermore it's not actually possible to configure Linux with an unlimited number of some resources, such as open files. Note that unlimiting all resources is not a good idea -- do you really want a few gigabytes of core dump should ...


1

It depends on your systems cryptographic hash used to store the passwords. do sudo cat /etc/shadow and look for the username followed by $number$ $1$ means you are using MD5 $2$ or $2a$ means you are using blowfish $5$ means you are using SHA-256 $6$ means you are using SHA-512 for example, sha-512 would give you a 2^512 max length. sha-256, 2^256th. ...


1

Thanks to @hrv for the insight. I've confirmed after a quick experiment: when the /etc/pam.d/sudo included pam_limits.so, then running sudo did set them, and when the /etc/pam.d/sudo did not include them, then running sudo didn't set them. I checked a couple of different machines and one of them did include pam_limits.so within /etc/pam.d/sudo while the ...


1

The solution you found was correct: iptables -A OUTPUT -m limit --limit 10/s -j ACCEPT But it is assuming a default policy of DROP or REJECT which is not usual for OUTPUT. You need to add: iptables -A OUTPUT -j REJECT Be sure to add this rule after the ACCEPT one. Either execute them in this order, or use -I instead of -A for the ACCEPT. Also, ...


1

There are two settings that limit the number of open files: a per-process limit, and a system-wide limit. The system-wide limit is set by the fs.file-max sysctl, which can be configured in /etc/sysctl.conf (read at boot time) or set on the fly with the sysctl command or by writing to /proc/sys/fs/file-max. The per-process limit is set by ulimit -n. The ...


1

With the comment from @Mark Plotnick, I finally figured out the reason ls -l "/proc/$(pidof node)/exe" returns lrwxrwxrwx 1 antony antony 0 Aug 27 13:04 /proc/4414/exe -> /usr/bin/nodejs So instead of node, I should have used nodejs The following command works cpulimit -l 50 -e nodejs Update: this is actually not a bullet-proof solution. Yes, ...


1

cpulimit is known not to work well in some cases. Sometimes it works quite well (on simple single threaded apps) and other times (mostly mutli-threaded or muti-process) it doesn't work. Technically speaking, there are two issues that could cause cpulimit to not limit. First is that the program your trying to run spawns a thread or process in such a way ...



Only top voted, non community-wiki answers of a minimum length are eligible