Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the Mac terminal commands?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what the Mac terminal commands are, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

A Collection of Mac Terminal commands

OSX uses the Unix file system, and all files are hung under the directory "/", so there is no need to have the concept of drive letter under Windows. For example, "C:" all the hard drives you see on your desktop are hung under / Volumes.

For example, when attached to a mobile hard drive called "XX", a hard disk icon appears on the desktop. Where is it actually?

Execute "ls / Volumes/XX" in the terminal to see if what is displayed is the contents of the removable hard drive.

Location of the driver: / Systme/Library/Extensions

User folder location: / User/ username

Location of the desktop: / User/ username / Desktop

The root location is / the core Mach_kernel file wildcard is an asterisk *

Note: in Unix systems, characters are case-sensitive, and A.txt is not equal to a.txt. The root directory flag / is not optional. Cd / System means to go to the System in the follow directory, while cd System means to go to the System in the current directory.

Enter command line operation mode

Under the graphical interface, use finder to open the application "utility" terminal.

If you can't even get into the graphical interface (such as installing the wrong display driver), press F8 when you boot, start with the-s parameter, and then enter the command mount-uw /

Get permission

In order to prevent misoperation from damaging the system, if you do not have permission for important files of the operating system in the user's state, you must first obtain root permission: "sudo-s".

Then enter the password, enter the password without any echo, not even an asterisk, just enter after typing.

Here are some common commands

Clean the system-use the following command: sudo periodic daily and enter and enter the administrator password. If you replace daily with weekly, you are running weekly cleanup. If you change it to monthly, you will do monthly cleaning. If you directly enter: sudo periodic dailyweekly monthly and then enter. It is tantamount to clearing the three together.

List files-ls

Ex.: I want to see what's in the catalogue.

Ls /

Want to see what's under the driver directory.

Ls / System/Library/Extensions

Parameter-w displays Chinese,-l details,-an includes hidden files

Conversion directory-cd

Example: want to view the files in the driver directory

Cd / System/Library/Extensions

Create a new directory-mkdir

Example: create a backup directory backup under the driver directory

Mkdir/System/Library/Extensions/backup

Create a backup directory backup on your desktop

Mkdir / User/ username / Desktop/backup

Copy files-cp

Example: want to copy the Natit.kext of the desktop to the driver directory

Cp-R / User/ username / Desktop/Natit.kext / System/Library/Extensions

The parameter R represents a recursive operation on the directory, and kext appears to be a file in the graphical interface, but it is actually a folder.

Backup all the files in the driver directory to the desktop backup

