Posts: 24,633
Threads: 1,093
Joined: May 2025
So... I have these Lab computers....
There is a file on them I want to Lock (as in, get info, check the "Lock" box).
I don't want to do that 28 times.
I have Apple Remote Desktop.
WIth ARD I can send a Terminal command, essentially just like I was sitting at one of the computers with Terminal open.
SO..
Question for a relative Noob to the command line;
Say I want to lock the file "/Users/student/Library/Preferences/com.apple.dock.plist/"...
How do I type that?
I'm paging through "Mac OS X Unleased" which is 96% command line tips, tricks, and stuff...and I can't find what I assumed was a fairly BASIC command!
Am I wrong that it should be simple?
Posts: 5,314
Threads: 111
Joined: May 2025
For starters, you could change the mode to disallow writing
sudo /bin/chmod a-w /Users/{student}/Library/Preferences/com.apple.dock.plist
Since the default permissions are 0600 (user gets r/w, group gets nothing, others get nothing}. The 'a-w' takes away write permission for everybody--user, group, others. The resulting permissions value is 0400 (owner gets only to read, noone else gets anything).
Before:
ls -l /Users/{student}/Library/Preferences/com.apple.dock.plist
-rw------- 1 {student} {group} 9287 Feb 23 08:53 /Users/{student}/Library/Preferences/com.apple.dock.plist
After:
ls -l /Users/{student}/Library/Preferences/com.apple.dock.plist
-r-------- 1 {student} {group} 9287 Feb 23 08:53 /Users/{student}/Library/Preferences/com.apple.dock.plist
If I can dredge up the Finder equivalent for locking, I'll post it later...
HTH,
[edit: chmod is in /bin not /usr/bin ]
Posts: 13,726
Threads: 599
Joined: Nov 2024
Reputation:
0
You need to install the Developer Tools (XCode) which would give you access to the SetFile command, which allows for setting file attributes on files in HFS directories.
Specifically, you would want to use this command:
%/Developer/Tools/SetFile -a L filename.ext
to set the Locked attribute to file called filename.txt
Posts: 5,314
Threads: 111
Joined: May 2025
Seacrest saved me the trouble...Thanks!
Posts: 24,633
Threads: 1,093
Joined: May 2025
Many Thanks!
That gives me a place to start!
Fortunately, with these machines, if I screw them up hopelessly, I can just erase them and re-clone in about 30 minutes.... not like if I goober up MY computer.
For the next "standard lab model", I'll investigate installing the Developers Tools...
Ideally, I want to put this step into a post-clone script... once I learn more about making executable scripts that is.
Posts: 24,633
Threads: 1,093
Joined: May 2025
Unfortunately, changing the com.apple.dock.plist files permissions does NOT keep it from being altered, and that change saved at log-out.
I just ran some tests...
The only thing that seems to keep it from being changed is the "Lock" in the Get-Info box.
To clarify details;
OS X 10.3.9
User is denied permission to change the dock by the Accounts->Limitations tab (this deny's the user being able to modify what is ON the dock.
At this level of restriction, the user can change the size and location of the dock, and toggle dock-hiding (which REALLY frustrates the K-2nd graders...as they have imperfect mastery of the mouse to begin with...)..
The only sucessful way I have found to remove a students ability to make the dock tiny, huge, or on the sides, or hidden, is to "Lock" the dock prefs.
I will experiment with the Developers Tools and SetFile whoozits when I have time!
Your input is much appreciated!
Posts: 24,633
Threads: 1,093
Joined: May 2025
Figured it out!
(Well, OK.. I found a place at MacOSXHints where someone way smarter than me figured it out....)
"chflags will let you lock and unlock files.
chflags uchg ~/Desktop/test.txt
this would lock a file
chflags nouchg ~/Desktop/test.txt
this would unlock the file
Worked great!