Tag Info

Hot answers tagged

78

You can write a C program to malloc the required memory and then use mlock() to prevent the memory from being swapped out. Then just let the program wait for keyboard input, and unlock the memory, free the memory and exit.


43

stress is a workload generator that simulates cpu/mem/io/hdd stress on POSIX systems. This call should do the trick on Linux: stress --vm-bytes $(awk '/MemFree/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 1 Adapt the /proc/meminfo call with free(1)/vm_stat(1)/etc. if you need it portable.


42

I would suggest running a VM with limited memory and testing the software in that would be a more efficient test than trying to fill memory on the host machine. That method also has the advantage that if the low memory situation causes OOM errors elsewhere and hangs the whole OS, you only hang the VM you are testing in not your machine that you might have ...


40

Simply switch your repos to testing and do a full upgrade: # cp /etc/apt/sources.list{,.bak} # sed -i -e 's/ \(stable\|wheezy\)/ testing/ig' /etc/apt/sources.list # apt-get update # apt-get --download-only dist-upgrade # apt-get dist-upgrade Make sure you stay plugged in for the duration of the last command, though. If it's botched or incomplete and you ...


26

run linux; boot with mem=nn[KMG] kernel boot parameter (look in linux/Documentation/kernel-parameters.txt for details).


21

From this HN comment: https://news.ycombinator.com/item?id=6695581 Just fill /dev/shm via dd or similar. swapoff -a dd if=/dev/zero of=/dev/shm/fill bs=1k count=1024k


10

How about ramfs if it exists? Mount it and copy over a large file? If there's no /dev/shm and no ramfs - I guess a tiny C program that does a large malloc based on some input value? Might have to run it a few times at once on a 32 bit system with a lot of memory.


7

If you want to test a particular process with limited memory you might be better off using ulimit to restrict the amount of allocatable memory.


7

I keep a function to do something similar in my dotfiles. https://github.com/sagotsky/.dotfiles/blob/master/.functions#L248 function malloc() { if [[ $# -eq 0 || $1 -eq '-h' || $1 -lt 0 ]] ; then echo -e "usage: malloc N\n\nAllocate N mb, wait, then release it." else N=$(free -m | grep Mem: | awk '{print int($2/10)}') if [[ $N -gt $1 ]] ...


6

I'm just repeating the answers listed on this (deleted?) stackoverflow question: http://stackoverflow.com/questions/426272/how-to-test-internet-connection-speed-from-command-line k2z: wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip or git clone https://github.com/sivel/speedtest-cli cd speedtest-cli ...


6

Using PAM is the best solution. You can write small C code, or install python-pam package and use a python script which comes with the python-pam package. See /usr/share/doc/python-pam/examples/pamtest.py


5

To simply see if a drive can be read, you can use dd(1). This will read in the contents of the CDROM and will ignore/discard the data (note that the CDROM device may have another name on your system): dd if=/dev/cdrom of=/dev/null It is also possible to compare this to an ISO image: dd if=/dev/cdrom | md5sum - /path/to/file.iso This will print a ...


5

From the bash(1) man page: -n Read commands but do not execute them. This may be used to check a shell script for syntax errors. This is ignored by interactive shells.


4

For a low-level check, I found qpxtool. With my drive (which, to be fair, is not on the supported devices list), the results didn't make sense, but maybe you will have better luck.


4

You can use dmsetup to create a device-mapper device using either the error or flakey targets to simulate failures. dmsetup create test --table '0 123 flakey 1 0 /dev/loop0' Where 123 is the length of the device, in sectors and /dev/loop0 is the original device that you want to simulate errors on. For error, you don't need the subsequent arguments as it ...


4

As for the tutorial, search engines seem to work, e.g. this one on howtoforge.com seems to give reasonable hints. Generally you might want to reconsider what exactly you are trying to achieve in the end. While eCryptfs will (to some degree) guarantee confidentiality you should be aware of several things: to hide the contents of home directory from other ...


4

Try out: dd if=/dev/urandom | bzip2 -9 >> /dev/null or use stress, a tool specifically designed to impose load on and stress test systems. It will launch multiple, parallel jobs and occupy 100% of your CPU: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s


4

Swap/change host entries in ~/.ssh/known_hosts so that an incorrect IP address is listed for your host: From: 192.168.0.10 ecdsa-sha2-nistp256 AAAAE2...kFr3pqkY= 192.168.0.20 ecdsa-sha2-nistp256 AAAAE2...A82zdls0= To: 192.168.0.20 ecdsa-sha2-nistp256 AAAAE2...kFr3pqkY= 192.168.0.10 ecdsa-sha2-nistp256 AAAAE2...A82zdls0= (Note that the IP addresses has ...


3

Ecryptfs stores each encrypted file in one file (the lower file, in ecryptfs terminology). The directory structure of the lower files mirrors that of the payload files, although the file names are encrypted. The metadata (modification times, in particular) of the lower files also reveals that of the payload files. The size of the lower file is slightly ...


3

ttcp is a simple, possibly too simple, speed test utility. pchar is another one people cite a lot, I've had bad luck with it, personally. Here's how I'd use ttcp. You need two machines, each with ttcp (http://playground.sun.com/pub/tcp-impl/ttcp/ttcp.c) compiled on them. HostA % ./ttcp -r -s -p 9401 ... HostB % ./ttcp -s -p 9401 < /boot/vmlinuz ...


3

You might be interested in TeSpeed. It is described as: If you are looking for tool that is able to test internet connection speed fron Linux terminal, you have found it! :) TeSpeed uses speedtest.net servers to check upload and download rate and it puts that information on charts. http://tespeed.sourceforge.net/


3

The right approach to testing whether a user can log in is to actually log in as that user. So what I recommend is to make the CGI script use expect to run su, pass a password and run the command that must be executed. Here's a draft of an expect script that does just this (warning: absolutely untested, and I'm not fluent in expect). Substitute in the user ...


