Sunday, February 3, 2013

Some useful linux/*nix cmds

Send cmd to screen (echo -ne '\015' emulates pressing the Enter key)
# screen -S sessionname -p 0 -X stuff 'command'`echo -ne '\015'`
Search file in packages (debian like distros)
# dpkg -S /etc/foo/foo.conf  
Check port availability
# nc -znvvw 3 192.168.1.100 80
Check availability of port range
# nc -znvvw 3 192.168.1.100 8080-8081
Row count in files with *.php extension
# find /root/* -type f -name "*.php" -exec wc -l {} + ;
Find files larger than 100MB
# find . -size +100M -exec du -h {} \;
SSH port forwarding example for SQL Server (remote-server - which have access to SQL Server by Local address 192.168.1.50, then we can connect to localhost:1433)
# ssh -f remote-server -L127.0.0.1:1433:192.168.1.50:1433 -N

FreeBSD

Get S.M.A.R.T for 3ware raided HDDs (disks starts from 0, 1, 2...)
# smartctl -a -d 3ware,0 /dev/twa0
Renew sendmail aliases
# cd /etc/mail
# make
# newaliases

No comments: