Common UNIX directives for MAC terminals

Source: Internet
Author: User
Tags clear screen

Tip: Press the TAB key to automatically get the file name, folder name, Directive name

Path operation:

/root Path

./Current Path

.. /parent Path

Command format: Command parameters

1. ls display file name , equivalent to Dos under the dir command

Command format: LS [option] File

option is preferable:

- L Show detailed list

Domain 1: File types and file permissions

Domain 2: Number of file connections

Domain 3: File owner name

Domain 4: File user Group name

Domain 5: File length

Domain 6-8: Last Modified Date

Domain 9: File name

-A displays all files that contain hidden files (in. File name at the beginning)

- R display files and all subdirectories

-F display file (followed by *) and directory (followed by/)

- D with the L option to display the directory name instead of its contents

2. CD directory switch , equivalent to DOS under the CD command

Note that the directory delimiter is/, as opposed to Dos

Command format: CD dirname

3. PWD Displays the current path

4. Cat Displays the contents of the file, equivalent to the DOS type command

Command format: Cat filename

5. More to view the contents of a file in a paginated manner.

Command format: more filename

6. RM Delete File

Command format: RM [-r] filename (filename can be a file name, or a file name abbreviation symbol.)

Example:

RM file1 Delete the document with the file name File1.

RM file? There are five characters in the delete file name, and the first four characters are all documents of file.

RM f* Delete all documents in the file name with F as the first word.

Rm-r dir1 Delete the directory dir1, and all the documents and subdirectories below it.

7. mkdir Create a directory

Command format: mkdir [-P] Directory-name

Example:

mkdir Dir1 set up a new catalogue dir1.

Mkdir-p Dir/subdir Create a multilevel directory directly

8. RmDir Delete Directory

The directory must be empty first

Command format: RmDir directory

9. CP Document Replication

Command format: CP [-r] Source destination

Example:

CP file1 file2 Copy document FILE1 to File2

CP file1 DIR1 Copy the document FILE1 to the directory Dir1, and the file name is still file1.

Cp/tmp/file1. Copy the document FILE1 under directory/TMP to the current directory.

The file name is still file1.

Cp/tmp/file1 File2 the document under the directory/TMP file1 the current directory, file name

to File2

Cp-r dir1 Dir2 (recursive copy) copies the entire directory.

If the directory Dir2 exists, the directory Dir1, and all of its documents and subdirectories,

Copy to Directory Dir2, the new directory name is Dir1. If the directory Dir2 does not exist,

Copy the Dir1, and all of its documents and subdirectories, to the directory Dir2.

Ten. mv File movement

Command format: MV Source destination

Example:

MV File1 file2 The document FILE1, change the file name to File2.

MV File1 Dir1 file1 the document to the directory Dir1, the file name is still file1.

MV Dir1 DIR2 If the directory Dir2 does not exist, the directory Dir1, and all of its files

And subdirectories, move to directory Dir2, and the new directory name is Dir1.

If the directory Dir2 does not exist, it will dir1, and all of its documents and sub-

directory, change to directory Dir2.

A. Du view the disk capacity of the catalog

Command format: du [-sk] Directory

Example:

Du DIR1 Displays the total capacity of the directory Dir1 and its secondary directory

Du-sk DIR1 Displays the total capacity of the directory Dir1, measured in K-bytes

Find File Lookup

Command format: Find dir-name filename command

Example:

Find. -name Hello-print look for the current directory and all subdirectories inside called

Hello's documentation.

Find. -ctime +7-print Find documents that have not been changed within seven days

Find. -size +2000m-print to find documents larger than bytes

Find/tmp-user b1234567-print documents belonging to b1234567 in/tmp

Find. -name ' *.c '-exec rm {} Remove all. c Files

Find. -name test\*-print Displays the name of the first 4-bit test for the current directory and its subdirectories

WHO displays the current user name

Touch New File " file does not exist before new "

Open File/Folder

Clear Clear Screen

Common UNIX directives for MAC terminals

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.