Cp-R / System/Library/Extensions/* / User/ username / Desktop/backup

Move files-mv

Ex.: want to move AppleHDA.Kext to the desktop

Mv/System/Library/Extensions/AppleHDA.kext / User/ username / Desktop

Want to move AppleHDA.Kext to the backup directory

Mv / System/Library/Extensions/AppleHDA.kext/System/Library/Extensions/backup

Delete files-rm

Example: want to delete the cache of the driver

Rm-rf/System/Library/Extensions.kextcache

Rm-rf/System/Library/Extensions.mkext

Parameter-rf indicates recursion and enforcement. Be sure to use it carefully. If you execute "rm-rf /", your system will be gone.

Change file permissions-chmod

Example: set all files in the driver directory to root to read and write, and other users only read

Chmod-R 755/System/Library/Extensions

Parameter R indicates recursion, and 755 indicates the permissions of each user.

Read read write write execute permission excute

For example: 777 privilege rwx rwx rwx

Three numbers, divided into three parts.

The first number, indicating the owner's permissions

The second number represents the same group user rights, that is, other members of the group in which the user belongs

The third number, which indicates the permissions of users in other groups

R stands for read permission, and the value is equal to 4

W represents write permission, and the value is equal to 2

X stands for execution permission, and the value is equal to 1.

Therefore, 7 means readable, writable, and executable

0 means unreadable, unwritable, and unexecutable

Like the 777 above.

The first bit 7 equals 4 percent 2 percent 1, so it is rwx, and the owner has permission to read, write, and execute.

The second bit 7 is also 4, 2, 2, 1, and the users in the same group have read, write and execute permissions.

The third bit 7, which means that other users have read, write and execute permissions.

And for example, 744.

The first bit 7 equals 4, 2, 2, 1, and the owner has read, write, and execute permissions.

The second bit 4 equals 4, 0, 0, and 0, and users in the same group only have read permissions.

The third bit, 4, is also r -, and users in other groups also have read permissions.

Script file name-sh

Example: after modifying the driver, all the necessary operations are saved into a script, and after modifying the driver, you only need to run the script once.

1. Run nano/clean in the terminal

two。 Paste the following code into nano

Rm-rf/System/Library/Extensions.kextcache

Rm-rf/System/Library/Extensions.mkext

Chown-R root:wheel/System/Library/Extensions

Chmod-R 755/System/Library/Extensions

Diskutilrepairpermissions /

Kextcache-k/System/Library/Extensions/

3. Ctrl+ O save, Ctrl+X exit

4. In the future, whenever you move the driver, run sh / clean once in the terminal.

Are you dizzy? This is only part of the list, hehe, to give a specific commonly used example, I will use the above commands as much as possible.

(remember that sudo-s gets system permissions before each operation)

Example: for example, we downloaded a graphics card driver Weiphone.zip and decompressed it on the desktop to get a Weiphone.kext. What should we do? The steps are as follows:

Answer: 1. Backing up all drivers first seems like a habit problem, but often good habits can solve a lot of unnecessary problems.

Method: mkdir/User/ username / Desktop/backup set up a backup folder on the desktop

Cp-R / System/Library/Extensions/* / User/ username / Desktop/backup backup driver file

two。 Installation

Method: cp-R / User/ username / Desktop/Weiphone.kext/System/Library/Extensions copy it to the system driver directory location

Sh / clean executes cleanup script, operation completed

Problems often occur in this step, and there may be many reasons, but I am sure it is your own problem, hehe ~ remedial measures:

Method: start up by pressing F8 and starting with-s parameter

Execute mount-uw /

Rm-rf/User/ username / Desktop/Weiphone.kext remove this driver

Sh / clean executes cleanup script, operation completed

Restart, back to the original state, the graphics card without special effects how to do, need to modify the Natit Info. Only plist files will do.

Cp-R / User/ username / Desktop/Weiphone.kext/System/Library/Extensions copy it to the system driver directory location

Nano/System/Library/Extensions/Weiphone.kext/Info.plist

Save the disk with Ctrl+ O after editing, and exit with Ctrl+X

Sh / clean executes cleanup script, operation completed

Restart, right this time, graphics card special effects are available, it's time to get a sound card, God knows what will happen, we have to protect the existing results.

Mkdir / User/ username / Desktop/gooddrivers builds a directory for valid drivers

Cp-R/System/Library/Extensions/Weiphone.kext / User/ username / Desktop/gooddrivers backup

Save the disk with Ctrl+ O after editing, and exit with Ctrl+X

Sh/clean executes the cleanup script, and the operation is completed

If it is successful, back up the modified driver.

-

The following method is for those students who often fiddle with computers.

Q: what if we mess up all the drivers?

A: it doesn't matter if we have backed up all the driver files.

Press F8 to boot and start with the-s parameter

Execute mount-uw /

Since rm-rf/System/Library/Extensions/* is messed up, kill them all.

Cp-R/User/ username / Desktop/backup/* / System/Library/Extensions/ copy the original driver back

Cp-R / User/ username / Desktop/gooddrivers/*/System/Library/Extensions/ copy the modified driver back

Sh / clean executes cleanup script, operation completed

Got it!

Q: how does Mac OS X enable superusers?

A: literacy first, the term explains: Root user, also known as superuser, is the most powerful Unix account. The Root account can perform any "operation" in any part of the system, including: copying files, moving / removing files, executing programs, etc. Therefore, Root accounts are usually only assigned to advanced professional users. As a result, Apple hides Root user in its Mac OS X.

But sometimes we have to enable Root users in order to implement certain operations, there are three ways to start the Root account.

Still want to talk about it: root user nothing had better not fiddle with, equivalent to doing medical surgery, it may be a big deal.

Method 1:

Put the Mac OS X installation CD into the CD drive, boot the system with the CD, select the "Password Reset" option from the installation menu, and you can change your password and start the superuser mode. Copying this tool to the hard drive is not bootable. It must be booted from the CD to be effective. ) recommended Index *

