• Secure Copy
From source to Destination
scp /directory/localfile user@hostname.domain.com:filename
- or -
scp local_file user@hostip:/directory/directory/filename
________________________
• Copy via ftp
Say you want to copy an IOS image from a server to a router and tftp keeps timing out. You can use ftp to perform the task with no issue. You will need to turn on your ftp service and then put the file in your Public directory for the router to access it. Here is the command:
copy ftp://un:pw@hostname/Public/biglong_imagename(withlots of numbers).bin disk1:
________________________
• Make a copy of a directory in a new location with ditto:
- Existing directory named bgp, full of files. You want an exact copy of that directory and all the files in it just with a new name:
sudo ditto bgp rip
________________________
• Listing the ports you have configured in your System Preferences/Network
- Enter
networksetup -listallnetworkservices
Built-in Ethernet
PCI Ethernet Slot 3, Port 1
PCI Ethernet Slot 3, Port 2
PCI Ethernet Slot 3, Port 3
PCI Ethernet Slot 3, Port 4
Built-in FireWire
VPN (L2TP)
________________________
• Specific Interface information:
- Enter
networksetup -getinfo "Built-in Ethernet"
- or -
networksetup -getinfo "Airport"
Manual Configuration
IP address: X.X.X.X
Subnet mask: 255.255.252.0
Router: X.X.X.X
IPv6: Automatic
IPv6 Link Local Address: fe80::XXXx:XXXX:XXXX:XXX
Ethernet Address: 00:30:XX:XX:XX:XX
________________________
• Setting up and interface
- Enter
sudo networksetup -setmanual "Built-in Ethernet" 192.168.100.100 255.255.255.0 192.168.100.1
________________________
• Tar
tar -cvzf images.tar "File Name"
-- unpack --
tar -xzf ~/filename.tar/
________________________
• DHCP Netinfo - Network info
ipconfig getpacket en1
________________________
• Logging elimination of specified text
tail -f /var/log/router.log| sed -e '/routername/d' -e '/other_router/d'
/d is a sed option to delete the whole line if it matches what's inside the two /'s
tail -f /logs/cisco-routers | egrep -v list
________________________
• Grep through directory in search of specific text
grep -e 'aaa' -f *confg
________________________
• sftp
sftp://username@host.domain.com:22/
________________________
• Alias Address Ethernet Interface
sudo ifconfig en0 inet X.X.X.X netmask 255.255.252.0 alias
** Remove
sudo ifconfig en0 X.X.X.X netmask 0xfffffc00 broadcast X.X.X.X -alias
________________________
• DNS Digging
495 dig axfr domain.com @disthost.domin.com | grep hostname
496 dig axfr domain.com @disthost.domin.com | sed -e '/^hostname/p'
497 dig axfr domain.com @disthost.domin.com | grep ^hostname
498 dig axfr domain.com @disthost.domin.com | grep ^hostname | sed -e '/MX/d'
**
dig axfr domain.com @disthost.domin.com | grep ^hostname | sed -e '/MX/d'
________________________
• Piping output to file
sudo tcpdump -i en1 > ~/Desktop/output
________________________
• Grep -
grep "Nov 22" /var/log/system.log | grep -v "words to omit"|grep -v "more words|grep -v "even more words"
-or -
tail -f /var/log/router.log | egrep -v "line 103|line 104"
________________________
• Netinfo
Determining what Netinfo Server a client has bound to:
sudo lsof -i | grep lookupd
________________________
Man pages stored in /usr/share/man/man8/
____+_________+_______
Revision control:
/usr/local/tftp/configs - Location of the files
rcsdiff rotuername.domain.com-confg - gets you the revision number
rcsdiff -r1.2 router.domain.com-confg - once you have that revision number you can compare the changes
co -p1.11 router.domain.com-confg - Complete revision of a config
________________________
• SSH to Router with Secure ID Auth
ssh -l user X.X.X.X
________________________
• Searching with Grep
grep gnutella *.acl
________________________
• Clearing the contents of a file
cat /dev/null >/var/log/filename.log
________________________
• Active Connections on a box:
netstat -a -f inet -p TCP | grep -i established
________________________
• Port Check
nc -z -v hostname.domain.com 443
________________________
• Tar Files
tar -cvvf home.tar home/
In the above example command the system would create a tar file named home.tar
in the directory you currently are in of the home directory.
________________________
• Extracting the files from a tar file:
tar -xvvf myfile.tar
In the above example command the system would uncompress (untar) the myfile.tar file in the current directory.
ssh preshared key generation -
http://developer.apple.com/documentation/developertools/Conceptual/XcodeUserGuide/Contents/Resources/en.lproj/13_SSHEnvironment/chapter_953_section_1.html
________________________
• Making a cool .bash_profile:
alias servername="ssh yourname@servername.com"
alias ls="ls -lGitur"
alias q="exit"
alias tftp="cd /private/tftpboot"
alias open="cd /Applications"
alias tunnel="ssh username@servername.com -D 2222"
________________________
• Listing open connections you haveon your system:
lsof -i
________________________
• Updating your path (bash) with:
% echo 'PATH=$PATH:/usr/local/bin' >> ~/.bash_profile
% source .bash_profile
________________________
• MD5 Hash
openssl passwd -1 -table -salt "73u3" "cisco"
________________________
• Show system Version (Mac OS X)
sw_vers