Command Line Flashcards

(47 cards)

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
clear
clears current output screen
26
/
root directory, or separator for listing directories
27
, or ./
current directory
28
.. or ../
parent directory
29
../..
grand parent directory
30
*
wildcard
31
ls -a
includes hidden files in list | " ls -d .* " lists only the hidden files
32
ls -lah
Get detailed information about the files and directories listed
33
which [command]
shows the directory where the executable exists for the [command]
34
env
display environment variables and values
35
variable="value"
how to set an environment variable value | note that there are no spaces
36
ps1
environment variable for the prompt
37
.bashrc, .bash_profile
``` environment files (for bash, not Zsh) nano ~/.bashrc to edit ```
38
bin
binary: executable file
39
PATH
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
rwx
read, write, exectute
41
drwxrwxr-x 3 ec2-user ec2-user practice
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
chmod u-w test.txt
add write permissions for user to file test.txt
43
chmod 777 text.sh
``` 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
chmod 777 text.sh
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
groups
display the groups for current user
45
su
switch user | su - = switch to root user, password entry may be required
46
REPL
Read-Eval-Print-Loop