in terminal:
security dump-keychain -a | less > dump.txt
Tag: Terminal
Cisco Catalyst - Trunk Configuration
Here are steps to set port to trunk mode:
1. After connected to switch with console
2. Enter configuration mode
Switch> enable
Switch# Configure terminal
3. Clear the port to default
Switch(config)# default interface gigabitEthernet 1/0/24
4. Set the port to trunk
Switch(config)# interface gigabitEthernet 1/0/24
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk native vlan 1
Switch(config-if)# exit
5. Save settings
Switch# copy running-config startup-config
Password Recovery for Cisco Catalyst Switches
Steps to reset password for Cisco Catalyst Switches:
1. Connect PC with console cable
2. Unplug the power cable to the switch
3. Reconnect the power to the switch. Press and hold the Mode button while System LED is flashing green. After System LED turns amber and then solid green, release the Mode button.
If process followed correctly, the following message should be displayed:
flash_init
load_helper
boot
4.Enter these commands into the switch
Switch: flash_init
Switch: load_helper
Switch: dir flash:
Switch: rename flash:config.text flash:config.text.old
Switch: boot
5. Once the switch boot, answer NO to “Would you like to enter initial/system configuration dialog? [yes/no]:
6. Get into the privilege prompt
Switch> enable
7. Get into global configuration
Switch# conf t
Switch(config)# enable secret y0urPa$$word
Or,
Switch(config)# username admin privilege 15 secret y0urPa$$word
8. Save config
Switch(config)# exit
Switch# copy run start
Switch# reload
OSX install pkg in terminal
cd /
sudo mkdir /Volumes/mnt
sudo mount_afp afp://server/mnt /Volumes/mnt
sudo cp -R /Volumes/mnt/software.pkg /folder
sudo installer -pkg /folder/software.pkg -target /
sudo shutdown -r now
* If you get permission denied while installing/coying the pkg from server, it is worth to check permission set on the pkg file.
Squid Access Log with human readable Time
To see the access log with human readable time in terminal:
tail -f /var/log/squid/access.log | perl -p -e 's/^([0-9]*)/"[".localtime($1)."]"/e'
Reference here
Removing #comment lines from Conf file
Everyone knows that squid.conf have millions of #comment lines.
here is a one liner to remove it:
grep -v '^#' squid.conf | uniq | sort >squid.nocomment
this could apply to any files in Linux which has the # at the front.
Reference here
Install .pkg in MAC via ssh
Commands here:
sudo mkdir /Volumes/mnt
sudo mount_afp afp://osxserver/mnt /Volumes/mnt
sudo cp /Volumes/mnt/OpenToonz.pkg /scripts
sudo installer -pkg /scripts/OpenToonz.pkg -target /
Crontab - Force Shutdown in OSX
sudo crontab -e
Press i (insert text in vim)
30 19 * * 5 /sbin/shutdown -h now
Press esc (to exit editing)
Press shift+z shift+z (Writes changes and quit vim)
Time format in Crontab:
* * * * * command to execute
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
│ │ │ └──────── month (1 - 12)
│ │ └───────────── day of month (1 - 31)
│ └────────────────── hour (0 - 23)
└─────────────────────── min (0 - 59)
OSX Terminal Commands
Caching related:
sudo serveradmin stop caching
sudo serveradmin start caching
sudo serveradmin status caching
tail -F /Private/var/log/system.log
tail -F /Library/Server/Caching/Logs/Debug.log
example:
grep 'Since server start:' /Library/Server/Caching/Logs/Debug.log
grep 'B from cache' /Library/Server/Caching/Logs/Debug.log
egrep 'Since server start|B from cache' /Library/Server/Caching/Logs/Debug.log
grep '2015-09' /Library/Server/Caching/Logs/Debug.log | grep 'Since server start|B from cache'
grep -J 'MB downloaded' /Library/Server/Caching/Logs/Debug* > fromInternet.txt
grep -J 'MB from cache' /Library/Server/Caching/Logs/Debug* > fromCached.txt
grep -J 'Since server start' /Library/Server/Caching/Logs/Debug* > SinceServerStart.txt
SSH, Mapped Drive & Copy stuffs:
ssh computername
cd /
sudo mkdir scripts
sudo mkdir /Volumes/mnt
sudo mount_afp afp://osxserver.domain.com/mnt /Volumes/mnt
sudo cp /Volumes/mnt/homedrive.sh /scripts
sudo cp -R /Volumes/mnt/MappedDrive.app /Applications
sudo cp -R /Volumes/mnt/StudentShared.app /Applications
sudo cp -R /Volumes/mnt/Microsoft\ Remote\ Desktop.app /Applications
sudo umount /Volumes/mnt