Week 2 + 3 Flashcards

1
Q

What do the commands below do?

tilda (~) command?

whoamii command?

pwd command?

cd command?

A

tilda(~) goes to the home directory

whoami checks who the user is

pwd checks the current working directory(where u are)

cd command changes directory listed after cd

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

What are Paths?

Types of Paths?

A

List of directories separated by /.
example: /home/tenzing/desktop

Types: Absolute(starts with /), and Relative

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

Differences with Absolute and Relative paths?

A

Absolute: starts with / root directory

Relative: starts at current directory. use .. to go back a directory or ../../

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

What does ls -a command do?

what does ls -l command do?

A

Shows all hidden files and folders, hidden folders will have a . in front

Gives a long list with detailed info.

1st Column: File type and access
permissions
* 2nd Column: # of HardLinks to the
File
* 3rd Column: Owner and the
creator of the file
* 4th Column: Group of the owner

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

In the ls -l command
The first character on each line indicates the type.
List the types:

A

d (directory)
- (regui]lar file)
l (symbolic link)
s (socket)
p (pipe)
b (block file)
c (character file)

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

drwxr-xr-x

define this

A

d(type)
rwx(read-write-execute for owner)
xr(perms for group)
x(perms for others)

r = read
x = execute
w = write

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

What does -h command do?

And describe human-readable format?

A

when file size too big makes it easier to read. M - megabytes, G - Gigabytes, T- Terabytes.

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

What are different ways to sort with ls command?

A

ls -r (recursive, sort backwards)

ls -s (sort by file size)

ls -t (sort by time)

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

How to use ls to get a detailed timestamp?

A

ls –full-time

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

How to get to the manual page on how to use glob?

A

man 7 glob

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

What does the asterisk(*) do? and uses?

A
    • represents any name
      d - name that ends with d
      a
      - name that starts with a
      c - name that contains c
      a*c - name that starts w/ a and ends w/ c
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the ? character do?

A

??? - names that contain 3 characters

d.??? - name that starts with d. then contains any 3 characters

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

What does the square brackets do
[ ]?

A

[abc]d - begins with either a, b, or c and ends with d.

[a-zA-Z][0-9] - begins with any letter lower or uppercase and ends with any number from 0-9

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

What does [!] do?

A

[!abc]d – this is a name that does NOT begin with either character ‘a’
or ‘b’ or ‘c’ and ends with character ‘d’

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

What do the curly brackets do?

A

Curly brackets {} are used to specify terms that are separated by commas and each term must be a name or a wildcard.

Same as IN (value1, value2) in DBAS

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

How to create text files?

A

touch newfile.txt

or

cat > newfile.txt
content
content
CTRL-D to save

17
Q

How to create directory?

and

How to create 3 directories at once? named ‘a’, ‘b’, ‘c’

A

mkdir directoryname

mkdir a b c

18
Q

Create a two parents(o and s)
and s has two children

A

mkdir -p o/p/q/r s/{sub1,sub2}

19
Q

How to remove directories and files?

A

rmdir to remove directory

rm filename or
rm -r filename to force delete

20
Q

How to copy and move files and directories?

A

copy files:
cp filename end location
copy directory:
cp -r directoryname endlocation

move files:
mv filename endlocation

Use -n for no clobber, to prevent cp and mv commands from overwriting content at the destination

21
Q

How to rename files or directories?

rename directory ‘a’ to ‘aaa’ and move ‘aaa’ to ‘b’

A

mv directory newname

mv a b/aaa

22
Q

Types of text editors?

A

nano and vim

23
Q

Explain the difference between single hypen(-l) and double hyphen?

A

Single hypen options are for short form (-h), while double hypen are for full words (–human-readable).

24
Q

How to check for history?

A

history command

25
Q

Create a variable called greet and assign it a value of Hello. Then Display it.

A

greet=Hello

echo $greet

26
Q

Export the variable greet as an environment variable. Then unset it.

A

export greet
env | grep greet

unset greet

27
Q

What are the 4 types of commands

A

Internal - part of the shell(cd)

External - require executable files to run (which command)
type -a echo

Aliases - short name given to long commands

Functions - Complex structures that can be used to create new commands or change behaviour of existing commands

28
Q

What is root user

A

Root is a superuser account.

Recommended that you use sudo instead as a home user.

29
Q

The CLI is a very powerful and fast interface that allows users ______ ________ _______ _________ ______ _______ _________.

A

The CLI is a very powerful and fast interface that allows users to complete various tasks
by issuing commands.

30
Q

Once a user has entered a command, the terminal then accepts what the
user has typed and passes it to _ ___.

A

Once a user has entered a command, the terminal then accepts what the
user has typed and passes it to a shell.

31
Q

A shell is an application that allows users to use the services of an operating
system

It is named a shell because it ___________________________________.

_____ is the most commonly used shell in Linux.

A

A shell is an application that allows users to use the services of an operating
system

It is named a shell because it is the outermost layer around the operating system.

Bash is the most commonly used shell in Linux.

32
Q

breakdown the components:
tenzing@comp:~$

A

tenzing@comp:~$

tenzing: Username
comp: System name
~: current directory(~ means home)

33
Q

Two types of variables in Bash shell?

A

Local variables - store values, perform calculations, etc.
Environment variables - used to control the Linux run time environment

34
Q

Format for making a local variable?

How to check the value of a variable named “sum”

A

$ var=Hello
var(variable name)=Hello(value)

echo $sum

35
Q

There are many environment variables. For example: _____, _____, and ________ variables.

A

There are many environment variables. For example: PATH, HOME, and HISTSIZE variables.

36
Q

The ___ command outputs a list of the environment variables.

The _______ command is used to turn a local variable into an environment variable.

Variables can be removed using the unset command: _____ ___

A

The env command outputs a list of the environment variables.

The export command is used to turn a local variable into an environment variable.

Variables can be removed using the unset command: unset var

37
Q

Internet commands are the shell built-in commands.

Two Internal commands are ____ and ______

A

Two Internal commands are cd and echo

you can use the type command to check.

38
Q

External commands can be executed by typing _____ ______ __________ _______ _____ ________ __________.

A

External commands can be executed by typing the complete path to the executable file for that command.

the type command displays the location of external commands.