Intro to Command Line Flashcards

1
Q

Difference between /home/ubuntu and home/ubuntu

A

/home/ubuntu This path specifies a folder called “ubuntu” that lives under your root directory, then home directory.

home/ubuntu This path specifies a completely different folder. This path means there’s a folder called “ubuntu” that lives in a directory called “home”, which is itself in the current directory.

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

difference between ls and ls/

A

ls just shows list of current directory. ls/ shows list of root directory

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

Display contents of a file in an interactive way

A

less

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

Display documentation about a command

A

man

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

Display last part of a file

A

tail

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

How do display contents of a file?

A

cat

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

How do you create a file in the CLI?

A

touch

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

How to copy a file in CLI

A

cp

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

How to Display contents of a file, starting at the top and letting the user scroll down?

A

more

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

How to display first part of a file

A

head

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

How would you list any files or folders that end in ‘ot’?

A

ls /*ot

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

What does the ~ symbol mean?

A

~ - Your “home” directory, or the directory you are placed in when you log in.

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

What makes an executable different from other files?

3 reasons

A
  1. They have special characters at the beginning to tell the computer how to execute them.
  2. They have scripts or machine language as their content.
  3. They have the executable permission
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to list hidden files (dotfiles) in the current directory?

A

ls -a ~

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

What’s the difference between abc/ and /abc?

A

The path abc/ (also ./abc and ./abc/) are paths relative to your current working directory. The path /abc, however, is the file or directory abc in the root directory.

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

How To figure out a default executable’s location?

A

which

17
Q

How to re-initialize a particular environment file (such as .bashrc)

A

source ~/.bashrc

18
Q

To have a variable get interpolated, do you use single or double quotation marks?

A

Double quotation marks.

Example:

 $ MESSAGE1="This is message 1."
$ MESSAGE2="This is message 2."
$ MESSAGE="$MESSAGE1 $MESSAGE2"
$ echo $MESSAGE
This is message 1. This is message 2.
19
Q

What does the PATH variable do?

A

The PATH variable determines which directories are searched when a command is entered

You can add to PATH to make more commands available without having to memorize their exact path

Modifications to PATH, or any environment variable, on the fly will not be permanent; permanent modifications should be done in an environment file, like .bashrc

20
Q

What does&raquo_space; do?

A

The redirection operator (») is used to append text to a file. If the target file doesn’t exist, then it will be created.

21
Q

But why use sudo instead of just logging in as root? leave your Terminal open on accident.

A

There are several reasons for doing this, including the following:

The server administrator wants you to have root access for some commands and/or directories, but not for everything. In this case the administrator will set up sudo to have restrictions or whitelisted commands.

Running commands while logged in as root can be dangerous. Using a non-root user makes it obvious when you are running a command that requires root privileges because you have to prefix your command with sudo.

The sudo command provides a detailed audit trail so that system administrators can track what commands individuals used on system files.

Sudo uses a ticketing system where you put in your password once, then you don’t have to until you haven’t run any sudo commands for five minutes or longer. This adds security to your command line session, preventing others from gaining root access if you

22
Q

What does a REPL stand for?

A

Interfaces that Read Input, Evaluate Input, Print results and Loop back

23
Q

What are some examples of REPL interfaces?

A

mysql, ruby, python, or editors like vim and nano