1. Describe the meaning of GNU and the GPL.
GNU is a free software movement proposed by Richard Stallman in 1983, which requires us to freely use, freely change, and release software freely; the GPL is a protocol that defines how to be free.
2. List the Linux distributions you are familiar with.
Linux distributions: Redhat, CentOS, Ubuntu, Debian, Feroda, SUSE, etc.
3. Do you know the relationship between UNIX and Linux?
Linux is a Unix-like system, which can be said to be derived from UNIX.
4. How do I check if your Linux is 64-bit or 32-bit?
Uname-r, the result is a 32-bit Linux operating system if i386 or i586 or i686 is obtained, or 64-bit operating system if there is x86_64 in the result
5. How do you see the CPU information and memory information of your server?
View CPU Information: Cat/porc/cpuinfo
View memory Information: Cat/proc/meninfo
6. List some of the client software you know about the win SSH telnet to Linux.
PuTTY, Xshell, SECURECRT
7. When we telnet to Linux, how can I log in in addition to using a password? What do I need to save to your computer and what to put on the server file?
Also use the key to log in, you need to save the private key file on the computer, the public key content is fully pasted into the ~/.ssh/authorized_keys file on the server
8. What is the purpose of setting the grub password?
Increased system security requires a grub password to enter single-user mode
9. Briefly describe the Linux system startup steps.
BIOS power-on self-test, locate the MBR, find the bootloader (GRUB) bootloader through the MBR to find the location of the kernel kernel, find kernel, execute kernel image code, detect and load the hardware driver, and then pass from/etc/ The Inittab configuration file finds a given runlevel for system initialization, initialization process: executing/etc/rc.d/rc.sysinit, loading swap partitions, loading hardware modules, and performing some services to run first; Execute/ETC/RC.D/RC RUNLEVEL, start the service under the/ETC/RC.D/RCX.D directory, and finally execute the/etc/rc.d/rc.local; after initialization, run the Mingetty process, start the terminal, and finally the user logs in, which completes the system startup.
10. Please list the shortcuts you use and their role.
Crtl + u: Command line, clear the characters before the cursor
Crtl + K: command line, clear the character after the cursor
Crtl + L: Clear screen
Crtl + C: Stop a running operation
Crtl + Z: Pauses a running operation, resumes running, and is often used in conjunction with the Jobs 、!、 history command
Crtl + S: Lock terminal, lock, any input is not displayed, invalid
Ctrl + Q: Unlock the terminal, unlock it, restore the input, if there is an input character in the locked state, the character will be displayed
11. If your Linux root password is forgotten, how do you do it?
Restart the system, the system starts, the 5s press ENTER, the next key to select the line beginning with kernel (if you have the Grub password, press p, enter the grub password), press the E key to edit the kernel, add 1 or S or single at the end, press ENTER, then press the B key to enter one-user mode , enter passwd to modify the root password, and then reboot restart.
12. You accidentally put the/etc/passwd file to change the error, causing the system not to start normally, how do you do?
Optical drive loading system CD, boot system, F2 key into the BIOS, modify boot boot options, priority optical drive boot, save BIOS configuration exit, boot system, select rescue mode, choose not to use the network, prompt CD mount successful after entering the disc system, input command: chroot/mnt/ sysimage/Enter the Linux system, view the modified profile to the correct after saving exit, enter Exit command to exit to the disc system, finally reboot reboot, reboot after entering BIOS change back to priority hard drive boot
13. See how your disks are partitioned, and what are the file system types for each partition?
View disk Partitions: Fdisk-l
View partition file system type: Mount
14. Look at your disk size usage, and see your file system inode usage?
Disk size usage: df-h
Viewing file system inode usage: df-i
15. When using Fdisk partitioning, how many primary partitions can you divide? What's the relationship between logical partitions and extended partitions? Suppose my disk partition is this:/DEV/SDA1,/DEV/SDA2,/DEV/SDA3,/DEV/SDA5,/DEV/SDA6,/DEV/SDA7 then calculate the number of primary and logical partitions.
You can divide up to 4 primary partitions
The logical partition is built on the extended partition, the extended partition must be separated before the logical partition 2 primary partitions, 3 logical partitions
16. How do I check which version of your Linux is distributed? How do I check the kernel version of your Linux?
View Release version: Cat/etc/issue
View Kernel version: Uname-r
17. Which command can I use to see which users are currently logged on to the Linux system and which terminals are logged in?
W
18. How do I view the UID of the current user?
Id
19. How do I count the size of the/var/log directory?
Du-sh/var/log
20. To create a directory/tmp/aming/user1/123, consider the case where the/tmp/aming directory does not exist.
Mkdir-p/tmp/aming/user1/123
21. When copying a directory with CP, which option do I need to add?
-R option
22. What command can I use to count the number of lines in a document?
wc-l filename
23. How do I list the files and directories in a directory in chronological order?
Ls-lt
24. When deleting a directory or file, what options can be removed without asking us?
-F option
25. Using Ls-l to list the files and directories in the current directory, the first character of each line represents the type of the file, and if the character is-what does it mean, what does d,s,l,c,b mean?
-: Normal file
D: Catalogue
S: Socket file
L: Soft Link file
C: Character device file
B: Block device files
26. How does a soft connection work, how does a hard connection do? How to differentiate between soft and hard connections?
Create Soft Link: ln-s original file soft link file name
Create Hard Link: ln-s original file hard link file name
Distinguish soft and hard links: ls-li, soft link file identification character is L, hard link beginning character is-; Soft link file name will point to the original file, hard link will not point to the original file, hard link is the same as the original file inode, soft link and the original file Inode is different
27. How do I count the size of a file?
Du-sh filename
28. My linux server has not enough disk space, so I added a new hard disk, so what steps do I need to do to write data on the new disk? What command actions are used for each step?
Assume that the newly added drive is SDB
1) partition: Fdisk/dev/sdb partition, n new partition, select P Primary partition or E extended partition according to requirement, type partition size, p list current partition, W save partition Operation exit
2) Format: Format the previously created partition, such as partition/DEV/SDB/SDB1 needs to be formatted into EXT4 format, using command: Mke2fs-t ext4/dev/sdb1
3) Mount: There are two ways: temporary mount: MOUNT/DEV/SDB1 mount point
Permanently valid: Vim/etc/fstab
Add:/DEV/SDB1 mount point ext4 defaults 0 0
Save exit
Mount with the following command: Mount-a
29. When viewing with the ls-l command, what does the second column of numbers mean, and how do we calculate to get this number?
For files: How many files do you use the same inode (calculated: Original file + hard link number of original file)
For the directory: How many subdirectories are in the directory (calculation: LS can see the number of blue filenames of the directory + 2[2 representative.)
30. What commands can we use to view the contents of a text document? If this file is very large, how to view the first 50 lines of this file, how to view the last 100 lines of this file?
View Text Document contents: Cat, more, less, tail, head
View beginning 50 lines: head-50 filename
View last 100 lines: tail-100 filename
31. The content of a log file/var/log/1.log is constantly changing, so how to dynamically display the contents of a file?
Tail-f/var/log/1.log
32. Using the Vim tool, do the following: Copy the/etc/init.d/iptables to the/root/directory, rename it to Test.txt, open the test.txt with Vim, and set the line number; Move 6 characters down, right, left, right, respectively. ; Move the cursor to the 60th line, move it to the beginning of the line, move to the last line of the Test.txt file, move to the first row of the file, search for the iptables in the file, and count the total number of occurrences. ; Replace the iptables from the first line to the third line to iptable; restore the previous action, replace all iptables in the entire file with iptable, move the cursor to line 25, delete the character "$", delete the 50th line, and delete everything from 37 rows to 42 rows Copy 48 lines and paste them below 52 lines, copy the contents from 37 lines to 42 rows and paste them above 44 lines; Move the contents of lines 37 to 42 below 19 lines; Move the cursor to the first line, and change the/bin/sh to/bin/bash; Insert a new line below the first line and enter "# Hello !” ; Save the document and exit. Copy to/root/directory, rename to Test.txt: Current user is root, execute: CD;CP
/etc/init.d/iptables Test.txt
Vim Test.txt
Move down, up, left, and right 6 characters: 6j, 6k, 6h, 6l
Down, up one page: Crtl + F, Crtl + b
Move the cursor to line 60th: 60G
Move the cursor to the end of the line, and then move to the beginning: Shift + 4, SHIFT + 6
Move to the last line of the Test.txt file: G
Move to the first line of the file: GG
Search for the iptables that appear in the file, count the total number of occurrences: command line mode, enter/iptables, press n key down until the bottom left tip has reached the end of the text, altogether 11 replace the iptables from the first line to the third row with the iptable: command line mode,
In: 1,3$/iptables/iptable/g restore previous action: U replace all iptables in the entire file with iptable: command line mode, input: 1,
$s/iptables/iptable/g
Move the cursor to line 25, delete the character "$", delete the 50th line: 25G,HL the cursor to the character $, press X to delete; Delete line 50th: 50G,DD
Delete everything from 37 rows to 42 lines: command-line mode, input: 37,42d
Copy 48 lines and paste them below 52 lines; Copy the contents from 37 lines to 42 lines and paste them onto line 44: General mode, 48g,yy,52g,p; general mode, 37g,6yy,44g,p
Move the contents of rows 37 to 42 below the 19 line: General mode, 37g,6dd,19g,p
Move the cursor to the first line, change the/bin/sh to the/BIN/BASH:GG,L cursor to the right to the character/top, a toggle edit mode, enter BA, press ESC
Insert a new line below the first line and enter "# hello!" : Gg,o, Input # hello!
Save the document and exit: Press ESC, and then enter: X or: Wq or ZZ
33. Create a new user aming, and make the primary group Group1, the satellite group is group2, and then set a very complex password for the user.
Groupadd group1 group2
Useradd-g group1-g group2 aming
passwd aming
Two inputs more than 9 digits with uppercase and lowercase letters, numbers, special symbols (can also be generated with MKPASSWD, the tool needs to install the expect package)
34. Create a new user User3, then change the shell to/sbin/nologin, delete the User3 user, and delete it along with the user's home directory.
Useradd User3
Usermod-s/sbin/nologin
Userdel-r User3
35. Sometimes we want to temporarily switch to other users, what are the commands?
Su-username
36. If I want any user to be able to change the 1.txt, then how do we set the permissions for 1.txt?
chmod 666 1.txt or chmod +w 1.txt
37. I want to set all the files and directories in a directory (including level two, level three) to the main User1, the group of users how to do?
Chown-r user1:users Directory Name
What is the default permissions for the Linux system, and what are the permissions on the file? If you change its value, will you calculate the default permissions for the directory or file?
Directory default permissions: 755
File default permissions: 644
decided by umask
To change the Umask value:
Suppose Umask should be 001:umask 001
Calculation: Umask first converted from digital to rwx form:--------X
Directory default permissions = rwxrwxrwx-(--------x) = rwxrwxrw-, converted to digital form 776
File default permissions = rw-rw-rw--(--------x) = rwxrwxrw-, converted to digital form 666
39. Do you know what the role of suid is, please give an example of a Linux system that is actually used?
Suid for executable binary file settings, function: Let ordinary users of the executable binary files that the role of the file ownership of the file owner's permission to actually apply: executable binary file/usr/bin/passwd is set suid, so that ordinary users can/etc/ The passwd file is operated with the permissions of the main root of the file
40. Please create a new directory 123, and set permissions to implement such a requirement: Any user (except root) can create new, change, delete the file or directory you created, but cannot change other users.
mkdir 123
chmod 1777 123/
41. How to set permissions so that a file can only be added and cannot be deleted? And how to set permissions so that the file can not be deleted, renamed, set link, write, add data?
Make a file only add, cannot delete: chattr +a filename
Make this file cannot be deleted, renamed, set Link, write, new data: chattr-i filename;chattr +i filename
42. Do you know how to find the absolute path of a command? So which variable is this path derived from? How do I change the value of this variable and make it permanent?
To view the absolute path of the command: which command
By variable: $PATH
To change the value of a variable:
Vim ~/.bash_profile
Modify path= $PATH: $HOME/bin this line
Entry into force: source ~/.bash_profile
43. Please distinguish between atime,mtime,ctime three time, which command can be used to get to a file or directory of these three times?
Atime: Last Access time
Mtime: The last time the file content was modified
CTime: The last time the file attribute was modified
Gets the three time commands to a file or directory: Stat filename
44. If you run a command + option every day, and the command and options add up to a full 50 characters long, can you provide a quick and easy solution to run this command with just a few characters?
Using alias aliases, add alias in configuration file ~/.BASHRC and take effect with source ~/.BASHRC
45. Find all files (not directories) that are 100 days old under a directory and copy them to/tmp/.
Find. -type f-mtime +100|xargs-i cp {}/tmp/
46. Look for directories and files in a directory, or files larger than 1G in size, and delete them all the year before.
Find. -mtime +365-o-type f-size +1g|xargs RM-RF
47. Use the DD command to generate two test files with file sizes of 100M, 50M, respectively, and then compress and decompress using Gzip,bzip2,tar.
DD If=/dev/zero of=./100m bs=1m count=100
DD If=/dev/zero of=./50m bs=1m count=50
gzip, tar compress decompression:
Tar zcvf 100m.tar.gz 100M
Tar zcvf 50m.tar.gz 50M
Tar zxvf 100m.tar.gz 100M
Tar zxvf 50m.tar.gz 50M
BZIP2, tar compression decompression:
Tar jcvf 100m.tar.gz 100M
Tar jcvf 50m.tar.gz 50M
Tar jxvf 100m.tar.gz 100M
Tar jxvf 50m.tar.gz 50M
48. How to check the IP card, how to see if the current network adapter is connected?
View Nic Ip:ifconfig
To see if the connection is connected: Assume viewing the NIC Eth0:mii-tool eth0 or Ethtool eth0
49. Set IP to eth0 as follows: IP address 192.168.123.123, Subnet mask 255.255.255.0, Gateway 192.168.123.1,dns1 to 192.168.123.1,DNS2 for 8.8.8.8
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Ipaddr=192.168.123.123
netmask=255.255.255.0
gateway=192.168.123.1
dns1=192.168.123.1
dns2=8.8.8.8
Restart the network service to take effect:
Service Network restart
50. What can we do to make the changed NIC configuration file effective? Write at least two of them.
Method One: Restart network services, service network restart
Method Two: Restart the network interface, such as changing the NIC to Eth0, using Ifdown eth0;ifup eth0
51. What are the RPM package commands that the system has installed?
Rpm-qa
52. How do I check which RPM package is installed for a command?
RPM-QF ' which command '
53. How do I install, uninstall, and upgrade a RPM package using the RPM tool?
Installation: RPM-IVH RPM Package Full name
Uninstall: rpm-e RPM Package Name
Upgrade: RPM-UVH RPM Package Name
54. How do I use Yum to find, install, or uninstall an RPM package?
Search: Yum list|grep rpm package name or Yum search RPM package name
Installation: Yum Install RPM package name
Uninstall: Yum Remove RPM Package name
55. How to put your process into the background, and how to transfer the background process back to the foreground?
Process jumps in the background: Command &
Back to the foreground: jobs View the jobs ID,FG Jobsid running in the background
56. A partition we give it 10G, can actually really use the space only about 9G, this is why?
When formatting, the system defaults to 5% of the space given to Superuser root, and the file system itself takes up space
57. How do I open a document and let the cursor navigate to line 35th when I enter it?
vim-35 filename
58. How do I unzip the. Tar.xz tarball?
Tar JXVF Compressed Package name
How does yum download a RPM package?
Install the package first: Yum install-y yum-plugin-downloadonly
Download RPM package to current directory: Yum install--downloadonly--downloaddir=./RPM package Name
60. Where should I download the source package? When we install the source package, when you unzip, what is the first thing you have to do, and then we go to install?
Pipe network download; First check the install or readme documentation
Some of my exercises