​​Linux brief introduction

Linux, Free and open source , Multiuser multitask system . be based on Linux There are multiple versions of derivatives .RedHat,Ubuntu,Debian etc. .

Common 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 , Then create p(parent)

cd               Switch directories

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 deletion , Can delete subdirectories and files

     -f             Force delete

find               Search for a file in the file system

wc                 Count lines in text , Number of words , Number of characters

grep             Find a string in a text file

rmdir           remove empty directories

tree             Tree structure display directory , Installation required tree package

pwd               Show current directory

ln                   Create linked file

more,less   Page by page display of text file content

head,tail     Show header , Tail content

ctrl+alt+F1   Command line full screen mode

System management command

stat               Show details of the specified file , than ls More detailed

who               Display online login users

whoami           Show current operation user

hostname       Display host name

uname           Display system information

top                 Dynamic display of process information consuming the most resources

ps                   Show transient process status ps -aux

du                   View catalog size du -h /home Display catalog information with unit

df                   disk size viewing df -h Display disk information with units

ifconfig           View the network

ping                 Test network connectivity

netstat           Display network status information

man                 The command won't work , Looking for a man   as :man ls

clear               Clear screen

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

kill                 Kill process , You can use it first ps or top Command view process's id, And then kill Command kill process .

Package compression related commands



tar:                 Pack and compress

     -c               Archive file

     -x               Compress files

     -z              gzip Compress files

     -j              bzip2 Compress files

     -v               Show 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 , Combined use gzip compress

tar -jcvf /home/abc.tar.bz2 /home/abc       pack , Combined use bzip2 compress

of course , If you want to unzip , Replace the above command directly   tar -cvf  / tar -zcvf  / tar -jcvf In “c” change into “x” That's it .

Shut down / Restart the machine


     -r             Shutdown and restart

     -h             Shutdown without restart

     now           Shut down now

halt               Shut down

reboot           restart

Linux The Conduit

Use the standard output of one command as the standard input of another . That is to use several commands together , The result of the last command in addition to the previous one .

example :grep -r "close" /home/* | more       stay home Find all files in the directory , include close Documents of , And page output .

Linux Package management

dpkg (Debian Package) management tool , Package name to .deb suffix . This method is suitable for the situation that the system cannot be connected to the Internet .

Such as installation tree Installation package for command , First 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 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 tree take as an 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 File to .deb file

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

sudo alien abc.rpm

vim use

vim Three modes : Command mode , Insertion mode , Edit mode . use ESC or i or : To switch modes .

In command mode :

:q                       sign out

:q!                     forced return

:wq                   Save and exit

:set number     set number

:set nonumber   Hide line numbers

/apache             Find in document apache Press n Jump to the next ,shift+n the previous

yyp                   Copy cursor line , And paste

h( Move one character left ←),j( next row ↓),k( previous line ↑),l( One character to the right →)

User and user group management

/etc/passwd     Store user account

/etc/group       Storage group account

/etc/shadow     Store password of user 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 password

su root

su - root 

/etc/profile     System environment variable

bash_profile     User environment variables

.bashrc               User environment variables

su user               Switch users , Load profile .bashrc

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

Change users and groups of files

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

for example : And jdk-7u21-linux-i586.tar.gz take as an example . Belongs to user hadoop, group hadoop

To switch users and groups to which this file belongs . Commands are available .

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

File permission management

Three basic authorities

R           read         The value is expressed as 4

W           write         The value is expressed as 2

X           Executable   The value is expressed as 1