39 Common Linux system simple face questions

Source: Internet
Author: User
Tags dns2 iptables rsync

39 Common Linux system simple face questions

This article mainly shares 39 common Linux system simple interview questions, including how to see how the current Linux system has several physical CPUs and the number of cores per CPU, how real-time to see how much network card traffic and so on, I hope to help you.

1, how to see the current Linux system has several physical CPUs and the number of cores per CPU?

Answer: [[email protected] ~ 10:55 #35]# cat/proc/cpuinfo|grep-c ' physical ID '

4

[Email protected] ~ 10:56 #36]# cat/proc/cpuinfo|grep-c ' processor '

4

2, check the system load there are two commonly used commands, which two? What do these three numbers mean?

Answer: [[email protected] ~ 10:56 #37]# W

10:57:38 up min, 1 user, Load average:0.00, 0.00, 0.00

USER TTY from [email protected] IDLE jcpu PCPU

Root pts/0 192.168.147.1 18:44 0.00s 0.10s 0.00s W

[Email protected] ~ 10:57 #38]# Uptime

10:57:47 up min, 1 user, Load average:0.00, 0.00, 0.00

Where load average is the system load, three values represent the average load of the system in one minute, five minutes, and 15 minutes, that is, the average number of tasks.

3, Vmstat R, B, Si, so, bi, bo What do these columns mean?

Answer: [[email protected] ~ 10:57 #39]# Vmstat

procs-----------Memory-------------Swap-------io------System-------CPU-----

R b swpd free buff cache si so bi bo in CS us sy ID WA St

0 0 0 1783964 13172 106056 0 0 29 7 15 11 0 0 99 0 0

R is running, which indicates the number of tasks being run

B is blocked, which indicates the number of blocked tasks

Si indicates how much data is read from the swap partition into memory

So indicates how much data is written from memory to the swap partition

BI indicates how much data is read from disk into memory

Bo indicates how much data is written to disk from memory

Précis-Writers: I--input, enter memory

o--output, out of memory

s--swap, swap partition

b--block, block device, disk

The units are all KB

4, Linux system, you know how to distinguish between buffer and cache?

A: Both buffer and cache are an area in memory, when the CPU needs to write data to disk, because the disk speed is slow, so the CPU first put the data into buffer, and then the CPU to perform other tasks, buffer data will be written to disk periodically When the CPU needs to read data from disk, because the disk speed is slow, you can put the data to be used in advance cache,cpu directly from the cache to take the data much faster.

5. When using top to view system resource usage, which column represents memory consumption?

Answer: PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND

301 Root 0 0 0 0 S 0.3 0.0 0:00.08 jbd2/sda3-8

1 Root 0 2900 1428 1216 S 0.0 0.1 0:01.28 Init

2 Root 0 0 0 0 S 0.0 0.0 0:00.00 Kthreadd

3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0

Virt Virtual Memory usage

Res Physical Memory usage

SHR Shared Memory usage

%mem Memory Usage

6, how to check the real-time network card traffic is how much? How do I view historical network card traffic?

Answer: Install the Sysstat package and view it using the SAR command.

Yum install-y sysstat# Install the Sysstat package to get the SAR command

Sar-n dev# View network card traffic, default 10 minute update

Sar-n DEV 1 10# One second, showing 10 times

Sar-n dev-f/var/log/sa/sa22# View traffic logs for a specified date

7. How do I see which processes are currently in the system?

Answer: Ps-aux or ps-elf

[Email protected] ~ 13:20 #56]# Ps-aux

Warning:bad syntax, perhaps a bogus '-'? See/usr/share/doc/procps-3.2.8/faq

USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND

Root 1 0.0 0.0 2900 1428? Ss 10:43 0:01/sbin/init

Root 2 0.0 0.0 0 0? S 10:43 0:00 [Kthreadd]

Root 3 0.0 0.0 0 0? S 10:43 0:00 [migration/0]

Root 4 0.0 0.0 0 0? S 10:43 0:00 [ksoftirqd/0]

......

[Email protected] ~ 13:21 #57]# ps-elf

F S UID PID PPID C PRI NI ADDR SZ wchan stime TTY time CMD

4 S Root 1 0 0 80 0-725-10:43? 00:00:01/sbin/init

1 S root 2 0 0 80 0-0-10:43? 00:00:00 [Kthreadd]

1 S Root 3 2 0-40--0-10:43? 00:00:00 [migration/0]

1 S Root 4 2 0 80 0-0-10:43? 00:00:00 [ksoftirqd/0]

1 S Root 5 2 0-40--0-10:43? 00:00:00 [migration/0]

8, PS when viewing the system process, there is a column stat, if the current process of the stat for the SS mean what meaning? What do you mean by Z?

A: s means hibernation; s represents the main process; Z indicates a zombie process.

9. How do I see which ports are open on the system?

Answer: [[email protected] ~ 13:20 #55]# NETSTAT-LNP

Active Internet connections (only servers)

Proto recv-q send-q Local address Foreign address State Pid/program Name

TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1035/sshd

TCP 0 0::: $:::* LISTEN 1035/sshd

UDP 0 0 0.0.0.0:68 0.0.0.0:* 931/dhclient

Active UNIX domain sockets (only servers)

Proto refcnt Flags Type State i-node pid/program name Path

UNIX 2 [ACC] STREAM LISTENING 6825 1/init @/com/ubuntu/upstart

UNIX 2 [ACC] STREAM LISTENING 8429 1003/dbus-daemon/var/run/dbus/system_bus_socket

10. How to check the status of network connection?

Answer: [[email protected] ~ 13:22 #58]# Netstat-an

Active Internet connections (servers and established)

Proto recv-q send-q Local address Foreign address state

TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

TCP 0 0 192.168.147.130:22 192.168.147.1:23893 established

TCP 0 0::: $:::* LISTEN

UDP 0 0 0.0.0.0:68 0.0.0.0:*

......

11, want to modify the IP, need to edit which configuration file, after modifying the configuration file, how to restart the network card, so that the configuration takes effect?

A: Use the VI or Vim editor to edit the NIC configuration file/etc/sysconfig/network-scripts/ifcft-eth0 (if the eth1 file is named Ifcft-eth1), the following:

Device=eth0

Hwaddr=00:0c:29:06:37:ba

Type=ethernet

Uuid=0eea1820-1fe8-4a80-a6f0-39b3d314f8da

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=192.168.147.130

netmask=255.255.255.0

gateway=192.168.147.2

dns1=192.168.147.2

dns2=8.8.8.8

After modifying the NIC, you can use the command to restart the network card:

Ifdown eth0

Ifup eth0

You can also restart the network service:

Service Network restart

12. Can I configure multiple IPs for a network card? If so, how to configure?

A: You can configure multiple IPs for a network card, with the following configuration steps:

cat/etc/sysconfig/network-scripts/ifcfg-eth0# viewing the configuration of eth0

Device=eth0

Hwaddr=00:0c:29:06:37:ba

Type=ethernet

Uuid=0eea1820-1fe8-4a80-a6f0-39b3d314f8da

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=192.168.147.130

netmask=255.255.255.0

gateway=192.168.147.2

dns1=192.168.147.2

dns2=8.8.8.8

(1) Create a new ifcfg-eth0:1 file

Cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0:1

(2) Modify the contents as follows: Vim/etc/sysconfig/network-scripts/ifcfg-eth0:1

Device=eth0:1

Hwaddr=00:0c:29:06:37:ba

Type=ethernet

Uuid=0eea1820-1fe8-4a80-a6f0-39b3d314f8da

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=192.168.147.133

netmask=255.255.255.0

gateway=192.168.147.2

dns1=192.168.147.2

dns2=8.8.8.8

(3) Restart the Network service:

Service Network restart

13, how to see if a network card is connected to the switch?

Answer: Mii-tool eth0 or Mii-tool eth1

14, how to view the host name of the current host, how to modify the hostname? What configuration file do I need to modify to continue to take effect after reboot?

A: View host Name: hostname

centos6.5

Modify host Name: hostname centos6.5-1

Permanent entry requires modification of the configuration file: Vim/etc/sysconfig/network

Networking=yes

Hostname=centos6.5-1

15. Which configuration file does the DNS need to modify?

Answer: (1) Set up DNS in file/etc/resolv.conf

(2) Setting up DNS in file/etc/sysconfig/network-scripts/ifcfg-eth0

16, use iptables write a rule: the source IP for 192.168.1.101 access to the native 80 port package directly rejected

Answer: iptables-i input-s 192.168.1.101-p tcp--dport 80-j REJECT

17. How do you want to save the Iptable rules to a file? How to recover?

A: Use Iptables-save redirect to file: Iptables-save > 1.ipt

Back with Iptables-restore reverse redirect: Iptables-restore < 1.ipt

18, how to back up a user's task plan?

A: Copy the task plan of the specified user under the/var/spool/cron/directory to the backup directory cron_bak/

cp/var/spool/cron/rachy/tmp/bak/cron_bak/

19. What does the preceding 5-digit table mean in the task plan format?

Answer: In turn: minutes, hours, days, months, weeks

20. How can I turn off services that are not used in the system?

A: (1) Use Visualizer: NTSYSV

(2) Use command: Chkconfig servicename off

21, how to make a service (if the service name is Nginx) only 3, 52 RunLevel Open, the other level off?

A: Turn off all operating levels first: Chkconfig Nginx off

Then open 35 RunLevel: Chkconfig--level

22, the Rsync Synchronization command, the following two ways are different?

(1) rsync-av/dira/ip:/dirb/

(2) RSYNC-AV/DIRA/IP: IRB:d

Answer: (1) The former is synchronized via SSH

(2) The latter is synchronized through the Rsync service

23, rsync synchronization, if the source to be synchronized with a soft connection, how to synchronize the target files or directories of the soft connection?

A: Synchronizing source files requires the plus-l option

24. When an account logs on to Linux, what log files will the system record relevant information?

A: The user authentication process is recorded in/var/log/secure, and the logged-on success information is logged in/var/log/wtmp.

25. When there is a problem with the NIC or hard drive, which command can we use to view the relevant information?

Answer: Use the command DMESG

26, respectively, using xargs and exec to achieve such a requirement, the current directory of all suffixes named. txt file permissions modified to 777

Answer: (1) find./-type f-name "*.txt" |xargs chmod 777

(2) Find/-type f-name "*.txt"-exec chmod 777 {};

27, there is a script can run more than 2 days, how to make it run uninterrupted, but also at any time to observe the script runtime output information?

Answer: Use the screen tool

28, under the Linux system how to follow the following requirements: Filter only the HTTP service, the target IP is 192.168.0.111, catch 1000 packets, and save to the 1.cap file?

Answer: TCPDUMP-NN-S0 host 192.168.0.111 and Port 80-c 1000-w 1.cap

29, rsync synchronization data, how to filter out all. txt files are out of sync?

Answer: Add--exclude option:--exclude= "*.txt"

30, rsync synchronization data, if the target file is newer than the source file, then ignore the file, how to do?

Answer: Keep updates using the-U or--update option

31, want to visit a website under the Linux command line, and the site domain name has not been resolved, how to do?

A: In the/etc/hosts file, add a resolution record from the site's domain name to its IP, or use Curl-x

32. What file can we edit when we customize the domain name? Can one IP correspond to multiple domain names? Does a domain name correspond to multiple IPs?

A: Edit/etc/hosts, can be an IP for multiple domain names, not a domain name for multiple IP

33. Which command can we use to view the historical load of the system (for example, two days ago)?

Answer: Sar-q-f/var/log/sa/sa22 #查看22号的系统负载

34, how to specify a DNS server under Linux to resolve a domain name?

Answer: Use dig command: Dig @DNSip domain.com

such as: Dig @8.8.8.8 www.baidu.com# Use Google DNS resolution Baidu

35, when using Rsync synchronization data, if we are using the SSH mode, and the target machine's sshd port is not the default 22 port, then how do we do?

Answer: rsync "--rsh=ssh-p 10022" or rsync-e "Ssh-p 10022"

36, rsync synchronization, how to delete the target data more out of the data, that the source does not exist, but the target exists in the file or directory?

A: plus the--delete option

37. When using free to view memory usage, which value represents the amount of memory actually available?

Answer: The value of the second row of the free column

38, one day you suddenly found that the company's website access speed has become very slow, how should you do?

(Server can login, prompt: You can start from the system load and network card traffic)

A: Can be analyzed from two aspects: Analyze the system load, use the W command or the uptime command to view the system load, if the load is very high, use the top command to see the Cpu,mem and other occupancy, either the CPU is busy, or the memory is not enough, if both are normal, Then use the SAR command to analyze the network card traffic, analysis is not attacked. Once you have analyzed the cause of the problem, take appropriate measures to resolve it, such as deciding whether to kill some processes, or to prohibit some access.

39, rsync when using the service mode, if we specify a password file, then the password file permissions should be set to how much?

Answer: 600 or 400

39 Common Linux system simple face questions

Related Article

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.