Working with Linux files Flashcards

1
Q

Briefly explain Linux file philosophy

A

In Linux everything is a file, if it is not a file then it is a process.

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

Explain three basic file types in Linux

A
  1. Ordinary files
    Contains data, text or program instructions
  2. Directories
    Store both ordinary and special files
  3. Special files
    Provide access to hardware such as disk drives
    Enables you to access a single file using different file names.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Color that represent directory

A

Blue

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

Color that represent compressed archives files

A

Red

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

Color that represent text files

A

White

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

Color that represent images

A

Pink

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

Color that represent links

A

Cyan

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

Color that represent devices

A

Yellow

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

Color that represent executables

A

Green

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

Color that represent broken links

A

Flashing red

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

What is the important of using colors to represent file types?

A

It allows the user to see the file type without using any options to ls

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

The standard scheme for file type colors

A

/etc/DIR_COLORS:

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

What command do we use to find out more about data we are dealing with

A

file command

i. e #file Tama.txt

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

ls -l First column

A

represents file type and permission given on a file

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

ls -l Second column

A

Represents number of memory blocks taken by the file or dir

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

ls -l Third column

A

Represents owner of the file. The one who created it

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

ls -l Fourth column

A

Represents group of the owner

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

ls -l Fifth column

A

Represents file size in bytes

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

ls -l Sixth column

A

Represents date and time when the file was created or modified last time.

20
Q

ls -l Seventh column

A

Represents file or directory name

21
Q

Identify these character as they are used to indicate file type in ls -l list: - b c d l p s

A
  • : Regular file eg ASCII txt file, bins, exe or hard links
    b: Block special file. Block input/output device file eg physical hdd
    c : Character special file. Raw input/output device file eg physical hdd
    d : Directory containing other files
    l : Symbolic link file. Links on regular file
    p : Named pipe. Mechanism for IPC
    s : Socket used for IPC
    . : Invisible file
22
Q

How do list invisible files in Linux?

A

By including -a option to ls command

23
Q

What are the three Linux commands that allows you to view the contents of a file?

A
  1. cat
  2. More
  3. less
24
Q

How do you display contents of a file with line numbers?

A

By adding -b option to cat, more or less

25
Q

How do you know which shell you are using (2 ways)

A

Either check the line for your account in /etc/passwd or type the command: echo $SHELL

26
Q

How do view known shells in Linux system?

A

cat /etc/shells

27
Q

How do count total number of lines, words and characters in a file?

A

wc

28
Q

Apart from creating a new file, what are some effects of touch command to a file or directory?

A

It is used to update the access date or modification date of a file or a directory.

29
Q

How do you make a copy of an existing file?

A

cp

30
Q

How do you rename a file?

A

mv

31
Q

How do you delete a file?

A

rm

rm (for multiple files)

32
Q

Define Directory Tree?

A

It is a hierarchical structure for organizing files and directories

33
Q

How do you go back in your home directory or other users?

A

cd ~ or cd~

34
Q

How do you go back one level (last dir)?

A

cd -

35
Q

How do you see if your home dir has quota system set?

A

quota -v

36
Q

Explain two ways of displaying path names

A
  1. Absolute
    A path name is absolute if it is described in relation to root, so it begin with / always
  2. Relative
    Relative path names never begin with /
37
Q

How do you determine where you are within the file system at anytime?

A

pwd

38
Q

How do you list files in a dir?

A

ls

ls -l /usr/local (for long list)

39
Q

How do you delete a directory?

A

rm

40
Q

How do you define an environmental variables in Linux?

A

Are variables that are defined for the current shell and are inherited by any child shells or processes.

Environmental variables are used to pass information into processes that are spawned from the shell

41
Q

What are shell variables?

A

Are variables that are contained exclusively within the shell in which they were set or defined

The are often used to keep track of ephemeral data, like the CWD

42
Q

What does printenv command do?

A

Print all or part of the environment

43
Q

What does env command do?

A

Print all exported environment or run a program in a modified environment

44
Q

What does set command do?

A

Print the name and value of each shell variable

45
Q

Briefly describe commonly used variables in Linux

A
  1. BASH_VERSION - Holds the version of this instant bash - echo $BASH_VERSION
  2. HOSTNAME - The name of your computer - $echo HOSTNAME
  3. HOME - The home directory of current user - $echo $HOME
  4. PATH - The search path for commands - $PATH
  5. PS1 - Your prompt settings - $echo PS1
  6. TERM - Your login terminal type - echo $TERM
  7. SHELL - Set path to login shell - echo $SHELL