반응형
Basics | |
man [command] | Show the help manual of the command |
[command] -h | Get help about a command |
open [file] | Opens a file |
nano [file] | Opens the Terminal editor |
sudo [command] | Run command with the security privileges of the super user |
~ (Tilde) | Home directory |
.. (Double Period) | Parent directory |
. (Single Period) | Current directory |
/ (Forward Slash) | Top level directory |
exit | End a shell session |
Shift + Cmd + V | Paste the selection |
Option + Shift + Cmd + C | Copy plain text |
Ctrl + _ | Undo the last command |
Ctrl + Z | Puts whatever you're running into a suspended background process |
Ctrl + Y | Paste whatever was cut by the last command |
Ctrl + B | Move cursor one character backward |
Ctrl + F | Move cursor one character forward |
Option + ← | Move cursor one word backward |
Option + → | Move cursor one word forward |
Ctrl + D | Exit the current shell |
Ctrl + C | Kill whatever you're running |
Ctrl + L | Clear the screen |
Esc + T | Swap the last two words before the cursor |
Ctrl + T | Swap the last two characters before the cursor |
Ctrl + W | Delete the word before the cursor |
Ctrl + K | Clear the line after the cursor |
Ctrl + U | Clear the line before the cursor |
Ctrl + E | Go to the end of the line you're currently typing on |
Ctrl + A | Go to the beginning of the line you're currently typing on |
Command | Action |
Output | |
Tab | Auto-complete file and folder names |
<cmd1> | <cmd2> |
<cmd> > <file> | Direct the output of <cmd> into <file> |
<cmd> > > <file> | Appends the output of <cmd> to <file> |
head <file> | Output the first 10 lines of <file> |
less <file> | Output the contents of <file> using the less command that supports pagination and more |
cat <file> | Output the content of <file> |
Search | |
grep -rl "<text>" <dir> | Search for all files containing <text> inside <dir> |
grep "<text>" <file> | Output all occurrences of <text> inside <file> (add -i for case insensitivity) |
find <dir> -name <"file"> | Find all files named <file> inside <dir>. Use wildcards (*) to search for parts of filenames |
Environment Variable or Path | |
export PATH=$PATH:absolute/path to/program/ | Execute a program via terminal only in your current session. If you use a program regularly, add the path to shell configuration file. |
echo $PATH >path.txt | Export the path directory to a text file |
echo $PATH | Check the value of the PATH variable which storea a list of directories with executable files |
$echo | Tells the terminal to print something and show it to you |
printenv | Display a list of currently set environment variables. Also tells you which shell you're using |
Homebrew | |
brew cleanup | Remove stale lock files and outdated packages for all formula and casks. |
brew unpin [installed_formula] | Unpin to upgrade a package |
brew pin [installed_formula] | Pin a formula from getting upgraded |
brew outdated --cask | Search for outdated cask |
brew outdated --formula | Search for outdated formula |
brew outdated <formula> | <cask> |
brew upgrade <formula> | <cask> |
brew search text | /regex/ |
brew deps <formula> | <cask> |
brew list --cask | List only installed cask |
brew list --formula | List only installed formulas |
brew uninstall <formula> | cask> |
brew install <formula> | <cask> |
brew help | List of useful homebrew formula and cask commands |
brew doctor | Check brew for potential problems |
Network | |
traceroute [hostname] | Identify the path and the hops traversed by the packets from your device to the destination address |
ifconfig en0 | View your device IP and MAC address |
arp -a | View a list of all devices on your local network. It will show you the IP and MAC address of all the devices |
scp <file><user>@<host>:/remote/path | Copy <file> to a remote <host> |
ssh <username>@<host> | Establish SSH connection to <host> with user <username> |
curl -O <url/to/file> | Download file via HTTP, HTTPS, or FTP |
whois <domain> | Output whois info for a domain |
ping <host> | Ping host and display status |
Processes | |
ps -ax | grep <appname> |
kill PID | Quit process with ID <PID>. You'll see PID as a column in the Activity Monitor |
top -o rsize | Sort top by memory usage |
top -ocpu -s 5 | Display processes sorted by CPU usage, updating every 5 seconds |
top | Display live information about currently running processes |
ps -aux | Shows all the processes with %cpu, %mem, page in, PID, and command |
ps -ax | Output currently running processes. Here, a shows processes from all users and x shows processes that are not connected with the Terminal |
Permissions | |
chown <user>:<group> <file> | Change the ownership of a file to user and group. Add -R to include folder contents |
chmod -R 600 <dir> | Change the permission of a folder (and its contents) to 600 |
chmod 755 <file> | Change the permission of a file to 755 |
ls -ld/<dir> | Display the read, write, and access permission of a particular folder |
ls -ld | Display the default permission for a home directory |
Command History | |
!! | Execute the last command typed |
![value] | Execute the last command typed that starts with a value |
history n | Shows the previous commands you've typed. Add a number to limit to the last n items |
Ctrl + R | Search through previously used commands |
File and Directory Management | |
mv *.png ~/<dir> | Move all PNG files from current folder to a different folder |
mv -i <file> <dir> | Optional -i flag to warn you before overwriting the file |
mv <file> <dir> | Move a file to the folder, possibly by overwriting an existing file |
mv <file> <newfilename> | Move/rename |
rm <file1> <file2> <file3> | Delete multiple files without any confirmation |
rm -f <file> | Force removal without confirmation |
rm -i <file> | Delete a file only when you give confirmation |
rm <file> | Delete a file (This deletes the file permanently; use with caution.) |
ditto -V [folder path][new folder] | Copy the contents of a folder to new folder. In here "-V" print a line of status for every file copied |
cp <file1> <file2> <file3>/Users/<dir> | Copy multiple files to a folder |
cp -i <file><dir> | Prompts you before copying a file with a warning overwrite message |
cp -R <dir> <"new dir"> | Copy a folder to a new folder with spaces in the filename |
cp <file>~/<dir>/<newfile> | Copy a file to the folder and rename the copied file |
cp <file> <newfile> | Copy a file to the current folder |
cp <file> <dir> | Copy a file to the folder |
touch <file> | Create a new file without any extension |
rm -R <dir> | Delete a folder and its contents |
rmdir <dir> | Delete a folder (only works on empty folders) |
mkdir "<dir>" | Create a folder with a space in the filename |
mkdir <dir1> <dir2> <dir3> | Create several folders at once |
mkdir -p <dir>/<dir> | Create nested folders |
mkdir <dir> | Create new folder named <dir> |
File Size and Disk Space | |
df -H | Calculate free disk space in powers of 1,000 (as opposed to 1,024) |
df -h | Calculate your system's free disk space |
du -sk* | sort -nr |
du -s | Display an entry for each specified file |
du -sh [folder] | Human readable output of all files in a directory |
du | List usage for each subdirectory and its contents |
List Directory Contents | |
ls -la | List detailed directory contents, including hidden files |
ls -lo | List the file names with size, owner, and flags |
ls -lh | Long listing with human readable file sizes in KB, MB, or GB |
ls -lt | List the files sorted by time modified (most recent first) |
ls -l / | List of the file system from root with symbolic links |
ls -l | List in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more |
ls -S | Sort files or entries by size |
ls -F | Display a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic link |
ls -1 | Output the list of files in one entry per line format |
ls -a | List all entries including those with .(period) and ..(double period) |
ls -C | Force multi-column output of the listing |
ls | Display the name of files and subdirectories in the directory |
Change Directory | |
cd ../.. | Move up two levels |
cd .. | Move up to the parent directory |
pwd | Show your working directory |
cd - | Previous directory or folder you last browsed |
cd / | Root of the drive |
cd ~ | Home directory |
cd [folder] | Change directory, e.g. cd Documents |
cd | Home directory |
반응형
'Notes' 카테고리의 다른 글
[Photoshop] Shortcuts (0) | 2023.01.01 |
---|---|
[Mac] python3로 기본 설정 변경하기 (0) | 2022.10.24 |
[VS code] Shortcuts for Mac OS (0) | 2022.10.13 |
Mac에 git 설치하기 (0) | 2022.10.03 |
Apple Silicon Mac에서 Homebrew 설치 및 사용 (0) | 2022.10.02 |