Common Commands for 2021-09-11 linux Learning-Basic Operations

Shortcut keys

Tab key: press Complete once, press Candidate twice

Ctrl+c key combination: terminate the current command process

Ctrl+d key combination: end of input

Ctrl+l key combination: clear screen


Command Name [Command Parameters] [Command Object]

Command Parameter Short Format -h

Command Parameter Short Format--help

Common keys and their functions in man commands

Key	    Effect
 Spacebar	    Page down
PaGe down	Page down
PaGe up 	Page up
home	    Go directly to the first page
end	        Go directly to the end page
/	        Search for a keyword from top to bottom, such as "/linux"
?	        Search for a keyword from bottom to search, such as "?linux"
n	        Navigate to the next keyword found
N	        Navigate to the last keyword found
q	        Exit Help Document

Structure and meaning of help information in man command

Structure Name	    Representational Meaning
NAME	    Name of the command
SYNOPSIS	Approximate use of parameters
DESCRIPTION	Introduction Description
EXAMPLES	Demo (with brief instructions)
DEFAULTS	Default functionality
OPTIONS	    Specific available options (with description)
ENVIRONMENT	environment variable
FILES	    Files used
SEE ALSO	Related information
HISTORY	    Maintain History and Contact

echo command

Used to output strings or extract variable values in the syntax echo [string] [$variable]

date command

Displays or sets the time and date in the syntax date'[+specified format]'
Parameter-s Settings

Parameters in the date command and their functions

Symbol    Effect
%S	    Seconds (00)~59)
%M	    Minutes (00)~59)
%H	    Hours (00)~23)
%I	    Hours (00)~12)
%m	    Month (1)~12)
%p	    Show AM or PM
%a    	Abbreviated workday name (for example: Sun)
%A    	Full workday name (for example: Sunday)
%b	    Abbreviated month name (for example: Jan)
%B	    Full month name (for example: January)
%q	    Quarter (1)~4)
%y	    Short year (e.g. 20)
%Y	    Full year (e.g. 2020)
%d	    The day of the month
%j	    The day of the year
%n	    Line break (equivalent to pressing Enter)
%t	    Skip grid (equivalent to pressing) Tab Key)

timedatectl command

Set the system time and time zone, which is called "time date control" in English. The syntax is timedatectl [parameter]

Parameters and role in timedatectl command

parameter	          Effect
status            show status information
list-timezones    List known time zones
set-time          Set system time
set-timezone      Set effective time zone


timedatectl set-time 2021-05-18
timedatectl set-time 9:30

reboot command


sudo reboot
systemctl reboot -i

poweroff command


sudo poweroff
systemctl poweroff -i

wget command

Download a network file, called "web get" in English. The syntax is wget [parameter] web address

Parameters in the wget command and their effects

Parameter Role
-b	  Background download mode
-P	  Download to specified directory
-t	  Maximum number of attempts
-c	  Breakpoint Continuation
-p	  Download all resources on the page, including pictures, videos, etc.
-r	  recursive

ps command

View the status of processes in the system. This is called processes in English. The syntax is ps [parameter]

Parameters and role in ps command

Parameter Role
-a	  Show all processes (including those of other users)
-u	  Users and other details
-x	  Show processes without control terminals

Five common process states are run, interrupt, uninterruptable, deadly, and stop

