Commonly used tips for Mac novices to play with the terminal! !

Commonly used tips for Mac novices to play with the terminal! !

The Mac terminal is a special application that can be used to execute some special commands. You can send some special commands to the Mac through the terminal, but the newbies who are new to Mac may not be very familiar with this aspect. So today I will take you to understand the common knowledge of the terminal. Interested friends and novice babies don't miss it!

How to open the terminal:

Find the terminal application through other folders of Launchpad

View occupied ports

lsof -i:port

TQ-WXdeMacBook-Pro:~ anonyper$ lsof -i:8081


uwsgi 22117 anonyper 3u IPv4 0x90a5adf44866b61d 0t0 TCP *: sunproxyadmin (LISTEN)

Kill the occupied port

Kill PID

Kill -9 PID forced to kill

TQ-WXdeMacBook-Pro:~ anonyper$ kill 22117

Mac command line commonly used commands:

  • ls lists unhidden files in the current directory
  • ls -a lists all files in the current directory
  • cd XXX/XXX switch directory
  • cd switch to the upper directory
  • cd ~ Switch to the user's root directory (this is the case on Mac, other systems are unknown)
  • cd/switch to the root directory of the computer
  • psd displays the path of the current directory
  • mkfile -n size[b|k|m|g] XXX Create size XXX file
  • mkdir XXX creates a folder named XXX in the current directory
  • rm xxx delete the xxx file in the current directory
  • rmdir XXX Delete the XXX folder in the current directory. If the folder is not empty, it will prompt Directory not empty
  • rm -rf XXX Force delete XXX files/folders in the current directory
  • rm -f XXX force delete the XXX file in the current directory
  • cat display file content
  • cp copy files/folders, such as: cp file file1
  • open Use the default file to open the file/folder

View IP address

ifconfig//ipconfig on windows

ping to send a request to a host (can test whether the other server is available)

hot key

  • shift+command+3 save the current window picture (to the desktop)
  • cintrol+shift+command+3 copy the current window picture
  • shift+command+4 save the selected area picture (to the desktop)
  • cintrol+shift+command+4 Copy the selected area picture

Finder commonly used shortcut keys

  • command + N to create a new visitor window
  • shift+command + N new folder
  • command + i View introduction
  • shift + command + D to locate the desktop
  • shift + command + H to locate the personal folder
  • shift + command + O to locate the document
  • shift + command + A to locate the application (may conflict with Tencent screenshots)
  • command + W close the window
  • option + command + W close all windows