More info at http://www.linuxatemyram.com/
free -m
echo 3 | sudo tee /proc/sys/vm/drop_caches
free -m
ps aux |grep httpd| cut -f 4 -d " "| xargs -n 1 -I {} cat /proc/{}/status|grep "VmSize"
ssh -p35 -N -f -C -g -R 8022:localhost:22 [email protected]
diff -uN patchtest.txt patchtest1.txt > patchtest.patch
patch patchtest.txt < patchtest.patch
grep -A 3 -i "elif" *
ssh -N -L 2080:localhost:80 home
python -m SimpleHTTPServer
cat >> /tmp/file << EOF
row 1
row 2
EOF
sed -i 's/SEARCH/REPLACE/g' /etc/passwd
sed 's/SEARCH/REPLACE/g' /etc/passwd
find . -name .svn -prune -o -type f -exec grep -Hn "@todo” {} \;
find -exec grep 10.100.50.3 {} \;|awk ‘{print $3}' |xargs -L 1 rm
find -exec grep 404 {} \; >ERR
If you like to login from computer A to computer B with ssh, without using any password, follow the below script code. This is useful if you have some automated scripts that do things on other computers.
Generate authentication keys, login to computer A as user a. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
a@a:~$ ssh b@b 'mkdir -p .;chmod 700 .ssh; \
touch .ssh/authorized_keys;chmod 640 .ssh/authorized_keys'
b@B's password:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
Now it’s possible to login to B from A with user a and no password.
a@A:~> ssh b@B hostname
B
Click here or here for external link.
nmap -v -sP 192.168.0.*
arp -na
sysctl -w net.ipv4.ip_forward=1
Click here for a mini howto about dar backups. Click here to download a dar backup script or here to download my version.
Click here or here for mini linux command howto.
aticonfig –odgt | grep Temp | cut -b 43-47
for (( i=0;i<10;i++ )) ;
do
echo -n `date`
aticonfig –odgt | grep Temp| cut -b 42-47;
sleep 1;
done
On server: ./iperf -s -K 1M
On Client: ./iperf -c 10.0.1.100 -i 1
If the kernel is damaged, or as in my case you like to move a hard drive from an intel to an amd computer. You need to rebuild/reinstall the kernel. boot the centos installation cd/dvd Type “linux rescue” in the boot menu Click next, next, next (connect to the network) When in the shell type chroot /mnt/sysimage yum install kernel reboot
vgcreate vg_data /dev/hdd
lvcreate -n VolData -L 50G vg_data
mke2fs -j /dev/vg_data/VolData
mount /dev/vg_data/VolData /opt
echo "/dev/vg_data/VolData /opt ext3 defaults 1 2″ >> /etc/fstab
Execute a program periodically, showing output fullscreen
watch "ps aux|grep mysql”
watch -n.1 'cat /proc/interrupts'
semodule -DB
yum install -y policycoreutils-python setroubleshoot-server
sealert -a /var/log/audit/audit.log
grep tftpdir_rw_t /var/log/audit/audit.log | audit2allow -m sycocobbler > sycocobbler.te
cat sycocobbler.te
checkmodule -M -m -o sycocobbler.mod sycocobbler.te
semodule_package -o sycocobbler.pp -m sycocobbler.mod
semodule -i sycocobbler.pp
yumdownloader --source openldap-servers
rpm -Uvh openldap-servers*
less rpmbuild/SPECS/openldap.spec
rpm2cpio foo.rpm | cpio -idmv --no-absolute-filenames
yum install kernel-2.6.18-238.9.1.el5
# Make sure the older kernel will boot first.
cat /etc/grup.conf
reboot
# This might be done before reboot, to make sure that the newer kernel doesn't boot.
rpm -q kernel
yum remove kernel-2.6.18-274.7.1.el5
sed -i '$exclude=kernel kernel-devel kernel-headers' /etc/yum.conf
yum update
# Line 1: Remove all old existing module X
# Line 2: Add module X
# Line 3: Only one whitespace between each module
# Line 4: No whitespaces before last "
# Line 5: No whitespaces before firstt "
sed "/IPTABLES_MODULES=/s/ip_conntrack_tftp\( \|\"\)/\1/g;
/IPTABLES_MODULES=/s/\"/\"ip_conntrack_tftp /;
/IPTABLES_MODULES=/s/\( \)\+/ /g;
/IPTABLES_MODULES=/s/ \"/\"/;
/IPTABLES_MODULES=/s/\" /\"/
" iptables-config
http://blog.urfix.com/25-linux-commands/