Tips and Tricks for all system
id : xq0uqkocvt
category : computer
blog : unixlinux
created : 03/14/11 - 10:06:51

  • Copy through a gateway using tar and ssh :
root@gateway# ssh server1 "cd /dir/to/copy; tar -cf - * | gzip" | ssh server2 "cd /destination/dir; gunzip | tar -xvf -"

  • Redirect port from one server to another through a gateway :
root@gateway#ssh -R 2222:server1:22 server2
root@server2#ssh -p 2222 -l root localhost
root@server1#

  • Usefull find :
    • Find with permissions :
#find / -type f -perm -o+rx
#find / -type f -perm -g+rx
#find / -type f -perm -u+rx

  • Which process is listening on a port :
# lsof -i :<port_number>

  • List all process listening on tcp/udp :
# lsof -iTCP
# lsof -iUDP

  • List ports open by a process with its pid :
# lsof -p 10551470 | grep LISTEN

  • Simulate seq with awk :
#  for i in `echo 3 10 | awk '{ for (i=$1;i<=$2;i++) { print i} }'` ; do echo ${i}; done
3
4
5
6
7
8
9
10