MAC usage record
- switch path in terminal
- switch to another disk
- Open `bash_profile`
- macos architecture confirmation
- Show hidden, hidden folder
- Right-click function extension
- screenshot
- Change the position of the Windows keyboard Alt and Win keys on the usb interface under MacOS
- dual screen setup
- System Integrity Protection (SIP)
- Remove apps downloaded from the internet
switch path in terminal
In macOS Terminal, you can use cd
the command to switch locations (i.e. change the current working directory). Here are some commonly used commands and techniques:
-
View the current location: You can use
pwd
the command to display the full path of the current working directory. -
Switch to the specified directory: use
cd
the command followed by the path of the target directory, for examplecd /path/to/directory
. You can use absolute paths (full paths from the root directory) or relative paths (paths relative to the current directory). -
Return to the previous directory: Use
cd ..
the command to return to the previous directory. -
Return to home directory: Enter
cd
(onlycd
, without any parameters), press enter to return to your home directory (usually/Users/你的用户名/
). -
Use the tab key to automatically complete the path: When entering the path, press the tab key to automatically complete the directory or file name, which can reduce the chance of input errors.
-
Use the ~ symbol to represent the home directory: you can use to
cd ~
enter your home directory, or you can use tocd ~/Desktop
enter the Desktop directory under the home directory.
These are some basic commands and tricks that will help you switch places in macOS Terminal. There are other advanced commands and options that you can learn and explore as needed.
switch to another disk
If you want to switch from your user directory (usually /Users/你的用户名/
) to another disk, you can use the following steps:
-
Determine the name of the other disk: First, you need to determine the name of the disk you want to switch to.
ls /Volumes
You can list all volumes (including other disks) mounted in the current system by typing in the terminal , and find the name of the disk you want to switch to. -
Switch using an absolute path: Once you know the name of another drive, you can use an absolute path to switch to that drive. Suppose you want to switch to
OtherDrive
the disk named , you can enter the following command in the terminal:
cd /Volumes/OtherDrive
This will switch to the disk with the specified name.
Please note that if you need administrator privileges when switching to other disks, you may need to add them before the command sudo
. For example:
sudo cd /Volumes/OtherDrive
This will ask you to enter your administrator password to gain access. sudo cd
In general, however, using is invalid in a terminal , because sudo
only affects cd
the command, not cd
the commands following the command.
Openbash_profile
This file can be edited using a text editor or a command-line editor.
Here are a few common methods:
-
Open with a text editor:
- In a terminal, execute the following command to open
~/.bash_profile
the file:nano ~/.bash_profile
- This will
nano
open the file with a text editor~/.bash_profile
. You can edit and save changes in the file. When you press Ctrl+X to exit the editor, you will be prompted to save your changes.
or
- If you prefer another text editor, you can use that editor's command-line tool to open it
~/.bash_profile
. For example, for Visual Studio Code, you can execute the following command:
This will opencode ~/.bash_profile
~/.bash_profile
the file with Visual Studio Code.
- In a terminal, execute the following command to open
-
Open with a command line editor:
- In a terminal, execute the following command to open
~/.bash_profile
the file:vi ~/.bash_profile
- This will open the file with Vi or Vim editor
~/.bash_profile
. You can use the commands of the Vi editor to edit and save changes.
or
- If you are familiar with other command-line editors, you can use the editor's command-line tool to open
~/.bash_profile
. For example, with Emacs, you can execute the following command:
This will open the file with the Emacs editoremacs ~/.bash_profile
~/.bash_profile
.
- In a terminal, execute the following command to open
Please choose the method that suits you according to your preference and available editors, and use the corresponding command to open ~/.bash_profile
the file for editing.
edit with vibash_profile
-
Enter edit mode: In the Vi editor, it is in command mode by default. To enter edit mode, press
i
the key. Now you can enter and edit content in the file. -
Make modifications: In edit mode, you are free to modify
~/.bash_profile
the contents of the file. You can add, remove, or modify shell commands, environment variables, and more. After editing, you can enter your modifications through the keyboard. -
Save changes: After finishing the changes, press
Esc
the key to exit the editing mode. Then type:wq
, meaning to save the file and exit the Vi editor. PressEnter
the key to execute the command.If you just want to save the file without exiting the Vi editor, you can use
:w
the command to save the file. -
Exit Vi editor (optional): If you don't want to save the changes after you finish editing, you can press
Esc
the key to exit the editing mode. Then type:q!
, which means to abandon the modification and force quit the Vi editor. PressEnter
the key to execute the command.
nano ~/.bash_profile
After you have nano
edited ~/.bash_profile
the file with the command, you can save and exit as follows:
-
Press
Ctrl + X
the key, this will displaynano
the exit prompt for . -
Press
Y
the key to confirm and save the changes. -
Press
Enter
the key to confirm the file name (usually~/.bash_profile
). -
This
nano
will save the changes and exit, returning you to the command line interface.
Note that after saving changes, you may need to reload ~/.bash_profile
the file or restart the terminal for the changes to take effect. You can execute one of the following commands:
- Execute
source ~/.bash_profile
the command to reload~/.bash_profile
the file. - Alternatively, close the terminal and reopen a new terminal window for the changes to take effect.
This way, your changes will be saved and applied to ~/.bash_profile
the file.
macos architecture confirmation
To determine if macOS is running on Apple Silicon (arm64), you can perform the following steps:
- Click the Apple icon in the upper left corner and select "About This Mac".
- In the window that pops up, check the "Processor" or "Chip" column.
- If it says something like "Apple M1," "Apple M1 Pro," or "Apple M1 Max," then your version of macOS is running on Apple Silicon, which is the arm64 architecture.
- If it says something like "Intel Core i5," "Intel Core i7," or other Intel processor information, then your version of macOS is running on the Intel x86 architecture.
Show hidden, hidden folder
Press the Command+Shift+Period (CMD+Shift+.) shortcut.
Right-click function extension
Right-click assistant == APP Store
screenshot
Capture full screen: Shortcut key (Shift+Command+3)
Screenshot window: Shortcut key (Shift+Command+4, then press space bar)
Change the position of the Windows keyboard Alt and Win keys on the usb interface under MacOS
https://support.apple.com/zh-cn/guide/mac-help/mchlp1011/mac
-
On your Mac, choose Apple menu > System Settings, then click Keyboard in the sidebar. (You may need to scroll down.)
-
Click Keyboard Shortcuts on the right, then select Modifier Keys from the list on the left.
-
For each modifier key whose default action you want to change, click the pop-up menu, then choose an action to perform when the key is pressed or choose No Action.
For example, if you are used to using the Control key on your keyboard, and the corresponding position on Apple keyboards is the Caps Lock key, you can click the Caps Lock key pop-up menu, then choose Control to Performs the same action as pressing the Control key.
dual screen setup
Left and right screen swap: System Settings -> Display -> Arrangement
System Integrity Protection (SIP)
Sometimes the application cannot be installed and it is related to SIP
- When the Apple M1 M2 Mac is turned off, press and hold the power button until the setting appears and then release it to enter the recovery mode
- Intel chips need to power on or restart the Mac, immediately press and hold Command ⌘ + R on the keyboard until you see the Apple logo or a spinning globe and release the keys to enter recovery mode
//关闭
csrutil disable
//打开
csrutil enable
//查看状态
csrutil status