linux common commands and instructions (centOS7)

uname -a View all kernel information system

View uname -r kernel

cat / etc / redhat-release version View System

cat / proc / meminfo memory information view

free -m view is M units

free -g view of the unit of information is the G

mkdir Create a directory Example: mkdir java

Create a file touch cases: touch go

rm -rf / delete a route path

rm -ri / path delete a path (whether) Note: there will be prompted before deleting

cd to a directory  

vi / vim to edit files

ps -ef | grep name need to view a process

top all processes similar to windows task manager

ss -tanl View all listening ports

lsof -i: port number to see whether or not a port monitor

curl ip: port if the port can pass ping Example: curl 120.119.110.315:8001

nc -w 1 ip port </ dev / null && echo "tcp port ok" if you can see through

     例:nc -w 1  132.121.213.41 8611 < /dev/null && echo "tcp port ok"

 

echo "UID of this script: $ UID" get user id 

id | awk '{print substr ($ 1,5,4)}' taken (acquisition system user and group id) 

     Detailed parameters: $ 1 represents the first group of words that is user id $ 2

                        The first indicates the start of a $ 5 cut from a few, the second 4 bits represent the number of cut

id |awk '{split($2,a,"=");print a[2]}'|awk '{split($1,b,"(");print b[1]}'

Parameters: The first is to take $ 2 represents the group id, user id becomes take $ 1

 

usermod -u id number of the user name set user id number Example: usermod -u 1001 tele

groupmod -g id number to set the user name of the user group id Example: groupmod -g 1001 tele 

 

View thread handles:

ulimit -a

more /proc/sys/fs/file-max

lsof|awk '{print $2}'|wc -l

Linux single largest file modification process connections:

vi /etc/security/limits.conf add

* Soft nofile 65536

* Hard nofile 65536

Log in again, ulimit -a execution

 

lsof | wc -l to see all processes of the number of open files

lsof -p pid | wc -l to see the number of files a process opens

 

echo 3> / proc / sys /  vm / drop_caches clean up all caches

 

systemctl stop firewalld.service 停止firewall

systemctl disable firewalld.service prohibit firewall boot

 

ifconfig to view ip address

 View all ifconfig -a native ip address

ip addr view the virtual machine IP address

curl ifconfig.me query Internet public network ip

ip link set-- change the properties of the device, abbreviation: set, s

ip link show- Display Specifications abbreviation: show, list, lst, sh, ls, ls option appears two or more times, ip will output more detailed error information statistics

ip address add-- add a new protocol address

ip address delete-- delete a protocol address;

ip address show-- display protocol address;

ip address flush-- clear protocol address;

 ip neighbour add-- add a new neighbor entry, ip neighbour change-- modify an existing entry, ip neighbour replace-- replace an existing entry, abbreviation: add, a; change, chg; replace, repl;

ip neighbour delete-- delete a neighbor entry;

ip route add-- Add a new route. ip route change-- modify the route. ip route replace-- replace the existing route;

ip route delete-- delete routes, abbreviation: delete, del, d;

ip route show-- routing lists, abbreviation: show, list, sh, ls, l.

 

Set synchrony timedatectl set-timezone Asia / Shanghai

cp / usr / share / zoneinfo / Asia / Shanghai / etc / localtime set consistent results synchrony supra

ln -sf / usr / share / zoneinfo / Asia / Shanghai / etc / localtime && echo 'Asia / Shanghai'> / etc / timezone time zone setting NOTE: docker vessel with consistent physical area required to machine

hostnamectl set-hostname hostname set the hostname 

 

Set user password never expires

vi / etc / shadow

Find a user needs to modify the last third of the 90 was changed to 99999

sudo usermod -aG docker gdeop

echo -e 'old password \ n new password \ n New Password' | passwd

 

chmod -R 777 path that is granted permissions for all users 777linux system with root privileges highest

 chown -R telecom path telecom users grant

 chgrp -R telecom telecom path grant User Group

 chmod u + s nginx by permission

 

Creating user groups groupadd gdeop gdeop

useradd -d path -m user name and user name to create a path    

useradd -d path -m gdeop -g group of users to create a path to the user name and join user groups 

 

chown -R gdeop:gdeop /data1/gdeop 

useradd gdeop

usermod -a -G gdeop gdeop

passwd username password example: passwd gdeop

 

Setting a user with root privileges sudo   

vi /etc/sudoers 

gdeop  ALL=(ALL)       NOPASSWD: ALL

 

uname -a # View kernel / linux system operating system / CPU information information command

head -n 1 / etc / issue # check the OS version, not the letter L is the number 1

cat / proc / cpuinfo # View system information linux command CPU information

hostname # View the computer name of the linux command information system

lspci -tv # list all PCI devices

lsusb -tv # lists all USB devices linux command information system

lsmod # listed loadable kernel modules

env # viewing environment variable resources

free -m # View the amount of memory usage and swap

df -h # see how each partition usage

Du -sh * View the size of directories and files

grep MemTotal / proc / meminfo # view the amount of memory

grep MemFree / proc / meminfo # view the amount of free memory

uptime # View system uptime, number of users, load

cat / proc / loadavg # View system load disk and partition

mount | column -t # View articulated partition status

See all partitions fdisk -l #

swapon -s # View all swap partitions

hdparm -i / dev / hda # View disk parameters (only for IDE devices)

dmesg | grep IDE # view when you start the IDE device detects network conditions

ifconfig # view properties for all network interfaces

iptables -L # View firewall settings

route -n # View the routing table

netstat -lntp # View all listening ports

netstat -antp # view all established connections

netstat -s # View network statistics process

ps -ef # view all processes

top # display real-time status of the user process

