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 are the common commands in Linux?

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

Share

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

This article shows you what Linux commands are commonly used, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Command + parameter + executor

one。 Common system working commands

Wget downloads files from the specified URL

Example:

Wget http://www.linuxde.net/testfile.zip # download a single file

Wget-O wordpress.zip http://www.linuxde.net/download.aspx?id=1080 # download and save under a different file name

Ps to view the process status of the current system

Pstree to view inter-process relationships

Grep search

| | Pipeline commands are executed at the same time on the left and right sides. |

Example:

Ps-ef | grep java # find the java process

Kill kills unnecessary processes

Example:

Kill-9 3268 # forcibly delete the PID to 3268 process

Killall kills the process with the specified process name

Example:

Killall vi # process that kills all vi names

Top can dynamically view the overall operation of the system in real time.

Pidof looks up the process number of the process with the specified name, id

Example:

Pidof nginx

Man view the parameters of the command

Example:

Man kill (ctrl+z exit)

User

Useradd xxx add users, synchronously add a group

Groupadd xx

Su xx switches to user

Permission: u g o

Chmod Ubunw name.sh users increase write permissions

Increased execution permissions for chmod Groupx name.sh user group

Chmod Omurr name.sh other delete read permissions

Chmod 000 name.sh

Chgrp wl name.sh changes user group permissions to wl

two。 System status monitoring command

Ifconfig displays network device information

Example:

Ifconfig eth0 up/down # starts / shuts down the specified network card

Ifconfig eth0 add/del 33ffe:3240:800:1005::2/64 # configure and delete IPv6 addresses for network cards

Ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE # modify MAC address with ifconfig

Ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255 # configure IP address

Ifconfig eth0 arp/-arp # enables and closes the arp protocol

View system information

Example:

Uname-a # View operating system kernel information (kernel version number, hardware architecture, hostname, operating system type, etc.)

Cat / etc/issue # View Linux system release

Cat / proc/cpuinfo # View CPU related information

Uptime to view system uptime

Free displays the amount of memory unused and used by the current system

Who View system logged in user

Last displays the user's most recent login information

History display History command

Sosreport is a tool similar to supportconfig

Yum-y install sos # sosreport installation

Sosreport-help/man sosreport # get the help manual

three。 Working directory switch command

Pwd displays the directory where it is currently located

Cd to switch directories

Example:

Cd / root # enter the root directory

Cd.. # switch to the previous directory

Ls displays a list of targets

Example:

Ls-a # lists all files in the current directory (including hidden files)

four。 File directory management command

Create a new directory under the current directory of mkdir

Create a file or directory under the current directory of touch

Cp copies the source file to the specified file or directory

Example:

Cp file_name1 file_name2 # copy the file_name1 file from the current directory to the file_name2 file

The file_name1 file in the current directory of cp file_name1 / usr/file_name2 # is copied to the / usr directory and renamed to / file_name2

Mv moves files or renames files or directories

Example:

Mv file_name1 file_name2 # rename the file file_name1 to file_name2

Mv file_name1 / usr # move the file file_name1 to the usr directory

Rm deletes a file or directory

File View File Typ

Example:

File install.log

five。 Text file editing command

Cat connection merge File

Example:

Cat file_name1 # displays the contents of the file file_name1

Cat file_name1 file_name2 > file_name3 # merge the files file_name1 and file_name2 into the file file_name3

Vi text editing

Vi file name

Enter I to enter insert insert mode

ESC, exit insert mode, review mode Shift+: enters command line editing mode: wq save and exit: Q exit: Q! Force do not save exit dd delete selected row

More displays text content by page in full screen mode

Stat displays status information of files

six。 Package Compression and search Command

Tar creates files for files and directories

Example:

Tar-cvf log.tar log2012.log # is packaged only, not compressed

After tar-zcvf log.tar.gz log2012.log # is packaged, it is compressed in gzip

After tar-jcvf log.tar.bz2 log2012.log # is packaged, it is compressed in bzip2

Tar-ztvf log.tar.gz # View the files in the tar package

Tar-zxvf / usr/log.tar.gz # decompress the tar package

Simple way: tar-jcv-f log.tar.gz # Compression tar-jtv-f log.tat.gz # query tar-jxv-f log.tar.gz # decompress

Grep text search

Example:

Grep match_pattern file_name # search for text containing "match_pattern"

Find files under the directory specified by find

Example:

Find / home-name ".txt" # home directory looks for filenames ending in .txt, but ignores case

Find / home! -name ".txt" # home directory to find filenames that do not end in .txt, but ignore case

seven。 Other

Yum source

Cd / etc/yum.repos.d # source storage path

Wget-0 / etc/yum.repos.d/CentOS-Base http://mirrors.aliyun.com/repo/Centos-7.repo

Yum clean all

Yum makecache # clear and regenerate the yum cache

Yum list

Yum install packagename # installation package

Yum erase/remove packagename # Uninstall the package

Restart the service

Cd / home/chnsys/cms/config

. / cms.server restart

IP configuration

Vim / etc/sysconfig/network-scripts/ifcfg-eth0 # modify default configuration (delete ipv6 information)

Decive= "eth0"

Bootproto= "static" # ip address assignment method

Onboot= "yes" # whether to activate this device when the system starts

Type=ethernet

IPAddR=192.168.1.143 # IP address

Netmask=255.255.254.0 # Subnet Mask

GateWay=192.168.1.1 # Gateway

Hwaddr= "00:0C:29:5D:5F:2A"

Vim / etc/resolv.conf # set up DNS nameserver 8.8.8.8 service network restart # restart network service ip addr # View ip

Firewalls

Service statuc firewalld.service # View firewall status (CentOS7:systemctl replaces service)

Service stop firewalld # turn off the firewall

Service start firewalld # start the firewall

Service disable firewalld.service # turn off the firewall and start up automatically

What are the common commands in Linux? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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