ie if you have the following piece of code:
currdir=`pwd`
and want to replace it with
currdir=$(pwd)
then, in Notepad++ use the following in the find and replace menu:
Find: `(.*)`
Replace: \$\($1\)
currdir=`pwd`
currdir=$(pwd)
yum install gcc gcc-c++ autoconf automake
Then install the command itself:
wget http://pkgs.fedoraproject.org/repo/pkgs/stress/stress1.0.4.tar.gz/a607afa695a511765b40993a64c6e2f4/stress-1.0.4.tar.gz
tar zxvf stress-1.0.4.tar.gz
cd stress-1.0.4
./configure
make
make install
To do the stress tests themselves:
stress –c 5 –t 1200s
Stress Memory for 10 minutes
stress –m 10 –t 1200s
Stress disk io for 10 minutes
stress –d 10 –t 1200s
The first command will push CPU to 500%. It only works on one core, so it may need to run several time simultaneously, depending on how many cores there are. The second command produces 10 spinning process, and the third 10 spinning disk write processes.
#!/bin/bash
if [ $1 ]; then
NUM_PROC=$1
else
NUM_PROC=10
fi
uptime
for i in $(seq 1 $NUM_PROC ); do
awk 'BEGIN {for(i=0;i<10000;i++)for(j=0;j<10000;j++);}' &
pidarr[$i]=$!
echo ${pidarr[$i]}
done
ps -fp "${pidarr[*]}"
uptime
We can use dd and a variation of the above script to thrash the disk IO:
#!/bin/bash
if [ $1 ]; then
NUM_PROC=$1
else
NUM_PROC=10
fi
for i in $(seq 1 $NUM_PROC ); do
dd if=/dev/sda of=/dev/null &
pidarr[$i]=$!
echo ${pidarr[$i]}
done
ps -fp "${pidarr[*]}"
And for memory, we can use another variation:
#!/bin/bash
if [ $1 ]; then
NUM_PROC=$1
else
NUM_PROC=2
fi
BS=$(free | grep "^Mem" | awk '{print $2}' | head -1)
for i in $(seq 1 $NUM_PROC ); do
dd if=/dev/urandom bs=$BS of=/dev/null count=1050 &
pidarr[$i]=$!
echo ${pidarr[$i]}
done
ps -fp "${pidarr[*]}"
This caches huge blocks of random numbers (using a block size of the total amount of used space in the system). Doing it a couple of times simultaneously will do the trick.
$ ./dbusers.sh -s UC1 -rUC2 user1 user2 user3
./dbusers.sh: line 33: $'\r': command not found
./dbusers.sh: line 36: syntax error near unexpected token `$'in\r''
'/dbusers.sh: line 36: ` case $value in
This can be fixed in notepad++ in the Settings menu:
sed -i 's/\r\n/\n/g' <script>
This simple sed command searches for <linefeed><carriage return> (\r\n) and replaces it with a simple <carriage return> (\n).NAME=amypond
CORES=2
IF1=hre228001
IF2=hre229001
ADD1=172.21.138.107
ADD2=172.21.139.107
zonecfg -z $NAME <<EOF
create
set zonepath=/zones/$NAME
set autoboot=true
set bootargs="-m verbose"
add dedicated-cpu
set ncpus=$CORES
end
add net
set physical=$IF1
set address=$ADD1
end
add net
set physical=$IF2
set address=$ADD2
end
info
verify
commit
EOF
zoneadm -z $NAME install
zoneadm -z $NAME ready
zoneadm -z $NAME boot
add fs
set dir=/mnt
set special=/cdrom
set type=lofs
add options [ro,nodevices]
end
add inherit-pkg-dir
set dir=/opt/sfw
end
add capped-memory
set physical=50m
set swap=100m
set locked=30m
end
zlogin -C $NAME
sudo date
user | The name of the user being granted access |
host | A host on the network. For all hosts, use ALL. |
command | A list of one or more commands, qualified by options such as whether the password is required. For all commands, use ALL. |
paul ALL = ALL
paul beatle = (ringo) ALL
NOPASSWD / PASSWD | Determines whether or not the user will require a password to run the command. |
NOEXEC / EXEC | If sudo has been compiled with noexec support, this determines whether or not an executable will be allowed to run further commands itself. |
SETENV / NOSETENV | Determines whether or not users are allowed to override environment variables with the sudo -e command. |
LOG_INPUT / NOLOG_INPUT | Determines whether or not the input to the command is written to the log file. |
LOG_OUTPUT / NOLOG_OUTPUT | Determines whether or not the output from the command is written to the log file. |
paul beatle = PASSWD: /usr/bin/kill, NOPASSWD: /usr/bin/lprm
sudo -l
su -
yum -y install httpd
chkconfig httpd on
service httpd start
<html>
<head>
<title>Dougie's Linux Hints Test Web Page</title>
</head>
<body>
This is a test Web Page.
</body>
</html>
elinks http://localhost
yum groupremove “X Window System”