w # View active users

View information about a specified user id #

View user login log last #

cut -d: -f1 / etc / passwd # View all system users

cut -d: -f1 / etc / group # View all system groups

crontab -l # to view the current user's scheduled tasks service

chkconfig -list # lists all system services

chkconfig -list | grep on # lists all system services program starts

rpm -qa # View all the packages installed

cat / proc / cpuinfo: View CPU-related parameters linux system commands

cat / proc / partitions: View System Information command linux hard disk and partition information

cat / proc / meminfo: memory information see linux system linux system command

cat / proc / version: Check version, similar to the uname -r

cat / proc / ioports: View io port equipment

cat / proc / interrupts: View interrupt

cat / proc / pci: View information pci device

cat / proc / swaps: View information for all swap partitions

 

cat / proc / meminfo | grep MemTotal view memory size

fdisk -l | grep Disk Check the hard disk size

cat / proc / cpuinfo | grep "model name" && cat / proc / cpuinfo | grep "physical id" view system information clocked

find -type d -empty search for empty folders

 

docker docker info View details  

systemctl daemon-reload reload

systemctl start docker  开启容器
systemctl stop docker  停止容器
sytemctl enable docker  设置开机启动
systemctl status docker  查看docker运行状态
systemctl restart docker  重启docker

docker  the Inspect  CONTAINER_NAME |  grep  Mounts -A  20   View docker container working directory path

docker info | grep "Docker Root Dir" View docker working directory (mirrored storage container path)

docker diff to see what subfolders affected

docker system prune Remove close container volumes and useless data network, without tag mirror.

docker system prune -a command to clean more thoroughly, the vessel will not use the Docker image are deleted. Note: These two commands will take you temporarily closed containers, as well as temporarily unused Docker image are deleted

Disk Usage docker system df for viewing Docker similar df command on Linux

du -hs / var / lib / docker / command to view disk usage

docker rmi -f `docker images | grep '<none>' | awk '{print $ 3}'` delete a name or label for the mirror none

docker rm `docker ps -a | grep Exited | awk '{print $ 1}'` deleted abnormally stopped container docker

docker images -q --filter "dangling = true" | xargs -t --no-run-if-empty docker rmi remove all mirrors useless

docker exec -it container id / bin / bash into the container  

ctrl + p + q exit vessel

docker rm $ (docker ps -aq) remove all containers

docker stop $ (docker ps -a -q) Stop all containers

docker run container tail -f / dev / null to keep the vessel running in the foreground

docker ps view of the container has been running

docker ps -a to view all containers (stop running)

docker inspect the vessel name | grep Address see one container ip

docker inspect --format = '{{Name}.} - {{range .NetworkSettings.Networks}} {. {IPAddress}} {{end}}' $ (docker ps -aq) show all IP addresses containers

 

ocker container Log Viewer command:

 docker logs --tail -f [容器id]

 docker logs -f -t --tail rows vessel name

 docker logs -f -t --since = "Date" --tail = number of rows of the container name (id)

 docker exec -it [vessel id] sh

 

 Creating the groupadd docker docker group
gpasswd -a $ {USER} docker docker users join group

usermod -aG docker telecom telecom users to user groups added to the docker 

 

cat / var / log / log name to view the log

systemctl restart rsyslog restart rsyslog service

man 3 syslog log level view

rpm -q rsyslog logging software

rpm rsyslog log file list -ql

rpm -qc rsyslog View profile

 

cd / into the root directory 

find -name filename example:.. find -name api_center.log

 

The local directory copied to the remote:

scp -r directory name username @ computer IP or computer name: display details # remote path, add -v parameter

From the remote copy back to the local directory:

scp -r username @ computer IP or computer name: the name of the local directory path 

 

Unzip command:

tar xvf FileName.tar decompression

tar cvf FileName.tar DirName package

 

gunzip FileName.gz decompression

gzip -d FileName.gz decompression

gzip FileName compression

 

extracting tar zxvf FileName.tar.gz

tar zcvf FileName.tar.gz DirName   压缩

 

bzip2 -d FileName.bz2 decompression

bunzip2 FileName.bz2 decompression

bzip2 -z FileName compression

 

extracting tar jxvf FileName.tar.bz2

compressed tar jcvf FileName.tar.bz2 DirName

 

bzip2 -d FileName.bz decompression

bunzip2 FileName.bz decompression

 bzip2 -z FileName compression

 

extracting tar jxvf FileName.tar.bz

compressed tar jcvf FileName.tar.bz2 DirName

 

 

uncompress FileName.Z decompression

compression compress FileName

 

extracting tar Zxvf FileName.tar.Z

compressed tar Zcvf FileName.tar.Z DirName

 

extracting tar zxvf FileName.tgz

tar -zcvf examples.tgz examples (examples of the implementation of the current directory path) compression

 

extracting tar zxvf FileName.tar.tgz

FileName.tar.tgz FileName compression

 

unzip unzip FileName.zip

zip FileName.zip DirName compression

 

rar a FileName.rar decompression

rar e FileName.rar compression

 

View locale coding system 

/ Etc / sysconfig / i18n, such as coding into Chinese:

code show as below:

LANG = en_US.UTF-8

Changed

. code show as below:

LANG="zh_CN.GBK"

After the restart it

 

export LANG = zh_CN.GBK encoding format set

View Task jobs

 

nohup and> / dev / null 2> & 1 uses: nohup represents permanent operation. & Means running in the background

    In applying Unix / Linux, we generally want a program running in the background, nohup ./start-mysql.sh &

 

 

 

 

 

 

 

 

  

 

Guess you like

Origin blog.csdn.net/fenlin88l/article/details/89489192