본문 바로가기

webdesign/etc.

Mac terminal commands

 

https://www.macupdate.com/blog/post/91-mac-terminal-commands-list

 

Mac Terminal Commands and Tricks List [2020 Edition]

The Terminal is an important part of the MacOS environment. Do you know Terminal commands and tricks? You will soon. Here’s an introduction to this intimidating application.

www.macupdate.com

Mac Terminal Commands List

man [command] If you do not know what a command does or what a specific parameter related to a command does, the manual (man) page will provide you with all the information you need. 
. Current Directory. Wherever you are required to enter a directory location, this will refer to the directory you are currently in.
.. Parent Directory. Wherever you are required to enter a directory location, this will refer to the parent of your current directory
* Wildcard. Anything that matches certain criteria. For example “*.jpg” means any file with the jpg extension.
~ Home Directory
clear Used to clear the space of your Terminal
sudo [command] Some commands require you to be a superuser. In such cases, you can use this command to gain such privileges provided you are an admin of the system. You will be required to enter your administrator password to execute such commands.
history The Terminal keeps a history of all the commands you have entered. This command will display all the commands you have entered.
history -c Deletes the command history of the Terminal

List Directory commands

pwd Print working directory (Outputs the address of the current directory )
ls Displays the names of files and subdirectories containing in the folder
ls -l Lists in the long format. Includes information like file mode, owner, group name and many more
ls -al Lists detailed directory contents including hidden files.

Change Directory commands

cd Go to Home Directory
cd [folder name] Change directory (If the directory you would like to navigate to is not in the current directory, the complete file address is required )
cd .. Move up to the parent directory
cd ../.. Move up two levels (Could be extended to as many levels as possible by adding ../)
cd ~ Go to Home Directory

File and Directory management

mkdir <dir> Create a new subdirectory in the current directory
mkdir <dir1> <dir2> <dir3> Create several directories at once.
mkdir “<dir>” Create a folder with a space in its name
rm -R <dir> Remove a directory and its contents
cp -R <dir> <”newdir”> Copy a folder to another folder with spaces in its name
touch <file> Create a new file
nano <file> Opens a Terminal file editor. You can make changes to your files right from the Terminal.
cp <file> <dir> Copy a file to a directory
cp <file> <newfile> Copy a file to the current directory with the name given as <newfile>
rm <file> Remove a file completely. This will remove it completely from the system so be careful when using this command.
rm -i <file> Deleting a file after providing confirmation.
mv <file> <newfile> Move a file to another file/ Rename a file
mv <file> <dir> Move a file to a folder and will overwrite existing files
mv *.txt <dir> Move all text files of the current folder to a different folder

 

https://www.techrepublic.com/article/16-terminal-commands-every-user-should-know/

 

17 Terminal commands every user should know

The following is a list of entry-level operational commands aimed at understanding and using Terminal.

www.techrepublic.com

Terminal, or the command line interface (CLI), is considered by many to be the Holy Grail of computer management. At one time the CLI was the only way to accomplish anything on a computer; then, the CLI gave way to the graphical user interface (GUI) as the popularity of PCs increased.

Some things in the Terminal allow users to work faster for basic or repetitive tasks. Commands can be chained together to increase their usage, and more. 

더보기

 

change directory: to navigate into a directory

cd "path/to/directory/"

 

listing directory:to view the contents (files and directories) inside of the current directory

ls "path/to/directory/"

 

open files : 

open "filename"

 

copy a file to another directory : 

cp "filename" "newfilename"

 

move a file

mv "filename" "path/to/new/file/location"

 

create a text file : 

touch myfile.txt

 

create a directory : 

mkdir "path/to/new/directory"

 

remove an empty directory

rmdir "path/to/directory"

 

remove nested directories:When you want to remove an entire directory that might contain other directories or files, then therm -Rcommand is where you will turn.This command is irreversible,  (unlike deleting files in the Finder and being able to restore them from the Trash). When this command is executed, all files and directories inside of the path you specify will be deleted immediately. 

rm -R "/path/to/root/directory"

 

execute commands with superuser privileges: sudo(or super user do) is a command that allows you to elevate your user privileges while executing the command to administrator privileges. This is required for some commands to run —for instance removing a file that is owned by another user. When you run this command, you will see a password field appear in the Terminal where you will need to type your user account password to finish the command execution.

sudo "command" 

 

list actively running computer processes :to see the stats of your system updated in the Terminal window, including the memory, CPU and disk utilization

top

 

quite sub screen and return to terminal:For commands that run in perpetuity when executed, you can end execution of the process by pressing the q key on your keyboard. Alternatively you can also press Control+C.

After executing a command, such astopto view active processes, press " q" to exit.

 

clear the terminal screen of all previous commands :

clear

 

copy contents of a folder to a new folder : 

ditto -V "MyFolder" "MyNewFolder"

 

exit : 

exit

 

 

https://www.makeuseof.com/tag/mac-terminal-commands-cheat-sheet/

 

The Mac Terminal Commands Cheat Sheet

Our mega cheat sheet of Mac terminal commands provides a great reference for all the important commands you should know.

www.makeuseof.com