Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What commands do you need to know to manage a Linux system?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you what commands you need to know about managing your Linux system. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. Command: ifconfig

Ifconfig is used to configure the network interface information that resides in the kernel. The information used to set the network adapter if necessary when the system starts. After that, it usually needs to be used only when debugging or when the system needs to be adjusted.

Check the active network adapter

[avishek@tecmint ~] $ifconfig eth0 Link encap:Ethernet HWaddr 40:2C:F4:EA:CF:0E inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:163843 errors:0 dropped:0 overruns:0 frame:0 TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen: 1000 RX bytes:154389832 (147.2 MiB) TX bytes:65085817 (62.0 MiB) Interrupt:20 Memory:f7100000-f7120000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: 1thumb 128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:78 errors:0 dropped:0 overruns:0 frame:0 TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes: 4186 (4.0 KiB) TX bytes:4186 (4.0 KiB)

Check all network adapters

The "- a" parameter is used to display the details of all network adapters (network cards), including those that are deactivated.

[avishek@tecmint ~] $ifconfig-an eth0 Link encap:Ethernet HWaddr 40:2C:F4:EA:CF:0E inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:163843 errors:0 dropped:0 overruns:0 frame:0 TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 Txqueuelen:1000 RX bytes:154389832 (147.2 MiB) TX bytes:65085817 (62.0MiB) Interrupt:20 Memory:f7100000-f7120000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: 1Point128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:78 errors:0 dropped:0 overruns:0 frame:0 TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX Bytes:4186 (4.0KiB) TX bytes:4186 (4.0KiB) virbr0 Link encap:Ethernet HWaddr 0e:30:a3:3a:bf:03 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0. 0 B) TX bytes:0 (0.0B)

Deactivate the network adapter

[avishek@tecmint ~] $ifconfig eth0 down

Enable network adapter

[avishek@tecmint ~] $ifconfig eth0 up

Specify the IP address to the network adapter

Set the IP address "192.168.1.12" for the network adapter eth0.

[avishek@tecmint ~] $ifconfig eth0 192.168.1.12

Change the subnet mask of the network adapter eth0:

[avishek@tecmint ~] $ifconfig eth0 netmask 255.255.255.

Change the broadcast address of the network adapter eth0:

[avishek@tecmint ~] $ifconfig eth0 broadcast 192.168.1.255

Specify the IP address, subnet mask, broadcast address for the network adapter eth0:

[avishek@tecmint ~] $ifconfig eth0 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255

Note Note: if you set up a wireless network card information, you can use the command is "iwconfig". For more examples and how to use ifconfig commands, read "15 useful ifconfig commands".

two。 Command: netstat

The netstat command displays a variety of network-related information, such as network connections, routing tables, interface statistics, camouflage connections, multicast membership, etc.

List all network ports

[avishek@tecmint ~] $netstat-an Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ACC] STREAM LISTENING 741379 / run/user/user1/keyring-I5cn1c/gpg unix 2 [ACC] STREAM LISTENING 8965 / var/run/acpid.socket unix 2 [ACC] STREAM LISTENING 18584 / tmp/.X11 -unix/X0 unix 2 [ACC] STREAM LISTENING 741385 / run/user/user1/keyring-I5cn1c/ssh unix 2 [ACC] STREAM LISTENING 741387 / run/user/user1/keyring-I5cn1c/pkcs11 unix 2 [ACC] STREAM LISTENING 20242 @ / tmp/dbus-ghtTjuPN46 unix 2 [ACC] STREAM LISTENING 13332 / var/run/samba/winbindd_privileged/ Pipe unix 2 [ACC] STREAM LISTENING 13331 / tmp/.winbindd/pipe unix 2 [ACC] STREAM LISTENING 11030 / var/run/mysqld/mysqld.sock unix 2 [ACC] STREAM LISTENING 19308 / tmp/ssh-qnZadSgJAbqd/agent.3221 unix 2 [ACC] STREAM LISTENING 436781 / tmp/HotShots unix 2 [ACC] STREAM LISTENING 46110 / run/user/ravisaive/pulse/native unix 2 [ACC] STREAM LISTENING 19310 / tmp/gpg-zfE9YT/S.gpg-agent....

Show all tcp related ports

