Terminal Commands Flashcards

1
Q

Ctrl + A

A

Go to the beginning of the line you’re currently typing on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Ctrl + E

A

Go to the end of the line you’re currently typing on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Ctrl + U

A

Clear the line before the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Ctrl + K

A

Clear the line after the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Ctrl + W

A

Delete the word before the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Ctrl + T

A

Swap the last two characters before the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Esc + T

A

Swap the last two words before the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Ctrl + L

A

Clear the screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Ctrl + C

A

Kill whatever you’re running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Ctrl + D

A

Exit the current shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Option + →

A

Move cursor one word forward

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Option + ←

A

Move cursor one word backward

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Ctrl + F

A

Move cursor one character forward

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Ctrl + B

A

Move cursor one character backward

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Ctrl + Y

A

Paste whatever was cut by the last command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Ctrl + Z

A

Puts whatever you’re running into a suspended background process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Ctrl + _

A

Undo the last command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

/ (Forward Slash)

A

Top level directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

. (Single Period)

A

Current directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

.. (Double Period)

A

Parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

~ (Tilde)

A

Home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

sudo [command]

A

Run command with the security privileges of the super user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

nano [file]

A

Opens the Terminal editor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

open [file]

A

Opens a file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

[command] -h

A

Get help about a command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

man [command]

A

Show the help manual of the command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

cd

A

Home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

cd [folder]

A

Change directory, e.g. cd Documents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

cd ~

A

Home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

cd/

A

Root of the drive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

cd -

A

Previous directory or folder you last browsed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

pwd

A

Show your working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

cd..

A

Move up to the parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

ls

A

Display the name of files and subdirectories in the directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

ls -C

A

Force multi-column output of the listing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

ls -a

A

List all entries including those with .(period) and ..(double period)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

ls -1

A

Output the list of files in one entry per line format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

ls -F

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

ls -S

A

Sort files or entries by size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

ls -l

A

List in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

ls -lt

A

List the files sorted by time modified (most recent first)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

ls -lh

A

Long listing with human readable file sizes in KB, MB, or GB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

ls -lo

A

List the file names with size, owner, and flags

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

ls -la

A

List detailed directory contents, including hidden files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

du

A

List usage for each subdirectory and its contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

du -sh [folder]

A

Human readable output of all files in a directory

47
Q

du -s

A

Display an entry for each specified file

48
Q

du -sk* | sort -nr

A

List files and folders, totaling the size including the subfolders. Replace sk* with sm* to list directories in MB

49
Q

df -h

A

Calculate your system’s free disk space

50
Q

df -H

A

Calculate free disk space in powers of 1,000 (as opposed to 1,024)

51
Q

mkdir

<dir>
</dir>

A

Create new folder named

<dir>
</dir>

52
Q

mkdir -p

<dir>/<dir>
</dir>
</dir>

A
53
Q

mkdir <dir1> <dir2> <dir3></dir3></dir2></dir1>

A

Create several folders at once

54
Q

mkdir “

<dir>"
</dir>

A

Create a folder with a space in the filename

55
Q

rmdir

<dir>
</dir>

A

Delete a folder (only works on empty folders)

56
Q

rm -R

<dir>
</dir>

A

Delete a folder and its contents

57
Q

touch <file></file>

A

Create a new file without any extension

58
Q

cp <file> <dir></dir></file>

A

Copy a file to the folder

59
Q

cp <file> <newfile></newfile></file>

A

Copy a file to the current folder

60
Q

cp <file>~/<dir>/<newfile></newfile>
</dir></file>

A

Copy a file to the folder and rename the copied file

61
Q

cp -R

<dir> &lt;"new dir"&gt;
</dir>

A

Copy a folder to a new folder with spaces in the filename

62
Q

cp -i <file><dir></dir></file>

A

Prompts you before copying a file with a warning overwrite message

63
Q

cp <file1> <file2> <file3>/Users/<dir></dir></file3></file2></file1>

A

Copy multiple files to a folder

64
Q

rm <file></file>

A

Delete a file (This deletes the file permanently; use with caution.)

65
Q

rm -i <file></file>

A