Method 2:

Start Terminal in Mac OS X (in the folder of applications / Utilities) and enter the following command:

Sudo passwd Root

The system will ask for a new password for Root user in real time, and then enter it again to ensure that the password is correct. Recommended index *

Method 3:

Start the NetInfo Manager application (in the applications / Utilities folder), and then follow these steps:

1. Select "Domain" → "user" → "launch Root user" from the menu

two。 Click the Lock button at the bottom of the window and enter the user name and password you provided during installation.

3. Select the * column from the list in the lower half of the window, and then enter the new password encrypted by Root user.

You can enter the following "htpasswd" command in Terminal to generate an encrypted new password:

[localhost:~] currentuser% htpasswd-nb anylogin yourpassword

[return]

[localhost:~] currentuser%anylogin: pu9fQgdzVHRB2

Pu9fQgdzVHRB2 is the new encrypted password

4. Click the Lock button at the bottom of the window, then save the changes and leave NetInfo Manager.

Now you can try Root user's new password suggestion index in Terminal.

Q: how to delete files that cannot be deleted in Finder through terminal commands

A: here I would like to introduce a regular question. There are often people for some reason. For example, crash, half of the file download accidentally returned, at this time there are often files can not be deleted, the system prompts you that you do not have enough permissions. At this point, we can delete it with a simple command.

1. Open the terminal application

two。 Enter the command: sudorm-r-f "the file you want to delete"

Also note that terminal commands are case-sensitive, all lowercase.

3. Use mouse to drag the files or folders you want to delete into the terminal window, and many of them can be dragged together.

4. Then enter in the terminal.

5. Enter the current administrator user password. If you don't have a password, just enter the car. Note that it is not the password of the root account.

6. There is no prompt in the terminal indicating that the deletion was successful.

Note: if you cannot delete it with this command, there are two possibilities: one is that you delete temporary files that are in use by the system. Second, there may be something wrong with your hard drive directory. Please check your hard drive with the disk tool first.

Explanation: sudo command: any command can be preceded by sudo,sudo to indicate administrator rights, can directly manage the more important files in the system, generally need to ask for a password. Enter the administrator password before the operation can be completed.

Shutdown command-sudo shutdown-h now

Sometimes when there is something wrong with the system and the shutdown is not successful, you can try to shut it down with the command line, after all, it is not good to turn off the power naked. At first, my machine sometimes crashed. I shut it down on the command line. It's so weird that I haven't been there since I died twice when I first bought the machine. In the terminal, you can also use halt command with other parameters to achieve shutdown, but shutdown~ is recommended.

Hidden file command-hide file command: it seems that there is a plug-in under Mac that can show hidden files. As for the plug-ins for hidden files, I have never heard of them. But I secretly thought that since the purpose of hiding the file was not to like others to find it, of course it would be better to be more complicated. The mv command is used to move files, but renames them if they are still in the same path, usually with "." in Mac. The beginning of the file is hidden, so we can use the mv command to hide the file. For example, if you have a file called Tool, if you want to hide it, you should go to the path of Tool. For example, if Tool is under the Program folder, you should use it under the Program folder.

Mv Tool .Tool

The hiding of Tool is realized. In the same way, mv. Tooltool can display hidden Tool. Of course, you need to use the cd command to go to the Program folder mentioned here. In the Linux/Unix system, the top directory is called the root directory, and any directory is always under the root directory, for example, Program may be "/ home/Program/Tool", so we only need

Cd / home/Program

You can hide the Tool. "cd." Indicates that the directory at this level, that is, the operation will not change, "cd." Means to return to the parent directory, such as "cd.." after "cd/home/Program". Represents it under the home folder. To show hidden files, to show hidden files under a folder, use "cd" to use the command under that folder

Ls-a

You can see that all files under this folder contain hidden files.

Mac Shortcut Keys

Keyboard shortcuts for boot-related commands

C: boot from a bootable CD, DVD, or USB driver (usually used when reinstalling the system)

D: boot to Apple hardware Test (Apple Hardware Test) or Apple Diagnostics (Apple Diagnostics)

N: start from a compatible NetBoot server