[avishek@tecmint ~] $netstat-at Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:mysql *: * LISTEN tcp 0 0 *: 5901 *: * LISTEN tcp 0 0 *: 5902 *: * LISTEN tcp 0 0 *: X11-1 *: * LISTEN tcp 0 0 *: X11-2 *: * LISTEN tcp 0 0 *: 5938 *: * LISTEN Tcp 0 0 localhost:5940 *: * LISTEN tcp 0 0 ravisaive-OptiPl:domain *: * LISTEN tcp 0 0 ravisaive-OptiPl:domain *: * LISTEN tcp 0 0 localhost:ipp *: * LISTEN tcp 0 0 ravisaive-OptiPle:48270 ec2-23-21-236-70.c:http ESTABLISHED tcp 00 ravisaive-OptiPle:48272 ec2-23-21-236-70.c:http TIME_WAIT tcp 00 ravisaive-OptiPle:48421 bom03s01-in-f22.1:https ESTABLISHED tcp 00 ravisaive-OptiPle:48269 ec2-23-21-236-70.c:http ESTABLISHED tcp 00 ravisaive-OptiPle:39084 channel-ecmp-06-f:https ESTABLISHED.

Display statistics for all connections

[avishek@tecmint] $netstat-s Ip: 4994239 total packets received 0 forwarded 0 incoming packets discarded 4165741 incoming packets delivered 3248924 requests sent out 8 outgoing packets dropped Icmp: 29460 ICMP messages received 566 input ICMP message failed. ICMP input histogram: destination unreachable: 98 redirects: 29362 2918 ICMP messages sent 0 ICMP messages failed ICMP output histogram: destination unreachable: 2918 IcmpMsg: InType3: 98 InType5: 29362 OutType3: 2918 Tcp: 94533 active connections openings 23 passive connection openings 5870 failed connection attempts 7194 connection resets received....

Yes! For some reason, if you don't want to parse the host, port, and user name of the netstat output.

[avishek@tecmint ~] $netstat-an

Well, you may need to get the dynamic information of the continuous output of netstat and stop it by passing the interrupt output instruction (ctrl + c).

[avishek@tecmint] $netstat-c

For more examples and usage of "netstat", browse the article "20 use cases of netstat".

3. Command: nslookup

A network utility that is used to obtain information about an Internet server. As the name implies, the utility will find the name server information by querying the DNS domain.

[avishek@tecmint ~] $nslookup tecmint.com Server: 192.168.1.1 Address: 192.168.1.1 tecmint.com Address 53 Non-authoritative answer: Name: tecmint.com Address: 50.16.67.239

Query mail exchanger records

[avishek@tecmint] $nslookup-query=mx tecmint.com Server: 192.168.1.1 Address: 192.168.1.1 Non-authoritative answer: tecmint.com mail exchanger = 0 smtp.secureserver.net. Tecmint.com mail exchanger = 10 mailstore1.secureserver.net. Authoritative answers can be found from:

Query domain name server

[avishek@tecmint] $nslookup-type=ns tecmint.com Server: 192.168.1.1 Address: 192.168.1.1 Non-authoritative answer: tecmint.com nameserver = ns3404.com. Tecmint.com nameserver = ns3403.com. Authoritative answers can be found from:

Query DNS record

[avishek@tecmint] $nslookup-type=any tecmint.com Server: 192.168.1.1 Address: 192.168.1.1 Non-authoritative answer: tecmint.com mail exchanger = 10 mailstore1.secureserver.net. Tecmint.com mail exchanger = 0 smtp.secureserver.net. Tecmint.com nameserver = ns06.domaincontrol.com. Tecmint.com nameserver = ns3404.com. Tecmint.com nameserver = ns3403.com. Tecmint.com nameserver = ns05.domaincontrol.com. Authoritative answers can be found from:

Query the initial authorization authority

[avishek@tecmint] $nslookup-type=soa tecmint.com Server: 192.168.1.1 Address: 192.168.1.153 Non-authoritative answer: tecmint.com origin = ns3403.hostgator.com mail addr = dnsadmin.gator1702.hostgator.com serial = 2012081102 refresh = 86400 retry = 7200 expire = 3600000 minimum = 86400 Authoritative answers can be found from:

Query port number

Change the port number you want to connect to:

