Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux:tips [2009/03/03 16:23] 89.212.110.65 added screenify link, explained sudo redirection |
linux:tips [2015/05/08 12:09] zagi |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== General linux tips and tricks ====== | ====== General linux tips and tricks ====== | ||
+ | |||
+ | |||
+ | ===== Limit the CPU usage of an application (process) - cpulimit ===== | ||
+ | |||
+ | === Installation: | ||
+ | |||
+ | Download last stable version of [[http:// | ||
+ | Then extract the source and compile with make: | ||
+ | |||
+ | tar zxf cpulimit-xxx.tar.gz | ||
+ | cd cpulimit-xxx | ||
+ | make | ||
+ | |||
+ | Executable file name is cpulimit. You may want to copy it in /usr/bin. | ||
+ | |||
+ | Usage: | ||
+ | Limit the process ' | ||
+ | |||
+ | cpulimit --exe bigloop --limit 40 | ||
+ | cpulimit --exe / | ||
+ | |||
+ | Limit a process by PID to 55% CPU: | ||
+ | |||
+ | cpulimit --pid 2960 --limit 55 | ||
+ | |||
+ | <note tip> | ||
+ | If your machine has one processor you can limit the percentage from 0% to 100%, which means that if you set for example 50%, your process cannot use more than 500 ms of cpu time for each second. But if your machine has four processors, percentage may vary from 0% to 400%, so setting the limit to 200% means to use no more than half of the available power. In any case, the percentage is the same of what you see when you run top. | ||
+ | </ | ||
===== Move a running process into a screen session ===== | ===== Move a running process into a screen session ===== | ||
[[http:// | [[http:// | ||
- | < | + | < |
#!/bin/sh | #!/bin/sh | ||
# Copyright Timo Lindfors 2004 | # Copyright Timo Lindfors 2004 | ||
Line 90: | Line 118: | ||
This will cleanly unmount drives, terminate processes and nicely reboot your machine. | This will cleanly unmount drives, terminate processes and nicely reboot your machine. | ||
+ | |||
+ | <note important> | ||
**also for more detailed info see:** [[http:// | **also for more detailed info see:** [[http:// | ||
Line 236: | Line 266: | ||
| 2 | To free dentries and inodes | | | 2 | To free dentries and inodes | | ||
| 3 | To free pagecache, dentries and inodes | | | 3 | To free pagecache, dentries and inodes | | ||
+ | |||
+ | ===== Linux memory management ===== | ||
+ | |||
+ | Memory overcommit can be configured via two parameters: | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | From Red Hat manual: | ||
+ | |||
+ | * **'' | ||
+ | * **0** — The kernel performs heuristic memory over commit handling by estimating the amount of memory available and failing requests that are blatantly invalid. Unfortunately, | ||
+ | * **1** — The kernel performs no memory over commit handling. Under this setting, the potential for memory overload is increased, but so is performance for memory intensive tasks (such as those executed by some scientific software). | ||
+ | * **2** — The kernel fails requests for memory that add up to all of swap plus the percent of physical RAM specified in ''/ | ||
+ | |||
+ | //**Note** This setting is only recommended for systems with swap areas larger than physical memory.// | ||
+ | |||
+ | * **'' | ||
+ | |||
===== / | ===== / | ||
Line 252: | Line 302: | ||
* If you want kernel to swap out more process memory and thus cache more file contents increase the value. Otherwise, if you would like kernel to swap less decrease it. | * If you want kernel to swap out more process memory and thus cache more file contents increase the value. Otherwise, if you would like kernel to swap less decrease it. | ||
* More info [[http:// | * More info [[http:// | ||
+ | |||
+ | Example: | ||
+ | * '' | ||
+ | * '' | ||
+ | * A value of '' | ||
+ | |||
===== Getting rid of that obsolete delay after password authentication ===== | ===== Getting rid of that obsolete delay after password authentication ===== | ||
Line 304: | Line 360: | ||
If you have a reliable server with a good RAID card and power supply, you could set the dirty_ratio to 100 and the dirty_background_ratio to 1. This was recommended by a buddy of mine who runs quite a few servers running virtual machines. | If you have a reliable server with a good RAID card and power supply, you could set the dirty_ratio to 100 and the dirty_background_ratio to 1. This was recommended by a buddy of mine who runs quite a few servers running virtual machines. | ||
+ | |||
+ | ===== convert files from ISO to UTF-8 ==== | ||
+ | |||
+ | < | ||
+ | for x in `find . -name ' | ||
+ | </ | ||
+ | |||
===== How do I force users to change their passwords upon first login? ===== | ===== How do I force users to change their passwords upon first login? ===== | ||
Line 319: | Line 382: | ||
# usermod -U < | # usermod -U < | ||
+ | === space report === | ||
+ | for i in `ls -1 /home`;do du -sh / |