Command Line Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Prompt

A

$

For Amazon Linux

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

Cursor

A

Where anything typed will show up

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

echo

A

display text in output

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

pwd

A

present working directory

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

command format

A

[command] [arguments…]

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

man [command]

A

Displays manual for [command]

Type “q” to exit manual.

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

Command Line Uses

A
Restart servers
Rename hundreds or thousands of files according to a prescribed pattern
Manage system logs
Set up scheduled tasks (cron jobs)
Debug server issues
Monkey patch code on a server
Query data
Set up databases and servers
--- and many more
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

cd [directory]

A

change directory

by itself, changes to the home directory, and with argument goes to the indicated directory

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

ls

A

list files and directories in current directory

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

pwd

A

display the path of the current directory

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

touch

A

create a file

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

mkdir

A

make directory

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

rm

A

remove a file or directory

Is permanent!

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

cp

A

copy a file or directory

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

mv [source] [destination]

A
move or rename a file or directory
movement is relative to current directory
.. = parent directory
. = current directory
/[directory name] = child directory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

cat

A

display contents of a file

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

more

A

displays contents of a file, starting at the top and letting the user scroll down

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

less

A

display contents of a file in an even ore interactive way

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

head

A

displays first part of a file

20
Q

tail

A

displays last part of a file

21
Q

cd /

A

change to parent directory

22
Q

ls -1

A

lists files and directories in the current directory, each on a new row of output

23
Q

cd ~

A

change to home directory

cd $HOME also works

24
Q

q

A

exit current screen, eg “man”, “more”, etc.

25
Q

clear

A

clears current output screen

26
Q

/

A

root directory, or separator for listing directories

27
Q

, or ./

A

current directory

28
Q

.. or ../

A

parent directory

29
Q

../..

A

grand parent directory

30
Q

*

A

wildcard

31
Q

ls -a

A

includes hidden files in list

“ ls -d .* “ lists only the hidden files

32
Q

ls -lah

A

Get detailed information about the files and directories listed

33
Q

which [command]

A

shows the directory where the executable exists for the [command]

34
Q

env

A

display environment variables and values

35
Q

variable=”value”

A

how to set an environment variable value

note that there are no spaces

36
Q

ps1

A

environment variable for the prompt

37
Q

.bashrc, .bash_profile

A
environment files (for bash, not Zsh)
nano ~/.bashrc to edit
38
Q

bin

A

binary: executable file

39
Q

PATH

A

environment variable.
determines which directories are searched when a command is entered
an ordered, colon-delimited list of directories that contain executables
PATH can be amended to add directories for executables
to permanently change PATH: .bashrc

40
Q

rwx

A

read, write, exectute

41
Q

drwxrwxr-x 3 ec2-user ec2-user practice

A

rwx = read, write, execute
d | rwx | rwx | r-x | 3 |ec2-user | ec2-user | practice
directory | User wx | Group rwx | Other rwx | # files | user name | group name | file / directory name

42
Q

chmod u-w test.txt

A

add write permissions for user to file test.txt

43
Q

chmod 777 text.sh

A
set permissions on text.sh to read, write, and execute for all users, groups, others.
Number	Permission
0	No permission granted.
1	Can execute.
2	Can write.
3	Can write and execute (2 + 1 = 3).
4	Can read.
5	Can read and execute (4 +1 = 5).
6	Can read and write (4 + 2 = 6).
7	Can read and write and execute (4 + 2 + 1 = 7).
43
Q

chmod 777 text.sh

A

set permissions on text.sh to read, write, and execute for all users, groups, others.
Number Permission
0 No permission granted.
1 Can execute.
2 Can write.
3 Can write and execute (2 + 1 = 3).
4 Can read.
5 Can read and execute (4 +1 = 5).
6 Can read and write (4 + 2 = 6).
7 Can read and write and execute (4 + 2 + 1 = 7).

44
Q

groups

A

display the groups for current user

45
Q

su

A

switch user

su - = switch to root user, password entry may be required

46
Q

REPL

A

Read-Eval-Print-Loop