Common shell commands under Mac

Source: Internet
Author: User

Today, let's introduce some common shell commands in the Mac Terminal:

1. View the full path to the current working directory

Pwd

(PWD's original intention is: Print work directiory, not password password meaning, hehe)

2. View the command's detailed help
Man command name
For example, to see the detailed usage of the PWD command, execute the man pwd

3. List files
LS parameter directory name
Example: Want to see what is in the directory,
LS/
Want to see what's in the drive directory,
Ls/system/library/extensions
Parameter-W displays Chinese,-l details,-a including hidden files


4. Converting a directory
CD
Example: Think of a drive directory to stroll around
Cd/system/library/extensions

5. Create a new directory
mkdir Directory Name
Example: Create a backup directory in the driver directory
Mkdir/system/library/extensions/backup
Build a backup directory on the desktop back up
mkdir/user/User name/desktop/backup

6, copy files
CP parameter source file destination file
Example: Want to copy the desktop Natit.kext to the drive directory
Cp-r/user/User Name/desktop/natit.kext/system/library/extensions
The parameter R indicates a recursive operation of the directory, and Kext looks like a file under the graphical interface, which is actually a folder.
Back up all files in the drive directory to desktop backup
Cp-r/system/library/extensions/*/user/User name/desktop/backup

7. deleting files
RM parameter File
Example: To delete a driver's cache
Rm-rf/system/library/extensions.kextcache
Rm-rf/system/library/extensions.mkext
Parameter-RF is recursive and mandatory, be careful to use, if executed RM-RF/your system is gone


8. Move Files
mv File
Example: Want to move Applehda.kext to the desktop
mv/system/library/extensions/applehda.kext/user/User name/desktop
Want to move the Applehda.kext to the backup directory
Mv/system/library/extensions/applehda.kext/system/library/extensions/backup

9. Change file Permissions
chmod parameter permission file
Example: Set all files in the drive directory to root read/write, other users read only
Chmod-r 755/system/library/extensions
The parameter R is recursive, and 755 represents the permissions of each user

10. Change file owner
chown Parameter User: Group file
Example: Change all the files in the drive directory to the root user
Chown-r root:wheel/system/library/extensions
Parameter r indicates a recursive operation

11. Fix permissions on files throughout the system
diskutil repairpermissions/
Strictly speaking, this is not a Unix command, but OSX is a software that remembers the modification or addition of the driver to execute once.

12. Text Editing
Nano file name
Example: Edit Natit info.plist
Nano/system/library/extensions/natit.kext/info.plist
After editing, use Ctrl +o to save, ctrl+x exit
Another text editing software is VI, the operation is a bit odd, cooked is very useful, and in all Unix-like systems, it is not afraid to go all over the world.

13. Run the script command
sh script file name
Example to modify the driver after all the required operations into a script, after the driver has been modified to run once this script is OK, convenient
1. Running Nano/clean in terminal
2. Paste the following code into the 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
Diskutil repairpermissions/
Kextcache-k/system/library/extensions/
3. Ctrl +o disk, ctrl+x exit
4. Once the driver is moved, run it once in the terminal Sh/clean


Little Tricks

use the Tab key to auto -complement commands
For example, think of the/system directory, enter the Cd/sy and then press the TAB key, the command will automatically fill into equal Cd/system

manipulate files and directories with spaces in the name
Spaces are written in the command, for example, to enter My Documents, the command is CD My Documents



——

Common shell commands under Mac

Related Article

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.