S: enter Single-User single player mode

T: target disk mode startup

V: enter Verbose mode

X: boot from OS X boot disk

Option: enter the startup manager

Option+N: boot from the NetBoot server using the default boot image

Command+V: start in verbose mode

Option+D: boot to Apple hardware Test (Apple Hardware Test) or Apple Diagnostics (AppleDiagnostics) via the network

Command+Option+Shift+Delete: boot the system in the external storage device

Command+Option+O+F: enter Open Firmware mode

Command+Option+P+R until the second boot sound after release: clear PRAM

Command+option+N+V: clearing NV RAM

Command+Option+R: launched from OS X Recovery over the network

Command+Option+P+R: reset NVRAM and release the button when you hear the startup sound again

Shift: safe mode startup

Left mouse button: force the CD to exit

Eject (eject) or F12 or mouse or trackpad button: press and hold one of the buttons to eject anything in the disk drive.

Second, commonly used system shortcuts

Command+M: zoom out the window

Command+W: closing window

Command+C: connect to the server

Control+ Click: right mouse button

Command+H: hiding window

Command+Q: exit the application

Command+Z: restore the previous step

Command+shift+Z: restore the next step

Command+shift+Q: go to Finder

Command+option: hide (open) Dock

Command+option+W: close all windows

Command+option+M: zoom out all windows

Command+E: exit the external device

Command+shift+A: go to the application folder (on finder)

Command+control+option+8: full screen reflection

Command+control+option+ pop-up key: shutdown

Key to turn on command+control+: force restart

Command+option+ pop-up key: computer hibernation

Command+option+esc: force exit of the application

Command+ single-press title column: skip to previous page

Command+delete: deleting fil

Command+option+shift+delete: forced removal of wastebaskets

Command+option+D: open the built-in dictionary and translate words in real time

Command+. (full stop): terminates any operation in progress

Ommand+down: use on any file, you can open the file directly

Fndelete: delete the word to the right of the cursor

Command+esc: starts the Front Row window operation.

III. Window operation

Option+ Click window to close the box (red): close all windows on the desktop

Option+ Click window Zoom (green): adjust the window to be as big as the screen

Option+ Click the window shrink box (yellow): collapse all windows

Command+W: closing a single window

Command+N: open a new window

Command+option+W: close all windows

Command window name bar: popup window path

Command+option+ window name bar: you can return to the path window and close the current window.

IV. Finder

Command+1: reading with icon

Command+2: using manifest preview

Command+3: using column preview

Command+4: preview with CoverFlow

Command+Y: preview with Quick Look

Command+option+Y: full-screen preview with Quick Look

Command+shift+H: open the Home directory

Command+shift+I: open iDisk

Command+shift+D: open desktop

Command+shift+C: turn on the computer

Command+shift+K: open the network

Command+shift+A: open the application

Option+ double click: open the program and automatically close the Finder window

Special effects: command+shift+option+down.

V. Auxiliary function

Command+option+8: enable / disable zooming

Command+option+=: magnification

Command+option+-: shrinks

Command+option+control+,: reduce the contrast

Command+option+control+. Increase the contrast

Commandoption control+8: X reflective effect.

VI. Screen capture

Command+shift+3: capture the whole screen

Command+shift+4: use mouse drag to intercept the required part of the screen

Command+shift+4+space: truncates the specified window

Hold down option in the capture screen: select the size of the area horizontally or vertically.

7. ITunes

Space: pause / start playback

Command+up: turn up the voice

Command+down: voice reduction

Command+right: the next song

Command+left: the last one

Command+option+down: mute on / off

Command+E: exit CD

Command+T: visual effect

Command+F: browse albums on full screen

VIII. Safari

Command+option+F: moving to the Google column

Command+ link points: open a new tab

Command+shift+ link points: moving to new tab

Command+option: open the new net window

Command+shift+ [: move to the previous tab

Command+shift+]: move to the next tab

Command+shift+H: move to home page

Command+shift+K: open a blocking pop-up window

Command+shift+E: clearing cach

Command+shift+R: revamping web pages

Command+F: looking for keywords on the website

Down: move down to browse

Up: move up and browse

IX. Mail

Command+N: create a new message

Command+shift+N: accept new mail