3

Not that I know of, but you can force it to swap just by allocating (and using) some ram. #include <stdlib.h> #include <string.h> #include <stdio.h> int main(int argc, char **argv) { if (argc < 2) return 1; int megs = atoi(argv[1]); if (megs <= 0) return 2; int i; for (i=0; i<megs; i++) { ...


3

How abount a simple python solution? #!/usr/bin/env python import sys import time if len(sys.argv) != 2: print "usage: fillmem <number-of-megabytes>" sys.exit() count = int(sys.argv[1]) megabyte = (0,) * (1024 * 1024 / 8) data = megabyte * count while True: time.sleep(1)


3

I think this is a case of asking the wrong question and sanity being drowned out by people competing for the most creative answer. If you only need to simulate OOM conditions, you don't need to fill memory. Just use a custom allocator and have it fail after a certain number of allocations. This approach seems to work well enough for SQLite.


3

Simple answer: No. tmux does not use unit tests or something like a big automated test suite. Also there is no check target or something similar in the Makefile. Anyhow there are some files which support a quick non automated test under /tools/, for example: /tools/UTF-8-demo.txt which contains a lot of UTF-8 ASCII Art examples /tools/256colors.pl which ...


3

One option to do a quick test could be to use a KGDB enabled kernel and stop the kernel manually and test, see this link. On another note, things I remember that could cause your pauses: cpufreq, cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency, the value is in ns (4000 in my AMD FX(tm)-8120 Eight-Core Processor) shouldn't be a problem, ...


3

If influencing the actual input is difficult (such as reacting on a disc error), you should make a thin wrapper around the function, that depends on some global state. In this case I would put such a wrapper around write() to return 0 or the actual return from write(). If the overhead of the wrapper is too big use some #define to be able to leave out the ...


2

To more specifically answer: "Is it possible to create a bash script that will test a given username and password combination against the registred user on the host?" Yes. #!/bin/bash uid=`id -u` if [ $uid -ne 0 ]; then echo "You must be root to run this" exit 1 fi if [ $# -lt 1 ]; then echo "You must supply a username to check - ($# ...


2

you can do 2 things.. check /var/log/cron to check if it's being executed add > /tmp/log 2>&1 to the end of the cron entry. then cat /tmp/log to check if the output is correct.



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