Delete a file only when you give confirmation

66
Q

rm -f <file></file>

A

Force removal without confirmation

67
Q

rm <file1> <file2> <file3></file3></file2></file1>

A

Delete multiple files without any confirmation

68
Q

mv <file> <newfilename></newfilename></file>

A

Move/rename

69
Q

mv <file> <dir></dir></file>

A

Move a file to the folder, possibly by overwriting an existing file

70
Q

mv -i <file> <dir></dir></file>

A

Optional -i flag to warn you before overwriting the file

71
Q

mv *.png ~/

<dir>
</dir>

A

Move all PNG files from current folder to a different folder

72
Q

Ctrl + R

A

Search through previously used commands

73
Q

history n

A

Shows the previous commands you’ve typed. Add a number to limit to the last n items

74
Q

![value]

A

Execute the last command typed that starts with a value

75
Q

!!

A

Execute the last command typed

76
Q

ls -ld

A

Display the default permission for a home directory

77
Q

ls -ld/

<dir>
</dir>

A

Display the read, write, and access permission of a particular folder

78
Q

chmod 755 <file></file>

A

Change the permission of a file to 755

79
Q

chmod -R 600

<dir>
</dir>

A

Change the permission of a folder (and its contents) to 600

80
Q

chown <user>:<group> <file></file></group></user>

A

Change the ownership of a file to user and group. Add -R to include folder contents

81
Q

ps -ax

A

Output currently running processes. Here, a shows processes from all users and x shows processes that are not connected with the Terminal

82
Q

ps -aux

A

Shows all the processes with %cpu, %mem, page in, PID, and command

83
Q

top

A

Display live information about currently running processes

84
Q

top -ocpu -s 5

A

Display processes sorted by CPU usage, updating every 5 seconds

85
Q

top -o rsize

A

Sort top by memory usage

86
Q

kill PID

A

Quit process with ID <pid>. You'll see PID as a column in the Activity Monitor</pid>

87
Q

ps -ax | grep <appname></appname>

A

Find a process by name or PID

88
Q

ping <host></host>

A

Ping host and display status

89
Q

whois <domain></domain>

A

Output whois info for a domain

90
Q

curl -O <url></url>

A

Download file via HTTP, HTTPS, or FTP

91
Q

ssh <username>@<host></host></username>

A

Establish SSH connection to <host> with user <username></username></host>

92
Q

scp <file><user>@<host>:/remote/path</host></user></file>

A

Copy <file> to a remote <host></host></file>

93
Q

brew doctor

A

Check brew for potential problems

94
Q

brew install <formula></formula>

A

Install a formula

95
Q

brew uninstall <formula></formula>

A

Uninstall a formula

96
Q

brew list

A

List all the installed formulas

97
Q

brew search

A

Display available formulas for brewing

98
Q

brew upgrade

A

Upgrade all outdated and unpinned brews

99
Q

brew update

A

Fetch latest version of homebrew and formula

100
Q

brew cleanup

A

Remove older version of installed formula

101
Q

brew tap homebrew/cask

A

Tap the cask repository from GitHub

102
Q

brew cask list

A

List all installed casks

103
Q

brew cask install <cask></cask>

A

Install the given cask

104
Q

brew cask uninstall <cask></cask>

A

Uninstall the given cask

105
Q

find

<dir> -name &lt;"file"&gt;
</dir>

A

Find all files named <file> inside <dir>. Use wildcards (*) to search for parts of filenames</dir></file>

106
Q

grep “”

A

Output all occurrences of inside (add -i for case insensitivity)

107
Q

grep -rl “”

A

Search for all files containing inside

108
Q

cat <file></file>

A

Output the content of <file></file>

109
Q

less <file></file>

A

Output the contents of <file> using the less command that supports pagination and more</file>

110
Q

head <file></file>

A

Output the first 10 lines of <file></file>

111
Q

<cmd> &gt; &gt; <file></file></cmd>

A

Appends the output of <cmd> to <file></file></cmd>

112
Q

<cmd> &gt; <file></file></cmd>

A

Direct the output of <cmd> into <file></file></cmd>

113
Q

cd ../../

A

Move 2 levels up