R(Run: The process is running or waiting in the run queue.

S(Interrupt: The process is dormant and disengages when a condition is formed or when a signal is received   Status.

D(Non-interruptable: The process does not respond to system asynchronous signals, even when using kill Commands cannot interrupt them either.

Z(Dead: The process has terminated, but the process descriptor still exists, Until the parent process calls wait4()The process is released after the system function.

T(Stop: The process stops running after it receives a stop signal.

pstree command

Show the relationships between processes in a tree, called a process tree in English

top command

Dynamically monitor information such as process activity and system load

nice command

Adjust the priority of the process in the syntax of nice -n Priority Digital Service Name

In the output of the top command, the PR and NI values represent the priority of the process. The lower the number (range -20-19), the higher the priority.

pidof command

Query the PID number value of a specified service process in the syntax pidof [parameter] service name

kill Command

Terminates a service process with a specified PID value, with the syntax kill [parameter] process PID

Parameter-9 Force killing process at highest level

killall command

Terminates all processes corresponding to a specified name of service in the syntax killall [parameter] service name

ifconfig command

Get information such as network card configuration and network status, which is called "interface config" in English and has the syntax ifconfig [parameter] [network device]

uname command

View information such as the system kernel version and system architecture. The full name is unix name in English and the syntax format is uname [-a]

free command

Displays memory usage information in the current system in free [-h] syntax

who command

View user terminal information currently logged on to the host

last command

Call host's visited record

ping command

Test network connectivity between hosts in the syntax ping [parameter] host address

Parameters in the ping command and their effects

Parameter Role
-c	  Total Sends
-l	  Specify Network Card Name
-i	  Every interval (seconds)
-W	  Maximum wait time (seconds)

tracepath command

Displays all routing information that a packet travels through on its way to the destination host in the syntax of a tracepath [parameter] domain name

netstat command

Parameters and role in netstat command

-a	Show all connections in Socket
-p	Show in use Socket information
-t	display TCP Connection Status of Protocol
-u	display UDP Connection Status of Protocol
-n	Use IP Address, do not use domain name
-l	List only the service status being monitored
-i	Network Card List Information Now
-r	Show routing table information

history command

Displays the history of executed commands in the syntax history [argument]

-c      Clear Records
!Number reuse

sosreport command

Collect system configuration and architecture information and output diagnostic documents

pwd command

Displays the working directory path where the user is currently located. This is called print working directory in English

cd command

Switch the current working path, which is called "change directory" in English and has the syntax cd [parameter] [directory]

ls command

Displays file information in a directory, called a list in English, in the syntax ls [parameter] [file name]

-a   Show all files
-l   Show Details
-d   Directory only
-Z   See SElinxu value

tree command

List directory contents and structure as a tree chart

find command

Finds the location of the file according to the specified criteria, and the syntax format is find [search scope]

Parameters and role in find command

parameter	            Effect
-name	            Match Name
-perm	            Match permissions ( mode To match exactly,-mode To include)
-user	            Match Owner
-group	            Match all groups
-mtime -n +n	    Match the time of change (-n finger n Within days,+n finger n Days ago)
-atime -n +n	    Match the time to access the file (-n finger n Within days,+n finger n Days ago)
-ctime -n +n    	Match the time to modify file permissions (-n finger n Within days,+n finger n Days ago)
-nouser            	Match files without owners
-nogroup	        Match files without all groups
-newer f1 !f2	    Match ratio file f1 New but better f2 Old Files
--type b/d/c/p/l/f	Match file type (Subtitle letters after represent block device, directory, character device, pipeline, linked file, text file in turn)
-size	            Match file size (+50KB To find more than 50 KB And-50KB To find less than 50 KB Files)
-prune	            Ignore a directory
-exec ...... {}\;	    Following commands for further processing search results

Loce command

Quickly search the location of the file by name, syntactically in the location file name

Build database with updatedb before use

whereis command

Quickly search binaries (commands), source code, and help files by name in the syntax whereis command name

which command

Quickly searches the location of the binary program (command) by the specified name in the syntax of the which command name

cat command

View plain text files (less content), called "concatenate" in English, with cat [parameter] file name in syntax

-n set number

more command

View plain text files (more content), grammatical format is more [parameter] file name

head command

View the first N lines of a plain text file, grammatically formatted as head [parameter] file name

-n Set the number of rows

tail command

View the last N lines of a plain text file or continuously refresh the latest contents of the file, in the syntax format tail [parameter] file name

-n Set the number of rows
-f Continuous refresh

tr command

Replace characters in the text content, called "translate" in English, with tr [original character] [target character]


cat anaconda-ks.cfg | tr [a-z] [A-Z]

wc command

Counts the number of lines, words, or bytes of a specified text file. English is called "word counts" and the syntax is wc [parameter] file name

Parameters and functions in wc command

parameter	Effect
-l    	Show only rows
-w    	Show word count only
-c    	Show bytes only

stat command

See the specific storage details and time of the file, which is called "status" in English and has the syntax of the stat file name

Access Time (Atime for short) when the content was last accessed

Modify Time

Change Time (the last time a file property was modified, or Ctime for short).

grep command

Extract text content by line in grep [parameter] file name syntax

Parameters in grep command and their functions

parameter	Effect
-b	    Will executable(binary)As a text file ( text)To search
-c	    Show only the number of rows found
-i	    ignore case
-n	    set number
-v	    Reverse Selection - List only rows without keywords.

cut command

Extract text content by Column with the syntax cut [parameter] file name


cut -d : -f 1 /etc/passwd

-d Set intervals, cutoffs
-f Specify Columns

diff command

Compare the differences between the contents of multiple files. English is all called "different" and the syntax is diff [parameter] file name A file name B

--brief  Determine if the files are the same
-c       Describe specific differences in file contents

uniq command

Removes consecutive lines of repetition from the text. The English language is called "unique", and the syntax is uniq [parameter] file name

sort command

Reorder text content in the syntax sort [argument] file name

Parameters in the sort command and their functions

parameter	Effect
-f	    ignore case
-b	    Ignore indents and spaces
-n	    Sort Numerically
-r	    Reverse sort
-u	    Remove duplicate rows
-t	    Specify Interval Character
-k	    Set field range


sort -t : -k 3 -n user.txt

touch command

Create a blank file or set the time of the file, grammatically in touch [parameter] file name

Parameters in touch command and their functions

parameter	Effect
-a	    Modify Read Time only atime)
-m	    Modify Modify Time Only mtime)
-d	    Modify at the same time atime and mtime

mkdir command

Create a blank directory, called "make directory" in English, with the syntax mkdir [parameter] directory name

cp command

Copy a file or directory, called "copy" in English, with the syntax cp [parameter] source file name and target file name

Parameters in the cp command and their functions

parameter	Effect
-p	    Keep the properties of the original file
-d	    If the object is a Link File, the properties of the Link File are preserved
-r	    Recursive continuous replication (for directories)
-i	    Ask if the target file exists to be overwritten
-a	    Amount to-pdr(p,d,r For the above parameters)

mv command

Cut or rename the file, all called "move" in English, syntactically mv [parameter] source file name Target file name

rm command

Delete a file or directory, which is called "remove" in English and has the syntax "rm [parameter] file name"

Parameters in rm commands and their functions

parameter	Effect
-f	    Enforcement
-i    	Ask before deleting
-r	    Delete Directory
-v	    Show process

dd command

Copies or converts files according to a specified size and number of data blocks in dd if=parameter value of=parameter value count=parameter value bs=parameter value

Parameters in dd command and their functions

parameter	Effect
if	    File name entered
of	    Output File Name
bs	    Set the size of each "block"
count	Set the number of blocks to copy


dd if=/dev/zero of=560_file count=1 bs=560M

/dev/zero wireless data

file command

File type, grammatical format is "file file name"

tar command

Package, compress, or unzip the file in the syntax "tar parameter file name"

Parameters in the tar command and their effects

parameter	Effect
-c	    Create Compressed File
-x	    Unzip Compressed File
-t	    See which files are in the compressed package
-z	    use Gzip Compression or decompression
-j	    use bzip2 Compression or decompression
-v	    Show the process of compression or decompression
-f	    Target File Name
-p	    Keep original permissions and attributes
-P	    Compression using absolute paths
-C	    Specify the directory to unzip to

Tags: Linux redhat

Posted on Sat, 11 Sep 2021 14:52:31 -0400 by siropchik