100% found this document useful (1 vote)
553 views

Mac Terminal Commands

Comandos de teclado para uso en Mac

Uploaded by

RFGC
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
553 views

Mac Terminal Commands

Comandos de teclado para uso en Mac

Uploaded by

RFGC
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

The Essential Mac Terminal

Commands Cheat Sheet


Shortcuts Change Directory
Auto-complete file and folder cd Home directory
Tab
names
Go to the beginning of the line cd [folder] Change directory, e.g. cd Documents
Ctrl + A cd ~ Home directory
you're currently typing on
Go to the end of the line you're cd/ Root of the drive
Ctrl + E
currently typing on Previous directory or folder you last
cd -
Ctrl + U Clear the line before the cursor browsed
Ctrl + K Clear the line after the cursor pwd Show your working directory
Delete the word before the cd.. Move up to the parent directory
Ctrl + W
cursor
cd../.. Move up two levels
Swap the last two characters
Ctrl + T
before the cursor List Directory Contents
Swap the last two words before Display the name of files and
Esc + T ls
the cursor subdirectories in the directory
Ctrl + L Clear the screen Force multi-column output of the
ls -C
Ctrl + C Kill whatever you're running listing
List all entries including those with
Ctrl + D Exit the current shell ls -a
.(period) and ..(double period)
Option + → Move cursor one word forward Output the list of files in one entry per
ls -1
line format
Option + ← Move cursor one word backward
Display a / (slash) immediately after
Move cursor one character each path that is a directory, *
Ctrl + F ls -F
forward (asterisk) after executable programs
Move cursor one character or scripts, and @ after a symbolic link
Ctrl + B
backward
ls -S Sort files or entries by size
Paste whatever was cut by the
Ctrl + Y List in a long format. Includes file
last command
Puts whatever you're running mode, owner and group name, date
ls -l
Ctrl + Z into a suspended background and time file was modified, pathname,
process and more
List the files sorted by time modified
Ctrl + _ Undo the last command ls -lt
(most recent first)
Basics ls -lh
Long listing with human readable file
sizes in KB, MB, or GB
/ (Forward Slash) Top level directory List the file names with size, owner,
ls -lo
. (Single Period) Current directory and flags
.. (Double Period) Parent directory List detailed directory contents,
ls -la
including hidden files
~ (Tilde) Home directory
Run command with the security
Command History
sudo [command] Search through previously used
privileges of the super user Ctrl + R
commands
nano [file] Opens the Terminal editor
Shows the previous commands typed.
open [file] Opens a file history n
Add a number to limit to last n items
[command] -h Get help about a command Execute the last command typed that
![value]
starts with a value
Show the help manual of the
man [command] !! Execute the last command typed
command
Copyright © 2019 MakeUseOf. For more cheat sheets, head over to www.makeuseof.com
File Size and Disk Space File and Directory Management
List usage for each Create new folder
du mkdir <dir>
subdirectory and its contents named <dir>
Human readable output of all mkdir -p <dir>/<dir> Create nested folders
du -sh [folder]
files in a directory Create several folders
Display an entry for each mkdir <dir1> <dir2> <dir3>
du -s at once
specified file Create a folder with a
List files and folders, totaling mkdir "<dir>"
space in the filename
the size including the Delete a folder (only
du -sk* | sort -nr
subfolders. Replace sk* with rmdir <dir> works on empty
sm* to list directories in MB folders)
Calculate your system's free Delete a folder and its
df -h rm -R <dir>
disk space contents
Calculate free disk space in Create a new file
df -H powers of 1,000 (as opposed touch <file>
without any extension
to 1,024) Copy a file to the
cp <file> <dir>
Permissions folder
Display the default permission Copy a file to the
ls -ld cp <file> <newfile>
for a home directory current folder
Display the read, write, and Copy a file to the
ls -ld/<dir> access permission of a cp <file>~/<dir>/<newfile> folder and rename the
particular folder copied file
Change the permission of a Copy a folder to a new
chmod 755<file> cp -R <dir> <"new dir"> folder with spaces in
file to 755
Change the permission of a the filename
chmod -R Prompts you before
folder (and its contents) to
600<dir> copying a file with a
600 cp -i <file><dir>
Change the ownership of a file warning overwrite
chown<user>:<gro message
to user and group. Add -R to
up><file> cp <file1> <file2> Copy multiple files to a
include folder contents
<file3>/Users/<dir> folder
Processes Delete a file (This
Output currently running deletes the file
rm <file>
processes. Here, a shows permanently; use with
ps -ax processes from all users and x caution.)
shows processes that are not Delete a file only when
rm -i <file>
connected with the Terminal you give confirmation
Shows all the processes with Force removal without
rm -f <file>
ps -aux %cpu, %mem, page in, PID, and confirmation
command Delete multiple files
Display live information about rm <file1> <file2> <file3> without any
top confirmation
currently running processes
Display processes sorted by mv <file> <newfilename> Move/rename
top -ocpu -s 5 CPU usage, updating every 5 Move a file to the
seconds folder, possibly by
mv <file> <dir>
top -o rsize Sort top by memory usage overwriting an existing
Quit process with ID <PID>. file
kill PID You'll see PID as a column in the Optional -i flag to warn
Activity Monitor mv -i <file> <dir> you before overwriting
ps -ax | grep the file
Find a process by name or PID Move all PNG files
<appname>
mv *.png ~/<dir> from current folder to
a different folder

Copyright © 2019 MakeUseOf. For more cheat sheets, head over to www.makeuseof.com
Network Search
Ping host and display Find all files named <file>
ping <host>
status find <dir> -name inside <dir>. Use wildcards
Output whois info for a <"file"> (*) to search for parts of
whois <domain>
domain filenames
Download file via Output all occurrences of
curl -O <url/to/file>
HTTP, HTTPS, or FTP grep "<text>" <file> <text> inside <file> (add -i
Establish SSH for case insensitivity)
ssh <username>@<host> connection to <host> Search for all files
with user <username> grep -rl "<text>" <dir> containing <text> inside
scp <dir>
Copy <file> to a
<file><user>@<host>:/rem
ote/path
remote <host> Output
Output the content of
Homebrew cat <file>
<file>
Check brew for Output the contents of
brew doctor
potential problems <file> using the less
less <file>
brew install <formula> Install a formula command that supports
pagination and more
brew uninstall <formula> Uninstall a formula Output the first 10 lines of
List all the installed head <file>
brew list <file>
formulas Appends the output of
Display available <cmd> > > <file>
brew search <cmd> to <file>
formulas for brewing Direct the output of
Upgrade all outdated <cmd> > <file>
brew upgrade <cmd> into <file>
and unpinned brews Direct the output of
Fetch latest version of <cmd1> | <cmd2>
<cmd1> to <cmd2>
brew update homebrew and
formula
Remove older version
brew cleanup
of installed formula
Tap the cask
brew tap homebrew/cask repository from
GitHub
brew cask list List all installed casks
brew cask install <cask> Install the given cask
Uninstall the given
brew cask uninstall <cask>
cask

Copyright © 2019 MakeUseOf. For more cheat sheets, head over to www.makeuseof.com

You might also like