linux common commands in test

Reference: https://www.cnblogs.com/lingzeng86/p/6595951.html

 

 Nothing else to do, sum up the common commands under linux, but also useless to a long, later to be used when reviewing records

ls和ll

Both are real documents, but not to show hidden files, hidden files if you want to display, then you need to use ls -a command

 

cd

cd ~: enter the user's home directory

cd -: Back to Contents before entering this directory

 

pwd

To display the current directory

 

whoami

Displays the current user name

 

mkdir

Create a directory mkdir a tree a, that is a file

mkdir bc create two trees, a file b, c a file

mkdir -p file1 / file2 / file3 :-p representatives loop to create, if not create this directory is the directory

 

Tab

Automatically append shortcuts, if you have a book file in the current directory, when you type b press the tab key, it will automatically help you filled the file name, it is easy to use

 

clear

Are some of the conventional command, mainly on the interface empty, of course, not really emptied, just write your command all moved to the top, the new open-top line, like emptying effect

 

touch

This is the mkdir and attached together using, mkdir is to create a folder, touch a file is created, but can also create multiple file names at the same time with a touch

 

rmdir

rmdir a delete a file a

rm -rf a cycle directory and delete all files in a directory (with caution)

rm -rf bc circulation delete the two files

 

rm

To delete a file or directory

rm file1 delete a file

rm -f file1 not prompted to delete a file

rm -rf file circulation to remove all the contents of the entire file, be sure pwd own position, caution

cp

cp file / *:. Copy all the files under the file directory to the current directory

cp -a dir1 / dir2 /:. dir2 direct copy this folder to the working directory

 

its

Switching superuser command, you can avoid a lot of authority, of course, this is more than a command, you can refer to the following summary before I do

Grandpa, inside please , when you finish entering need to enter their orders, usually root

 

chmod

For command authority, you can modify the settings authority, the same reference notes before me

Grandpa, please inside , with ll see that the permissions of each file

chmod +777 file1: file1 change the permissions of the file that the user has read, write, and execute permissions, the same group and others have execute permissions to read, no write permissions to other users of the same rights and privileges for group same

chmod a + r file1: Anyone can file file1 to read

chmod a + x file1: Anyone can file file1 to perform

 

vi or vim

Are editing commands, first edit the file with a file vi file, and then enter the edit page, do as i pay under normal display before writing to insert

Exit vi editing mode: Grandpa, come in please

 

 

cat

Command to display file contents, we often use cat to see the contents of the file

cat file to view the contents of the file file

cat -n file line number

 

tac

Flashbacks show file, in turn, is equivalent to cat

With a relatively small file, typically used to check the log

 

more

Recommended file viewer, so that the screen paused while showing full page, the page can be switched by keyboard shortcuts

General command more aaa

Next space representation

Enter represents the next line

b represents the previous page

/ Patten patten this element represents find

q for quit

 

less

Easy File Viewer

less commands usage and more command similar, it can also be used to view more than one file, except that in addition to the less command press the spacebar down display the documents, you can also use the arrow keys to scroll through the file, when to end while browsing, as long as the command prompt in less ":" the next press Q to

 

head

Show header

head file default display the last 10 lines

head -5 file 5 displays the first line

 

tail

Display end of the file

tail file default display the last 10 lines

tail -5 file shows the last five lines

tail -f file displayed in real time at the end of the file, it is important to check the log command

 

echo

echo 123 is directly input to the terminal

echo aaa>>a.txt  追加

echo aaa> a.txt cover

echo -n ""> a.txt the file emptied here to add -n, otherwise the character will be saved in the home inside

 

sort

Sort Text command

sort -n file sorting digitally

sort -r file in reverse

sort -u file deduplication

sort -rm file ascii sort of way

and piping in conjunction with the sort command

Such as: du -k * | sort -rn # file size descending row (very important) to see which account for more documents

 

grep

Printing the matched lines, grep often used in conjunction with conduit

grep "regular expression" file. With a good premise is familiar with regular grep under linux

grep 3 a.txt # a.txt file contains three rows printed out

grep 3 a.txt | wc -l # a.txt how many rows are contained in the file 3

grep -n 3 a.txt # 3 contains the line number and the line gave break out

grep -v 3 a.txt # 3 does not contain are displayed

Beginning grep 89 $ a.txt # 89 rows displayed

grep -n aa * # current directory contains all lines of aa displayed, print out the line number

 

kill

kill 10140 # child process itself and kill all

kill -9 10140 # only kill the child process

 

top

Check the health system commands, there are also notes, a bit more, I'll just send the link to it is I wrote before

Grandpa, come in please ,

 

Compression and unpacking

Do not make much introduction, see notes uncle, come in please

 

ps

Command displays the current process, using regular ps -ef

Details

 

netstat

View network information

netstat -lnp listening port case

netstat -anp all the ports case

Guess you like

Origin www.cnblogs.com/cheneyboon/p/11816002.html