3

From a previous question I have applied following command to my file.

sudo chflags -R nouchg TopSites.plist
sudo chmod 444 TopSites.plist

Now that the file is locked, I don't know how to remove it.

I currently have the file in my trash.

What does sudo do? And where can I find more info about it?
Where is the Trash stored in Mac OS X?
How do I delete this file?

3 Answers 3

5

sudo executes a command as another user. By default (as in this case) the user is the superuser root, which can do almost anything. The trash is located in ~/.Trash. You can delete the entire trash by running:

rm -rf ~/.Trash/*
4

sudo

sudo stands for super user do, you can find more about it by using man sudo in the Terminal. The crux is that you can perform a command temporarily as root meaning you have complete privileges - when you are asked for your password in applications to do certain actions (eg. installing) it's the GUI equivalent of using sudo.

Trash location

Your Trash for your startup drive can be found at ~/.Trash/, whereas for external hard drives it can be found at /Volumes/NAME_OF_EXTERNAL/.Trashes/USER_ID/ where USER_ID is your user id.

Deleting Files

You have a couple options to delete the file: If you hold Option when you empty the Trash you can force empty the trash that will delete locked files like yours.

Alternatively you can use the Terminal to run the rm command (stands for remove). The rm command will delete the file (No trash, it's just gone so be careful using it). So for example rm -rf ~/.Trash/* will erase every file in your trash. If you ran sudo rm -rf ~/.Trash/* it would do it with superuser privileges.

The flags in the rm command stand for recursively (-r) and force (-f). You can find more about rm by running man rm.

2

You can force the removal by holding down the Option key while emptying the trash.

sudo allows you to run commands as another user. If no user is specified, root is used.

chflags changes file or folder "flags". The -R switch makes the command recursive, i.e. it will apply to all files in all subfolders. uchg makes the file immutable, nouchg clears the immutable flag.

chmod changes a file or folder's permissions. 444 is the octal permissions bitmask of a file that is read-only by everybody, including the owner. See this question for an explanation of octal masks and chmod.

Typing man 'command name' in a terminal will give you a complete description of all these commands.

2
  • that's not really a terminal way of doing things...
    – alexus
    Aug 29, 2009 at 17:16
  • @alexus - Richard is right. Any how I wanted to empty trash. You both are right. Thanks a lot for helping me. Aug 29, 2009 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .