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

2Permine Linux basic command

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

Share

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

1Basic Linux command

Ip address show centos7 views Nic information by default

Ifconfig centos6 views Nic information by default

Nmtui centos7 default image modification of network card information

Setup centos6 default graphical modification of network card information

Systemctl restart network centos7 restarts network services

/ etc/init.d/network restart centos6 restart network service

Reboot restart the system

Halt shuts down immediately

Shutdown shutdown

Cd changes directories

Cd.. Return to the previous directory

Cd / xx/xx/xx changes directories by absolute path

Cd xx changes directories through relative paths

Pwd displays the current path location

Ls displays the file information in the directory

Ll displays the details of files in the directory and arranges them in a list

Ls-a shows hidden files

Ll-a shows hidden files

Mkdir create directory

Create a directory in mkdir-p recursive form

Touch create File

Rm deletes catalog files

Rm-rf forcefully deletes directory files

Cp copies catalog files

Cp-r copy directory files recursively (including permissions)

Mv cut directories or files

2 detailed explanation of Linux system directory

/ root directory the beginning of everything

/ bin and / usr/bin: directories for executable binaries

/ boot: place some files used when the linux system starts up

/ dev: store device files under the linux system

/ etc: the directory where the system configuration files are stored

/ root: home directory of system administrator root

Home: the default user home directory of the system

/ lib:/usr/lib:/usr/local/lib: directory of function libraries used by the system

/ lost+fount: when an error occurs in a system exception, some missing fragments will be placed in this directory

/ opt: the directory where additional software is installed for the host

/ proc: all the data in this directory is in memory

/ sbin:/usr/sbin:/usr/local/sbin: place executable commands used by system administrators

/ tmp: temporary storage directory

/ usr: application storage directory

/ var: log file

3dint vi text editing

Esc global mode

I insert mode

: last line mode

G quickly move the cursor to the last line

Gg quickly moves the cursor to the first line

Move the cursor quickly to the end of a line

0 quickly move the cursor to the beginning of a line

O create a new line below the specified line and go directly to the editing state

Yy copies the contents of the specified line

P paste the copied content

Dd delete (cut content)

U undo the previous operation

X deletes one character backward

C deletes the whole line of characters behind the cursor

: set nu number

: 1meme10s / ^ / # / g comment out lines 1-10 in batch with #

1Jing 10s / ^ # / g delete 1-10 lines in batches # comments

: s#root#oldboy#g modified, cursor location

:% s#root#oldboy#g global modification

: 9 copy 15 16 (copy lines 9-15, paste after 16 lines)

/ find

Display input command shortcut key use

The current display input command shortcut key is used

Ctrl + a cursor quickly moves to the beginning of the line Home

The ctrl + e cursor quickly moves to the end of the line End

Ctrl + l quickly clearing the screen is equivalent to turning the page.

Ctrl + s locks the current window

Ctrl + r search for used commands

Ctrl + u cut the contents before the cursor

Ctrl + k cut the contents of the cursor

Ctrl + y paste cut content

Ctrl + ← quickly move the cursor one word to the left

Ctrl + → quickly move the cursor to the right one word

Ctrl + c undo aborts the current operation

Ctrl + d exiting the current user is equivalent to logout

four,

Df-h View disk

Df-I view disk innode

/ etc/fstab boots and mounts the disk automatically

Lsblk displays the current disk partitions in a tree structure

Blkid View disk uuid

DNS parsing

/ etc/hosts ip for domain name resolution

/ etc/resolv.conf specify DNS

/ etc/hostname hostname settings file

/ etc/sysconfig/network-scripts/ifcfg-eth0 network card configuration file

/ etc/rc.local boot autorun program file

/ etc/profile variable load file

System run level file

/ usr/lib/systemd/system/runlevel*target

0 shutdown level 0.target-poweroff.target 1 single user level (security mode) reset system password 1.target-rescue.target 2 multi-user level (no network multi-user) 2.target-multi-user.target 2.target-multi-user.target 3 multi-user level (multi-user with network) 3.target-multi-user.target 4 not used 4.target-multi-user.target 5 graphical interface 5.target-graphical.target 6 restart level 6.target-reboot.target

View file command

Cat unfolds text content

Tail looks at the end of the file (- n plus a number indicates how many lines are displayed. 10 lines are displayed by default)

Tail-f / var/log/secure view and monitor files

Tail-F real-time monitoring

Head starts looking at the file (- n plus a number indicates how many lines are displayed. 10 lines are displayed by default)

Cat / proc/cpuinfo view cpu information

Processor: 0-the total number of CPU cores of the server

Cpu cores: 1-the core of each CPU of the server

Model name: Intel (R) Core (TM) i5-8400 CPU @ 2.80GHz-CPU model

Physical id: 0-number of CPU (number of paths) 1

Filter file contents command:

Grep

[root@localhost ~] # grep "processor" / proc/cpuinfo

Processor: 0

Processor: 1

[root@localhost ~] # grep "processor" / proc/cpuinfo | wc-l

two

Cat / proc/meminfo view mem information

Free view memory information

Free-h displays memory information in human-readable form

Cat / proc/mounts to check the mount of system disk

Cat / proc/loadavg to check the load of the system

1.63 0.61 0.22 1/228 2487

1.63 (average load for 1 minute) 0.61 (average load for 5 minutes) 0.22 (average load for 15 minutes) 1Compact 228 (numerator is the number of currently running processes, denominator is the total number of processes) 2487 (ID of the most recently running process)

Df-h to view disk partition mounts

W View the current login terminal

Cat / etc/redhat-release to view the current system version

Uname-r to view the current kernel version

Uname-a

Su user name changes the user. After switching, the user is still in the original user's home directory, using the original user shell.

Su-user name changes between users. Under the new user's home directory, use the new user shell.

Whoami View current user

[root@localhost ~] # echo $PS1

[\ u@\ h\ W]\ $

[root@localhost ~] # export PS1=' [\ u @\ h _\ t\ w]\ $'temporarily modify the prompt

[root@localhost_15:16:14 ~] #

[root@localhost15:16:25 ~] # echo "export PS1=' [\ u @\ h\ t\ w]\ $'" > > / etc/profile permanent modify prompt

[root@localhost_15:16:44 ~] # source / etc/profile

[root@localhost15:16:55 ~] $

How to change the color of a command prompt:

PS1=' [\ e [32th 1m] [\ u@\ h\ t\ w]\ $[\ e [0m]'

[\ e [0m]-set the end of the color and set the background color

[\ e [32th 1m] set font color

Download source optimization-optimize yum source update yum source is Aliyun-basic yum source (there are three yum sources on the Internet, Aliyun source, Tsinghua University source NetEase source) http://mirrors.aliyun.com/ official website update yum source is Aliyun-basic yum source curl-o / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo update to the current most New version 7 source check whether the update is successful / etc/yum.repos.d/ saves yum source file head-20 / etc/yum.repos.d/CentOS-Base.repo update yum source is Aliyun-extended yum source Wget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo updated successfully / there is an epel.repo file in the etc/yum.repo directory

How to confirm that the software is installed successfully:

Rpm-qa tree (software name)-query whether the software is installed successfully

Rpm-ql tree-query which dependency packages and installation paths are installed in the software

Rpm-e cowsay (software name)-nodeps (dependency packages are also uninstalled)-Uninstall the specified software

Which animalsay shows which software gift package a file or command belongs to

Yum install-y bash-completion-complete service name information software

Yum-y install xxx

Yum remove xxx

Firewall service

Systemctl stop firewalld, turn off the firewall

Systemctl start firewalld turn on the firewall

Systemctl retart firewalld restart Firewall

Systemctl status firewalld to view the current status of the firewall

SELINUX security service

Getenforce to view current selinux status

Setenforce 0ax 1 sets the current selinux status to temporarily off or on

Echo $LANG to view the current character encoding

Export LANG= "zh_CN.UTF-8" temporarily adjusts character encoding:

Cat / etc/locale.conf permanently adjusts character encoding:

LANG= "en_US.UTF-8"

Alias feature settings:

Temporary settin

Alias neteth0='cat / etc/sysconfig/network-scripts/ifcfg-eth0'

Permanent settin

Echo "alias neteth0='cat / etc/sysconfig/network-scripts/ifcfg-eth0'" > > / etc/profile

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