How to display and hide files and folders in Mac OS

Source: Internet
Author: User

Mac has a design principle, that is, what users do not need to see or what users do not want to see will not be displayed. However, if you want to modify some of these files, you can do this by entering the command line on the terminal to display all the files first.

Show System hidden files

Defaults write com. Apple. Finder appleshowallfiles-bool truekillall finder or defaults write com. Apple. Finder appleshowallfiles yeskillall Finder

You can also hide these hidden files. defaults write com. Apple. Finder appleshowallfiles-bool falsekillall finder or defaults write com. Apple. Finder appleshowallfiles nokillall Finder

After all the files are displayed, how can we hide a non-hidden file? The following two simple methods are described.

Method 1: Add a dot '.' directly before the file or folder name, and then the modify confirmation dialog box will pop up. Just click it.
Method 2: Use the command "chflags hidden" to hide files or folders.

First open terminal (Applications/utilities/terminal), and then execute the command
Chflags hidden file path or
Chflags hidden folder path
Yes. You can also enter chflags hidden and drag the file to be hidden to the input box with the mouse selected. The file will be automatically converted to the file path.
To unhide a file, run the following command:
Chflags nohidden
Corresponds to the previous step.

What is the difference between the above two methods? I personally think that the method does not modify the attributes of the file itself. In Linux and UNIX, files starting with a better Convention are hidden files.
In method 2, the hidden mark of the file is modified, but it does not seem to work on windows. It can only be used in Linux and UNIX. Method 1: Windows can also display
Hidden, it should be that windows also recognizes the dot conventions in Linux and UNIX.

On the Internet also found that there is an open source project that can hide files and folders, provides a program with interface, you can easily do not use the command line user, address is

Finally, attach the details of the chflags command.
The chflags command changes the file flags, including the hidden flag. The detailed usage is as follows:

SYNOPSISchflags [-fhv] [-R [-H | -L | -P]] flags file ...DESCRIPTIONThe chflags utility modifies the file flags of the listed files as specified by the flags operand.The options are as follows:-f Do not display a diagnostic message if chflags could not modify the flags for file, nor modifythe exit status to reflect such failures.-H If the -R option is specified, symbolic links on the command line are followed. (Symboliclinks encountered in the tree traversal are not followed.)-h If the file is a symbolic link, change the file flags of the link itself rather than the fileto which it points.-L If the -R option is specified, all symbolic links are followed.-P If the -R option is specified, no symbolic links are followed. This is the default.-R Change the file flags for the file hierarchies rooted in the files instead of just the filesthemselves.-v Cause chflags to be verbose, showing filenames as the flags are modified. If the -v option isspecified more than once, the old and new flags of the file will also be printed, in octalnotation.The flags are specified as an octal number or a comma separated list of keywords. The following key-words are currently defined:arch, archivedset the archived flag (super-user only)opaque set the opaque flag (owner or super-user only). [Directory is opaque when viewed througha union mount]nodump set the nodump flag (owner or super-user only)sappnd, sappendset the system append-only flag (super-user only)schg, schange, simmutableset the system immutable flag (super-user only)uappnd, uappendset the user append-only flag (owner or super-user only)uchg, uchange, uimmutableset the user immutable flag (owner or super-user only)hidden set the hidden flag [Hide item from GUI]As discussed in chflags(2), the sappnd and schg flags may only be unset when the system is in single-user mode.Putting the letters ``no'' before or removing the letters ``no'' from a keyword causes the flag to becleared. For example:nouchg clear the user immutable flag (owner or super-user only)dump clear the nodump flag (owner or super-user only)Unless the -H or -L options are given, chflags on a symbolic link always succeeds and has no effect.The -H, -L and -P options are ignored unless the -R option is specified. In addition, these optionsoverride each other and the command's actions are determined by the last one specified.You can use "ls -lO" to see the flags of existing files.

The following is a Chinese version

Chflags name: chflags-mark of File Change Overview: chflags [-Fhv] [-R [-H |-L |-p] Description of the mark file: tool chflags to modify the file flag of a specified file. Option:-F if the chflags cannot modify the file flag, nor modify the exit status to reflect such failures, the diagnostic information is not displayed. -H if the-r option is enabled, the file flag of the file to which the soft connection points will be changed (except for the soft connection in the traversal tree ). -H if the file is a soft connection, only the file mark of the link is changed, without changing the file mark pointed to by the link. -L if the-r option is enabled, the file flag of all files pointed to by the soft connection is changed. -P if the-r option is enabled, the file flag of all files pointed to by the soft connection is not changed. This is the default option. -R change the file flags for the file hierachies rooted int the files instead of just the files themselves.-V displays the file name when the flag is modified. If-V appears more than twice, the old and new logos are displayed at the same time in octal. The file flag is displayed by an octal number or a series of keywords separated by commas. The following key words are currently defined: arch, archived archive file mark (exclusive to Super Users) opaque file mark (applicable to file owners or Super Users) nodump file flag (applicable to file owners and superusers) sappnd, sappend only allows appending of file flag (exclusive to Super Users) schg, schange, simmutable file flag (exclusive to Super Users) sunlnk and sunlink files cannot be deleted (exclusive to Super Users) uappnd. uappend only allows users to attach file marks (applicable to owners and Super Users) uchg, uchange, uimmutable does not allow users to change the file flag (applies to owners and superusers) uunlnk, and uunlink does not allow users to delete file marks (applies to owners and superusers) adding or removing "no" before the keyword will clear the corresponding file flag. For example, nouchg clears the file flag that cannot be changed (applies to owners or superusers) dump clears the file flag corresponding to the octal value of the nodump file flag (applies to owners or superusers: 0 clear all file flag 1 nodump 2 uchg3 uchg, nodump4 uappnd10 opaque20 uunlnkother combinations of keywords may be placed by using the octets assigned. however, these are the most common ones. You can use "ls-Lo" to view the file mark. Note: Can some labels be changed depending on the security level settings of the current kernel. View Security (7) for more information. Exit status: Success 0, failure> 0. example: no reference: ls (1), chflags (2), Stat (2), FTS (3), security (7), symlink (7) Standard: no history: chflags first appeared in 4.4bsd. Bugs: only a limited number of utilities are chflags aware. some of thesetools include ls (1), CP (1), find (1), install (1), dump (8), and restore (8 ). in particle a tool which is not currently chflags aware is the Pax (1) utility. chio
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.