in terminal:
security dump-keychain -a | less > dump.txt
Tag: OSX
Get MAC's serial no via terminal
SSH into the mac,
> system_profiler SPHardwareDataType | grep “Serial”
this command should get u the serial no. (works on Mojave)
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.
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
Map drive and copy in OSX's Terminal
I do this via ssh (putty):
cd /
sudo mkdir scripts
sudo mkdir /Volumes/mnt
sudo mount_afp afp://server.share/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
第一次拆開Macbook Pro
Still remembered my first day at PCSSC was to fix an IMAC.
As days goes by, my skills and knowledge in OSX also gaining paces.
Just recently we were able to deploy 2 labs of iMAC with imaging software (DeployStudio).
With ssh enabled on the machines, it also make our job a lot easier by remote into it and do some works as required.
I probably should do some Apple courses in the future.
It was actually quite easy to open up the Macbook Pro, but not iMAC though.
My First Shell Script in OSX
#!/bin/sh
# Enable SSH
echo "Enabling SSH"
systemsetup -setremotelogin on
echo “Set computer name to this format eg: LRC-IMACXX, where xx is numbers.”
scutil --set HostName
ComputerName=$(HostName)
scutil --set LocalHostName $ComputerName
scutil --set ComputerName $ComputerName
echo “Computer name set to: “ $ComputerName
echo “Changing power preference”
sudo pmset -c ttyskeepawake 1
sudo pmset -c sleep 15
sudo pmset -c displaysleep 10
sudo pmset -c womp 1
sudo pmset -c halfdim 1
sudo pmset -c disksleep 10
echo “Schedule MAC wakeup at 8am and shutdown at 6pm everyday”
sudo pmset repeat shutdown MTWRF 18:00:00 wakeorpoweron MTWRF 08:00:00
echo “Set proxy”
sudo networksetup -setautoproxyurl Ethernet http://something.pac
sudo networksetup -setautoproxyurl Wi-Fi http://something.pac
echo “Joining Domain…”
sudo dsconfigad -f -a $ComputerName -domain domain.com -u username -p password
echo “Done”
to run this in terminal>
sudo sh scritpt.sh
Power Preference in Mac Terminal
reference here