Commonly used instructions

ls         Show files or directories

     -l           List file details l(list)

     -a           List all files and directories in the current directory , Include hidden a(all)

mkdir         Create directory

     -p           Create directory , If there is no parent directory , Create p(parent)

cd               Toggle directory

touch           Create an empty file

echo             Create a file with content .

cat               View file contents

cp                 Copy

mv               Move or rename

rm               Delete file

     -r             Recursive delete , Can delete subdirectories and files

     -f             Mandatory deletion

find               Search the file system for a file

wc                 Count the number of lines in the text 、 Number of words 、 Number of characters

grep             Find a string in a text file

rmdir           Delete empty directory

tree             The tree structure shows the directory , Need to install tree package

pwd               Show current directory

ln                   Create link file

more、less   Page by page display of text file content

head、tail     Show header 、 Ending content

ctrl+alt+F1   Command line full screen mode

 

System management command

stat               Show details of the specified file , Than ls A more detailed

who               Show online login users

whoami           Display the current operating user

hostname       Display host name

uname           Display system information

top                 Dynamic display of process information that currently consumes the most resources

ps                   Show transient process status ps -aux

du                   Check the catalog size du -h /home With unit display catalog information

df                   Check the disk size df -h With unit display disk information

ifconfig           Check the network

ping                 Test network connectivity

netstat           Display network status information

man                 Orders don't work , Looking for a man   Such as :man ls

clear               Clear the screen

alias               Rename the command Such as :alias showmeit="ps -aux" , In addition, the use of unaliax showmeit

kill                 Kill process , You can use first ps or top Command to view the id, And then use kill Order to kill the process .

 

Package compression related commands

gzip:

bzip2:

tar:                 Packaging compression

     -c               The archive

     -x               Compressed files

     -z              gzip Compressed files

     -j              bzip2 Compressed files

     -v               Shows the compression or decompression process v(view)

     -f               Use file name

example :

tar -cvf /home/abc.tar /home/abc               Pack only , Uncompressed

tar -zcvf /home/abc.tar.gz /home/abc         pack , And use gzip Compress

tar -jcvf /home/abc.tar.bz2 /home/abc       pack , And use bzip2 Compress

Of course , If you want to decompress , Just replace the above command   tar -cvf  / tar -zcvf  / tar -jcvf Medium “c” Switch to “x” That's all right. .

 

To turn it off / Restart the machine

shutdown

     -r             Shut down and restart

     -h             Shut down without restarting

     now           Turn off immediately.

halt               To turn it off

reboot           restart

 

Linux The Conduit

Take the standard output of one command as the standard input of another . That is to combine several commands , The result of the latter command in addition to the previous one .

example :grep -r "close" /home/* | more       stay home All files in the directory , Include close The file of , And pagination output .

 

Linux Package management

dpkg (Debian Package) Management tools , Package name with .deb suffix . This method is suitable for the case that the system can not be connected to the network .

Such as installation tree Command installation package , First the tree.deb to Linux In the system . Then use the following command to install .

sudo dpkg -i tree_1.5.3-1_i386.deb         Install the software

sudo dpkg -r tree                                     Uninstall software

 

notes : take tree.deb to Linux In the system , There are many ways .VMwareTool, Use mount mode ; Use winSCP Tools etc. ;

APT(Advanced Packaging Tool) Advanced software tools . This method is suitable for the situation that the system can connect to the Internet .

Still in tree For example

sudo apt-get install tree                         install tree

sudo apt-get remove tree                       uninstall tree

sudo apt-get update                                 Update software

sudo apt-get upgrade        

 

take .rpm The file to .deb file

.rpm by RedHat The software format used . stay Ubuntu You can't use it directly , So we need to change .

sudo alien abc.rpm

 

vim Use

vim Three models : Command mode 、 Insertion mode 、 Edit mode . Use ESC or i or : To switch modes .

In command mode :

:q                       sign out

:q!                     Forced exit

:wq                   Save and exit

:set number     According to the line Numbers

:set nonumber   Hide line numbers

/apache             Find... In the document apache Press n Skip to the next ,shift+n the previous

yyp                   Copy the line where the cursor is , And paste

h( Move one character to the left ←)、j( The next line ↓)、k( Last line ↑)、l( One character to the right →)

 

User and user group management

/etc/passwd     Store user accounts

/etc/group       Storage group account number

/etc/shadow     Store the password of the user's account

/etc/gshadow   Store password of user group account

useradd user name

userdel user name

adduser user name

groupadd Group name

groupdel Group name

passwd root     to root Set the password

su root

su - root 

/etc/profile     System environment variable

bash_profile     User environment variable

.bashrc               User environment variable

su user               Switching users , Load profile .bashrc

su - user             Switching users , Load profile /etc/profile , load bash_profile

Change the user and user group of the file

sudo chown [-R] owner[:group] {File|Directory}

for example : Also with jdk-7u21-linux-i586.tar.gz For example . Belongs to the user hadoop, Group hadoop

To switch users and groups to which this file belongs . You can use commands .

sudo chown root:root jdk-7u21-linux-i586.tar.gz

 

File permission management

Three basic rights

R           read         The value is expressed as 4

W           Write         The value is expressed as 2

X           Executable   The value is expressed as 1

As shown in the figure ,jdk-7u21-linux-i586.tar.gz The permission of the file is -rw-rw-r--

-rw-rw-r-- Ten characters in all , Divided into four sections .

First character “-” Represents a common file ; This position may also appear “l” link ;“d” Presentation directory

The second, third and fourth characters “rw-” Indicates the permissions of the current user .   So it's expressed numerically as 4+2=6

The 56th character “rw-” Indicates the permissions of the current group .       So it's expressed numerically as 4+2=6

The 89th character “r--” Indicates other user rights .               So it's expressed numerically as 4

So the permission to operate this file is expressed numerically as 664 

Change permissions

sudo chmod [u Users  g Subordinate to the group  o Other users  a All users ]  [+ Increase the permissions  - Reduce the permissions ]  [r  w  x]   Directory name  

for example : There's a file filename, Permission is “-rw-r----x” , Change the permission value to "-rwxrw-r-x", Expressed numerically as 765

sudo chmod u+x g+w o+r  filename

The above example can be expressed numerically

sudo chmod 765 filename