Command+option+N: open a new window

Command+O: open the active window

Command+E: reset information

Command+F: reply message

Command+shift+R: reply to all messages

Command+shift+B: bounce from

Command+shift+T: convert information, rich text or plain text

Mac problem solving

Resolve the slow running of Adobe Audition:

Run Adobe Audition, then exit, go to / Users/ your username / Library/Preferences/Adobe/Audition/ (Audition version number, CC2015 is 8.0jcc2014 is 7.0jcc6 is 6.0, etc.), open Debug Database.txt, edit the parameters, find the line DisableAGMDrawbot false false, change it to DisableAGMDrawbot true false, save and exit.

Resolve issues where the Bartender 2 plug-in cannot be installed:

Copy Bartenter 2.app/Contents/Library/LaunchService/com.surteesstudios.Bartender.BartenderInstallHelper to / Library/PrivilegedHelperTools, and copy Bartenter 2.app/Contents/MacOS/BartenderHelper.osax to / Library/ScriptingAdditions/

Resolve the problem that Mac App Store opens and shows blank and cannot be used:

Method 1: restart the computer, press and hold Command-Option-P-R during startup and let go after three times

Method 2: open the activity monitor, search store, and exit all the content found.

Method 3: restart the computer after typing nvram-c at the terminal

Method 4: enter these two commands in the terminal:

Sudo rm ~ / Library/Preferences/com.apple.appstore.plist

Sudo rm ~ / Library/Preferences/com.apple.storeagent.plist

Solve the problem that Microsoft Office 2016 takes up too much space:

1: move the DFonts and Fonts folders in Microsoft Word.app or Microsoft PowerPoint.app or Microsoft Excel.app display package contents / Contents/Resources to the location you want. It is recommended to create a new folder in / Library/Fonts/, call Microsoft Office 2016 Fonts to put these two folders, and then create a stand-in with the same name as the original folder. These avatars are then copied to the display package content / Contents/Resources of each Microsoft Office 2016 software for replacement.

2: move the Proofing Tools in the Microsoft Word.app or Microsoft PowerPoint.app or Microsoft Excel.app or Microsoft Outlook.app display package content / Contents/SharedSupport to the location you want, suggest putting it in / Library/Application Support/Microsoft, and then create a stand-in with the same name as the original folder, and then copy the stand-in to each Microsoft Office 2016 software display package content / Contents/SharedSupport to replace.

You need to start all over again after updating

Solve the problem of MplayerX fast forward blurred screen and playback blurred screen:

Open MPlayerX, open preferences, and fill in "- vc-* * 264vda," (comma cannot be lost, double quotation marks removed) or "- vc-vda," (comma cannot be lost, double quotation marks can be removed) in the additional settings of the advanced menu. The difference is that the former command does not retain the hardware of * * and 264, while the latter one retains the hardware of * * and 264.

Solve the problem that vm directories take up too much space:

The vm directory is full of useless files. Sleepimage is a very large junk file generated when the system hibernates. Swapfile0, swapfile1, etc. are all system garbage, which are all stored in / private/var/vm, which takes up space but is useless. Just find a very small file, change the name to the name of the file you want to delete, and put it in / private/var/vm to replace the source file.

Resolve the problem that GarageBand downloads basic sounds and loops too slowly:

First open GarageBand and then exit, open the activity monitor to find the process of GarageBand, double-click the process, click on the open file and port, turn to the bottom, you will see / private/var/folders/xx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/C/com.apple.garageband10/com.apple.MusicApps/audiocontentdownload.apple.com/lp10_ms3_content_2015/MAContent10_GarageBandCoreContent_v3.pkg information, where xx and xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx are random directories of the system / private/var/folders/xx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/C/com.apple.garageband10/com.apple.MusicApps is downloaded to the address, audiocontentdownload.apple.com/lp10_ms3_content_2015/MAContent10_GarageBandCoreContent_v3.pkg

Is the download URL, copy the download URL to the download tool to download, after the download, open / private/var/folders/xx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/C/com.apple.garageband10/com.apple.MusicApps, you will find that there is a folder inside, copy the downloaded file to replace the source file, and then open GarageBand, and the installation will begin

This is the end of this article on "what are the Mac terminal commands?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report