Basic Commands Flashcards

1
Q

How to display Disk Utility attached disks?

A

diskutier list

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

How to restart the Finder?

A

killall Finder

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

Command to make Mac speak?

A

say “Hi, Terminal says hello.”

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

Keep Mac from falling asleep.

A

caffeinated

-t (number of seconds)

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

Print CML history to screen?

A

history

-c (will clear history list)

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

Set root password.

A

sudo passwd root

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

Log-in as super user or root?

A

su or sudo -s

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

Change directory

A

cd /applications

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

Change to another volume

A

cd /volumes/”Mac OS X”

spaces need quotes

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

Remove or delete a file

A

rm

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

Remove a file in a different directory?

A

rm

example: re /Applications/Candybar.app

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

Remove a directory or folder.

A

rm -d

Example: rm -d delete_me

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

How to copy a file?

A

cp

Example: cp something.txt somethingeles.txt

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

How to move a file?

A

mv

Example: mv something.txt /Applications

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

Find a file

A

locate

Example: locate text.kext

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

Find a binary file

A

whereis

Example: whereis rm

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

Create a folder

A

mkdir
Example: mkdir directory
(it will make directory in current folder)

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

Move a folder

A

mv

Example: mv folder /Applications

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

Repair Permissions for a folder

A

chmod -R 755
chmod root:wheel
Examples: chmod -R 755 /System/Library/Extensions
(repair the Extensions folder)

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

Repair Disk Permissions without DiskUtility

A

diskutil repairPermissions /

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

List files in a directory

A

ls

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

Print Working Directory

A

pwd

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

Get a list of every process running on computer?

A

ps -ax

“process status” dumps all processes with ID #

24
Q

Check if a process is running?

A

ps -ax | grep

(this combines grep with the process status command”

25
Q

Forcibly end a process

A

kill

26
Q

Find current user

A

whoami

27
Q

Get current location or hostname?

A

hostname

28
Q

Navigate to home directory

A

cd ~
cd ~username
cd /Users/username

29
Q

How do you auto complete in CLI

A

press TAB

30
Q

Check powerbook standby time

A

pmset -g
(standby delay will be 10800 seconds by default)
chang it using:
sudo pmset -a standbydelay

31
Q

Open file in Quick Look

A

qlmanage -p

32
Q

Clear the terminal

A

clear

33
Q

How do you type a file name with a space in it

A
escape the space with \
Example: 
cd /Volumes/Macintosh\ HD/
or
cd "/Volumes/Macintosh HD/"
34
Q

List directory with list format

A

ls -l

35
Q

List files in a directory with hidden files

A

ls -a

combine with -l by typing ls -la to display both list format and hidden files

36
Q

Command to copy large amounts of data

A

ditto -V
(-V verbose prints one line to terminal for each file)
Example:
ditto -V /old/work/ /new/work/

37
Q

Change Screenshot file format

A

defaults write com.apple.screencapture type PDF
run
killall SystemUIServer
to see changes
to revert
defaults write com.apple.screencapture type png

38
Q

Change Screenshot location

A

$ defaults write com.apple.screencapture location /drag/location/here
then:: killall SystemUIServer

39
Q

Run a system stress test

A

yes

type Ctrl-C to stop

40
Q

View file system usage

A
sudo fs_usage
(type Ctrl-C to stop)
41
Q

View contents of any files

A

cat /path/to/file

42
Q

Rebuild Spotlight index for a drive.

A

sudo mdutil -E /Volumes/DriveName

this will delete the index and auto-rebuild

43
Q

Check the uptime of you mac

A

uptime

44
Q

Open file in any application

A

open -a /Application/AppName.app /path/to/file.txt

45
Q

List and install OS X software updates

A

sudo softwareupdate -l
(lists software updates)
sudo softwareupdate -ia

46
Q

Display a custom message at Login on multi user mac

A

sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText “Your Message!”
(to clear the message)
sudo defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText

47
Q

Run same command again

A

!!
(if you forget sudo after typing a command)
sudo !!
(will run same command with sudo in front)

48
Q

Download a file without the browser

A

curl -0 http://urltodownload.com/dmg.dmg

49
Q

Shutdown mac without delay

A

sudo shutdown -h now
sudo shutdown -r now
(add a time delay)
sudo shutdown -r +60

50
Q

Create a file of any size.

A

mkfile 1g test.abc

bytes (b) kilobytes (k) megabytes (m) gigabytes (g)

51
Q

Continually monitor a file (system log, etc.)

A

tail -f /var/log/system.log

terminal will constantly watch file as lines are added it will print to screen

52
Q

Get your IP address

A

ipconfig getifaddr en0

wired interface is en0 and wireless is en1

53
Q

Get your External IP address

A

curl ipecho.net/plain; echo

54
Q

How to test network connection

A

ping -c 10 www.apple.com

55
Q

Have the Mac read a text file

A

say -f

56
Q

Restore a disk image to External Drive

A

sudo asr -restore -noverify -source /path/to/diskimage/dmg -target /Volumes/VolumeToRestoreTo

57
Q

View all active processes

A

top