LF Flashcards
Difference between terminal, console and shell
Terminal and console are similar, piece of equipment through which you could interact with a computer.
Terminal is a device file.
A shell is the primary interface that users see when they log in, whose primary purpose is to start other programs.
How does a process receive input from keyboard?
keyboard generates interrupt
kernel looks for the IRQ handler
interrupt handler converts into keycode
The input layer uses kernel keyboard layout tables to map the scan code (position of the key on the keyboard) to a key code (like A) and interprets Shift, Alt, etc. The result of this interpretation is made available via /dev/input/event* to userland processes. You can use evtest so those events.
Xserver or terminal reads from /dev/input/event* and
What is an inode number?
An inode is a unique number assigned to files and directories while it is created. The inode number will be unique to entire filesystem.
What information is stored in inode?
File type: regular file, directory, pipe etc.
Permissions to that file: read, write, execute
Link count: The number of hard link relative to an inode
User ID: owner of file
Group ID: group owner
Size of file: or major/minor number in case of some special files
Time stamp: access time, modification time and (inode) change time
Attributes: immutable’ for example
Access control list: permissions for special users/groups
Link to location of file
Other metadata about the file
How to check inode in Linux
stat hello
File: ‘hello’
Size: 66 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 530461 Links: 2
Access: (0774/-rwxrwxr–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-05-15 20:12:32.540352591 +0000
Modify: 2017-05-15 20:12:16.901527357 +0000
Change: 2017-05-19 17:41:37.394470321 +0000
Birth: -
ls -il
total 140984
520170 dr-xrw-rw- 2 linoadmin linoadmin 4096 Mar 9 2013 asciiquarium_1.1
263206 -rwxr-xr-x 1 linoadmin linoadmin 15436 Mar 9 2013 asciiquarium.tar.gz
519187 drwxr—– 2 root root 4096 Apr 13 01:35 baba
258717 -rwSr–r– 1 root root 5747 Apr 25 01:45 bootstrap
655799 drwxr-xr-x 2 root root 4096 May 16 17:46 course
528927 drwxr-xr-x 3 root root 4096 Apr 29 00:29 environments
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 1292800 126091 1166709 10% /
devtmpfs 60205 319 59886 1% /dev
tmpfs 62556 1 62555 1% /dev/shm
tmpfs 62556 367 62189 1% /run
/dev/vda2 128 13 115 11% /mnt/vda2
tmpfs 62556 1 62555 1% /run/user/0
Symbolic links (or soft links) and does sym link have inode information?
If we delete or move the original file, the link will be broken and our ‘filesync’ file will not be longer available.
permissions on the symbolic link are completely open. This is because the permissions are not managed
What are Hard Links?
when you create a hard link for a file, all you really do is add a new name to an inode.
The interesting thing about hard links is that there is no difference between the original file and the link: they are just two names connected to the same inode.
The directories cannot be hard linked. Linux does not permit this to maintain the acyclic tree structure of directories.
A hard link cannot be created across filesystems. Both the files must be on the same filesystems, because different filesystems have different independent inode tables (two files on different filesystems, but with same inode number will be different).
Linux move files changes inode number?
Will not change the inode number
It will only change if it is in another file partition
Where is Inode table stored?
there’s a table of inodes on each filesystem, and there’s a separate filesystem on each partition
But, on the Internet, I found that each directory has its own table of the inodes and names associated to the files inside it.
That’s a table that maps file names to inode numbers. That is, the directory is a list of entries (or some more sophisticated data structure), and each element of the list contains a file name and an inode number. To find the file’s metadata and contents, the system reads the inode number from the directory, then reads the designated entry in the inode table. To find a file given its path, the system starts with the root inode, finds that it’s a directory, finds the directory entry for the first element, reads its inode, and so on.
Linux Performance Tools
http: //www.brendangregg.com/linuxperf.html
http: //www.brendangregg.com/Slides/Velocity2015_LinuxPerfTools.pdf
Different linux commands to debugging an issue?
top (checks CPU and memory)
iotop (monitor Linux Disk I/O usage)
iostat (iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates)
sar (system activity report contains cpu, memory, netrwork interfaces)
vmstat (vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity)
strace (captures and records all system calls made by a process and the signals received by the process)
What is Anti-method?
1) Searching for problem when not sure what the problem is (ask user what are they experiencing)
2) Wrong fix by guessing, without understanding problems just fix it by guess and it works
3) Blame someone else without understanding the problem
What is USE method?
utilization - busy time
saturation - queueing
error
uptime command used for?
prints average load on the cpu 5, 15, 30
Types of DNS
Authoritative Nameserver
Recursive Resolver
https://serverfault.com/questions/422288/what-is-the-difference-between-authoritative-nameserver-and-recursive-resolver
How does DNS traversal happen for a domain name (www.example.com)
It starts with (.) which is the root DNS Name Server, it redirects to com NS to ask for more details, similarly it keeps doing for every dot it encounters
DNS Zone Levels
The Domain Name System (DNS) defines a domain namespace, which specifies Top Level Domains (such as “.com”), second-level domains, (such as “acme.com”) and lower-level domains, also called subdomains (such as “support.acme.com”). Each of these levels can be a DNS zone.
For example, the root domain “acme.com” may be delegated to a Acme Corporation. Acme assumes responsibility for setting up an authoritative DNS server that holds the correct DNS records for the domain.
At each hierarchical level of the DNS system, there is a Name Server containing a zone file, which holds the trusted, correct DNS records for that zone.
Secondary DNS Zones
DNS servers can be deployed in a master/slave topology, where a secondary DNS server holds a read-only copy of the primary DNS server’s DNS records. The primary server holds the master zone file, and the secondary server constitutes an identical secondary zone; DNS requests are distributed between primary and secondary servers. A DNS zone transfer occurs when the primary server zone file is copied, in whole or in part, to the secondary DNS server.
What is a DNS Zone File?
A DNS Master File which authoritatively describes a zone
A DNS Cache File which lists the contents of a DNS cache—this is only a copy of the authoritative DNS zone
What constitutes DNS Zone Records?
In a zone file, each line represents a DNS resource record (RR). A record is made up of the following fields:
name
ttl
record class
record type
record data
Name is an alphanumeric identifier of the DNS record. It can be left blank, and inherits its value from the previous record.
TTL (time to live) specifies how long the record should be kept in the local cache of a DNS client. If not specified, the global TTL value at the top of the zone file is used.
Record class indicates the namespace—typically IN, which is the Internet namespace.
Record type is the DNS record type—for example an A record maps a hostname to an IPv4 address, and a CNAME is an alias which points a hostname to another hostname.
Record data has one or more information elements, depending on the record type, separated by a white space.
For example an MX record has two elements—a priority and a domain name for an email server.
DNS cache poisoning
DNS cache poisoning is the act of entering false information into a DNS cache, so that DNS queries return an incorrect response and users are directed to the wrong websites. DNS cache poisoning is also known as ‘DNS spoofing.’
Different type of interrupts an OS can get
I/O, Timer and Inter Processor