Operations and Maintenance Basic Command

1. View the current operating system version

[root@root ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)

2. View the number of bits in the operating system (kernel)

[root@root ~]# uname -r
2.6.32-431.el6.x86_64

3. View the running level of the current system

[root@root ~]# runlevel
N 3

4. Setting Linux boot level

5. Temporary modification of host name

6. Permanently modify the host name

6.1 Centos6-x Permanently modifies the host name (Note: Must shut down and restart)

6.2 Centos7-x Permanently Modify Host Name

Method 1 of 6.2.1 (Note: Must shut down and restart)

[root@root ~]# vim /etc/hostname
[root@root ~]# cat /etc/hostname
ywb
[root@root ~]# reboot
[root@ywb ~]#

6.2.2 Method 2 (no restart)

[root@root ~]# hostnamectl set-hostname ywb
[root@root ~]# bash
[root@ywb ~]#

7. Show local IP fastest

[root@yangqwnbo ~]# hostname -I
192.168.200.54 

8. Check the local account ciphertext

9. Except for the permission to display a file as quickly as possible (LL)

9.1 Digital Edition

[root@root /]# stat -c %a yangwenbo
644

9.2 English Version

[root@root /]# stat -c %A yangwenbo
-rw-r--r--

10. Value of variables (refer to one-variable first-order equation)

[root@root /]# yunwei=yangwenbo
[root@root /]# echo $yunwei
yangwenbo

11. View mounted disk space

[root@root /]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root   18G  1.1G   16G   7% /
tmpfs                        491M     0  491M   0% /dev/shm
/dev/sda1                    485M   33M  427M   8% /boot

12. View the current system

12.1 Check to see who has logged in

[root@root /]# who
root     tty1         2018-07-27 05:42
root     pts/0        2018-07-27 05:43 (192.168.200.1)

12.2 See who is currently logged in to the system

[root@root /]# whoami
root

13. View the AWK version

[root@yangwenbo /]# awk --version
GNU Awk 3.1.7
Copyright (C) 1989, 1991-2009 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

14. How to ping Baidu under NET mode

[root@yangwenbo etc]# echo "`hostname -I` www.baidu.com" >> /etc/hosts 
[root@yangwenbo etc]# ping www.baidu.com
PING www.baidu.com (192.168.200.54) 56(84) bytes of data.
64 bytes from www.baidu.com (192.168.200.54): icmp_seq=1 ttl=64 time=0.024 ms
64 bytes from www.baidu.com (192.168.200.54): icmp_seq=2 ttl=64 time=0.051 ms
64 bytes from www.baidu.com (192.168.200.54): icmp_seq=3 ttl=64 time=0.072 ms
^C
--- www.baidu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2326ms
rtt min/avg/max/mdev = 0.024/0.049/0.072/0.019 ms
[root@yangwenbo etc]# cat /etc/hosts | tail -1
`192.168.200.54`  www.baidu.com

15. Parsing/etc/resolv.conf

DNS client profile, used to set the IP address and DNS domain name of DNS server, also includes the search order of domain name of host. This file is a configuration file used by the domain name resolver (a library that resolves IP addresses based on host names).

[root@yangwenbo etc]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.200.1

NET Settings List in Virtual Machine

16.pstree process tree

17.aux specializes in looking at cpu and memory

18.find

18.1 Find this path and file (directory) size is greater than 10M

18.2 Find files (directories) within 7 days of this path + 7 (outside 7 days)

19. Two ways to move files (directories):

19.1

19.2

20. Use of head and tail

Use of 20.1 wc-l

20.2 View the first five lines of the file

20.3 Look at the last five lines of the file

20.4 View the first five lines of the file and the last five lines of the file, respectively

20.5 Look at lines 6 to 10 of the document

21.rpm Installer

21.1rpm-q Finds out exactly whether an installation package is installed

22.2rpm-qi View Installation Package Details

22.3rpm-qa View all installed package tables

22.4rpm-ivh Installation Package Name: Install an Installation Package

22.5rpm-e installation package name forcibly uninstalls an installation package

23.gzip compressed file

23.1 Compressed Files

23.2 Decompression

23.3 View File Size

24.tar file packaging

24.1 Packing Files

24.2 Unpack

24.3 File compression [j(z): compressed format]

25.chkconfig

26. There are two special files in Linux: black hole files and infinite streams

  • / dev/null: Black hole files, no matter what file content is redirected to this file, the content disappears.
  • / dev/zero: Infinite data stream file, no matter how big the data you get, but the data you get does not show anything, it is purely size.

Give an example:

Use of CD commands

27.1 CD mounting

27.2 Disc Unloading (or Direct Unloading of Disc Source)

28.3 Set up boot-up automatic mounting CD-ROM:

28.ps and kill

28.1 pstree process tree

28.2ps aux specializes in viewing cpu and memory

28.3kill

  • kill according to pid
  • pkill killall kills according to service name

29. Account and Group Creation

  • Two important ways to protect account information: / etc/passwd and / etc/shadow
  • Two important paths to protect group account information: / etc/group and / etc/gshadow

29.1 Create Users

29.2 Create passwords for users

29.2.1 Sets the login password for the newly created user (two password confirmations are required)

29.2.2 Create passwords for logged-in users at one time

29.3 Delete Users

29.4 Create Program User (Can't Log in)

29.5 Makes the account in use not logged in

29.5.1 VIM username

29.5.2 Change/bin/bash to/sbin/nologin

29.5.3 source/etc/passwd (immediate effect)

29.6 Designated Account Failure Time

29.7 Create and Delete Groups

30. File permissions

  • In Linux, the maximum directory permission is 777, and the maximum file permission is 666.
  • When the umash value is 0022,
  • The default maximum permission for directories is (777-022=) 755
  • The default maximum permission for files is (666-022=) 644

30.1 How to quickly view the permissions of a file or directory

30.2chmod Permissions to Modify Directories or Files

30.2.1 Digital Mode

30.2.2 Letter Mode

30.3 Chown Modified Subordinate Master or Subgroup

31. Lock files and use lsattr commands

31.1i lock

31.1.1 plus i lock

31.1.2 Unlock i

31.2a Lock

31.2.1 plus a lock

31.2.2 Unlock a

31.2.3a Lock Principle

32. Historical Order

32.1 Query History Command

32.2 Clearance of historical orders

32.3 Maximum number of reserved items for modifying historical orders

33.su and sudo

Use of 33.1su command

Use of 33.2 sudo command

33.3 sudo secret-free login

Use the visudo command to enter the edit

34. Soft and hard links of inode number

34.1 How to view inode number and Block

Soft Link of 34.2inode Number

34.3inode Hard Link

Tags: PHP Linux DNS sudo vim

Posted on Tue, 02 Jul 2019 14:45:30 -0700 by Cbrams