Linux Course notes Day03 after class homework selection

Source: Internet
Author: User

1. Describe the boot process from the Linux system to the login interface.

Answer:

(1) Power boot, BIOS self-test

(2) MBR boot

(3) Grub boot Menu

(4) Loading the kernel

(5) Start the INIT process

(6) Read Inittab files, execute scripts such as RC.SYSINIT,RC

(7) Start Mingetty, enter the login system interface

2. Describe the differences between soft links and hard links under Linux.

Answer:

(1) Default without parameters, the LN command creates a hard link

(2) The hard link is the same as the Inode node number of the source file, and the Inode node number of the soft link file is different from the source file

(3) The LN command cannot create a hard link to a directory, but can create a soft link

(4) Soft link can cross file system, hard link cannot cross file system

(5) Delete Soft link file, no effect on source file and hard link file

(6) Delete hard link files, no impact on source files and soft links

(7) Delete the source file, no impact on hard-link files, will cause its soft link invalidation

(8) Delete the source file and its hard link file, the whole file will be deleted.

(9) The snapshot function in many hardware devices, using the principle of similar hard links

3. Describe the respective meanings of Linux runlevel 0-6

Answer:

(1) 0: Shutdown

(2) 1: single-user mode

(3) 2: Multi-user text interface mode without network support

(4) 3: Multi-User text interface mode with network support

(5) 4: System reserved, not used

(6) 5: Multi-user mode with network support and X-window support

(7) 6: Restart

4. Describes the principle of file deletion under Linux.

Answer:

Linux is the number of link to control the deletion of files, only one file does not exist any link, the file will be deleted. In general, there are only 2 link counters per file: I_count and I_link.

The meaning of I_count is that the number of current files (or calls) is used, and the meaning of I_link is the number of media links (number of hard links): It can be understood that I_count is a memory reference counter, a reference counter for I_link disk.

When a file is referenced by a process, the corresponding number of i_count is incremented, and the corresponding number of i_link is incremented when the hard link to the file is created.

For the Delete command RM, the actual reduction is the disk reference counter I_link. When a file is being called by a process and the user performs an RM operation to delete the file, the file cannot be found by executing LS or other administrative commands, but the process of invoking the file continues to execute normally, and the content can be read and written correctly from the file.

This is because the RM operation only i_link the file to 0, but because the file is still referenced by the process, the i_count of the file is not 0. So even if the RM operation is performed, the system does not actually delete the file, when only I_count and I_link are 0, This file will only be deleted from the real one. That is, you also need to dismiss the process's call to the file.

When the file is not called, does the RM operation delete the deleted file after it has been executed?

RM Operation Just set the I_link of the file to 0, the actual is to delete the filename to the inode link, at this time, and do not delete the file entity is block data block, if the timely stop and its work, the data can be retrieved, if you continue to write data at this time, Then when the data can be allocated to the block data of the deleted data block, at this time the file will be really recycled, there will be no way back.

Summary: The above describes the Linux system delete file conditions: I_count and I_link are all 0, delete the principle: Delete the file name to the Inode link, will link to 0, and the data is still in block.

5. Problem: Please give example of Date command in the following format: 11-02-26. Then give the implementation of the weekly output such as: Saturday output of 6, please give the command separately.

Answer: Date +%y-%m-%d;date +%w

[[email protected] ~]# echo $ (date +%y-%m-%d)

13-05-24

[[email protected] ~]# echo ' Date +%y-%m-%d '

13-05-24

#------------à the usage of the above two commands is different and can be used for scripting

Excuse me, teacher, what's the difference in usage here?

[Email protected] ~]# date +%y-%m-%d

13-05-24

Extended Full format Date:

[[email protected] ~]# echo ' Date +%y-%m-%d '

2013-05-24

[[email protected] ~]# echo ' Date +%f '

2013-05-24

[[email protected] ~]# echo ' Date +%d '

05/24/13

[[email protected] ~]# echo ' Date +%y-%m-%d-%h-%m-%s '

2013-05-24-20-36-15

Example of production environment:

[Email protected] ~]# tar zcvf services_$ (date +%f). tar.gz/etc/services

Tar: Remove the Beginning "/" from the member name

/etc/services

[Email protected] ~]# tar ZTVF services_2013-05-24.tar.gz

-rw-r--r--root/root 362031 2006-02-23 21:09:23 etc/services

In the production environment, backup, log, synchronization and other large number of occasions will generally use time as a processing file name, can be used in conjunction with the scheduled task to generate different file names

Achieve weekly output For example: Saturday output is 6

[[email protected] ~]# echo ' Date +%w '

5

[Email protected] test]# tar zcvf services_$ (date +%w). tar.gz/etc/services

Tar: Remove the Beginning "/" from the member name

/etc/services

[[email protected] test]# ls

services_5.tar.gz Test1.txt test2.txt Test3.txt

The advantage of using weekly polling is a maximum of 7 logs, no need to delete, the system will automatically overwrite the previous file

6. Problem: Extended issue: Print three days ago date format as: 2011-02-26

Answer:

Method One: Date +%f---Date ' 3 day ago '

Method Two: Date +%y-%m-%d–-date ' 3 day ago '

Method Three: Date +%f-d ' 3 day ago '

Method Four: Date +%f-d '-3 day ' (recommended, minimum input)

7. the contents of the known/oldboy/test.txt file are:

Oldboy

Xizi

Xiaochao

How to filter out the space in the file (requires command line implementation).

Solution One: Grep–v "^$"/oldboy/test.txt

Solution Two: sed law, sed-i "/^$/"

8. please give the correct shutdown and restart the server command.

Answer:

Shutdown: shutdown-h now; halt; Poweroff; Init 0

Restart: shutdown–r Now;reboot;init 6

Linux Course notes Day03 after class homework selection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.