View current path:
Psd
Enter root:
cd
Enter the folder:
cd (文件夹)
Parent directory:
cd ..
List all files in a directory:
ls
Show file contents:
cat
Copy the file to the target directory:
cp 文件名 目标目录
~/Document/CPP2/ :
~代表root
Create xxx directory:
mkdir xxx
Create a new multi-level directory
mkdir -p XXX/XXX
create a new file
touch XXX.js
View all txt files in the current directory:
find *.txt
Open the current directory in a graphical interface:
open .
Return to the last visited directory:
cd -
delete:
rm 文件名
Show hidden folders:
defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder
Do not show hidden folders:
defaults write com.apple.finder AppleShowAllFiles -bool false; killall Finder
Delete system files:
sudo rm -rfv /Cool
Show running processes:
top
Ending process:
kill
Learn more about commands:
man
Common but risky command diskutil
- Check the partition limit: sudo diskutil resizeVolume /dev/disk1s3 limits
- Reset space size: sudo diskutil resizeVolume /dev/disk1s2 100GB
- Disconnect the drive: sudo diskutil unmountDisk force /dev/disk1
- Completely remove the logical disk: diskutil unmount /Volumes/Macintosh\ HD
- Show the GUID partition structure: gpt -r show /dev/disk1
- Remove EFI NO NAME:gpt remove -I 4 /dev/disk1
- Add new storage block: gpt add -I 3 -b 1362424032 -s 1269536 -t 426F6F74-0000-11AA- AA11-00306543ECAC
- New partition: newfs_hfs -J -v “Recovery HD” /dev/disk0s3
- Physical Core Storage expansion: diskutil cs resizeDisk 11111111-2222-3333-4444-55555555555 980g
- Logical Core Storage expansion: diskutil cs resizeVolume 11111111-2222-3333-4444-555555555555 980g
Automatically install brew
Mac has a very convenientpackage manager calledHomebrew< a i=4>, which allows you to install many applications automatically. Homebrew is not a built-in component of the terminal. You need to run this series of commands to install it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Homebrew needs to be installed before using the brew command
After the installation is complete, you can directly use commands such as brew cask install 软件英文名
to quickly install the required software. Readers who use Mac may have heard of HomeBrew, which is a simple and easy-to-use package manager that allows you to easily download and manage third-party applications.
Unfortunately, the articles we read often stop at brew install 某某应用[^1]
(installing applications with HomeBrew). In fact, the role of HomeBrew is much more than just downloading. If we learn a few more commands, we can turn HomeBrew into an App Store for third-party applications that integrates search, Download and update functions are integrated into one, simple and efficient.
- Search application: brew search application name (usually requires English name) If it is just a single application name (such as
squirrel
), you can usebrew install squirrel
to install it directly [1], generally these are command line tools that can be downloaded and installed directly. You can also see a type of applications withcask
in front of their names. They need to be installed using a different command:brew cask 应用名
, just like what their names represent..brew cask
(barrel) The downloaded files are packaged one by one.app
- Update applications and clean up old versions: First use the following command to check which applications can be updated
brew outdated
, and then update the applications that can be updated. Generally, I update all applications, so the command I use most often is:brew upgrade
, but sometimes we don’t want to update all applications. For example, there is a historical version of Chromium that does not disable Flash, and I always keep it. In order to deal with those websites that are still old and do not want Chromium to be updated to a higher version. At this time, we can add the name of the application that needs to be updated on the basis of the above command to avoid applications that do not need to be updated:brew upgrade 应用名
After the update, you can run the following command to change the application Old versions and cache removal.brew cleanup
, if you just want to see which applications can be cleaned, but do not need to deal with them temporarily, you can use this command to get a glimpse:brew cleanup -n
Specify that they need to be cleaned Cached applications:brew cleanup -n