[avishek@tecmint] $nslookup-port 56 tecmint.com Server: tecmint.com Address: 50.16.76.23953 Name: 56 Address: 14.13.253.12

Read more about 8 Nslookup commands.

4. Command: dig

Dig is a tool for querying the DNS domain name server, which can query the host address, mail exchange, and domain name server related information. You can use this tool on any Linux (Unix) or Macintosh OS X operating system. The most typical use of dig is a single host query.

[avishek@tecmint] $dig tecmint.com; DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 tecmint.com;; global options: + cmd;; Got answer:;;-> HEADER > HEADER / home/server/Desktop/backupfile.sql

Note: mysqldump requires that mysql is running and has the correct authorization password. We discussed some useful uses of the "mysqldump" command in backing up the database with the mysqldump command.

18. Mkpasswd command

Generates a random password that is difficult to guess according to the specified length.

[avishek@tecmint ~] $mkpasswd-l 10 zI4+Ybqfx9 [avishek@tecmint ~] $mkpasswd-l 20 w0Pr7aqKk&hmbmqdrlmk

Note:-l 10 produces a 10-character random password, while-l 20 produces a 20-character password, which can be set to any length to achieve the desired results. This command is useful and is often used in scripting languages to generate random passwords. You may need the yum or apt 'expect' package to use this command.

[avishek@tecmint ~] $yum install expect or [avishek@tecmint ~] $apt-get install expect

19. Command: paste

Merge two or more text files and merge them by line. Example. If the content of file1 is:

1 2 3 file2 is like this: a b c d [avishek@tecmint ~] $paste file1 file2 > file3

The result file3 will be: 1 a 2 b 3 c d

20.Command: lsof

Lsof is an acronym for "list open files" and shows all the files currently open on your system. This is very useful for finding out which processes use a particular file, or for displaying all files open for a single process. Some useful examples of 10 lsof commands that you may be interested in reading.

[avishek@tecmint] $lsof COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME init 1 root cwd DIR 8 root txt 1 4096 2 / init 1 root rtd DIR 8 root txt 1 4096 2 / init REG 8,1 227432 395571 / sbin/init init 1 root mem REG 8,1 47080 263023 / lib/i386-linux-gnu/libnss_files-2.17.so init 1 root mem REG 8,1 42672 270178 / lib/i386-linux-gnu/libnss_nis-2.17.so init 1 Root mem REG 8,1 87940 270187 / lib/i386-linux-gnu/libnsl-2.17.so init 1 root mem REG 8,1 30560 263021 / lib/i386-linux-gnu/libnss_compat-2.17.so init 1 root mem REG 8,1 124637 270176 / lib/i386-linux-gnu/libpthread -2.17.so init 1 root mem REG 8 lib/i386-linux-gnu/libc-2.17.so init 1 1770984 266166 / lib/i386-linux-gnu/libc-2.17.so init 1 root mem REG 8 30696 262824 / lib/i386-linux-gnu/librt-2.17.so init 1 root mem REG 8 34392 262867 / lib/i386-linux-gnu/libjson.so.0.1.0 init 1 root mem REG 8,1 296792 262889 / lib/i386-linux-gnu/libdbus-1.so.3.7.2 init 1 root mem REG 8,1 34168 262840 / lib/i386-linux-gnu/libnih-dbus.so.1.0.0 Init 1 root mem REG 8,1 95616 262848 / lib/i386-linux-gnu/libnih.so.1.0.0 init 1 root mem REG 8,1 134376 270186 / lib/i386-linux-gnu/ld-2.17.so init 1 root 0u CHR 1,3 0t0 1035 / dev/null init 1 root 1u CHR 1,3 0t0 1035 / dev/null init 1 root 2u CHR 1,3 0t0 1035 / dev/null init 1 root 3r FIFO 0,8 0t0 1714 pipe init 1 Root 4w FIFO 0 8 0t0 1714 pipe init 1 root 5r 0000 0 0 6245 anon_inode init 1 root 6r 0000 0 0 0 anon_inode init 1 root 7u unix 0xf5e91f80 0t0 8192 @ / com/ubuntu/upstart init 1 root 8w REG 8J 1 3916 394 / var/log/upstart/teamviewerd.log.1 (deleted) Thank you for reading! This is the end of this article on "what commands do you need to know about managing the Linux system?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report