​​Linux brief introduction

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




Frequently used instructions

ls           Show files or directories

     -l           List file detailsl(list)

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

mkdir         Create directory

     -p           Create directory, If there is no parent directory, Then createp(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 files

     -r             Recursive deletion, Can delete subdirectories and files

     -f             Mandatory deletion

find               Search for a file in the file system

wc                 Count lines in text, Word number, Character number

grep             Find a string in a text file

rmdir           remove empty directories

tree             Tree structure display directory, Need to installtree 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, thanls 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 men  as:man ls

clear               Clean screen

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

kill                 Kill process, It can be used first.ps or top Command view process'sid, Then reusekill Command kill process.

Package compression related commands

gzip:

bzip2:

tar:                 Packaging compression

     -c               Archive file

     -x               Compressed file

     -z              gzip Compressed file

     -j              bzip2 Compressed file

     -v               Show compression or decompression process v(view)

     -f               Use file name

example:

tar -cvf /home/abc.tar /home/abc               Only pack, Uncompressed

tar -zcvf /home/abc.tar.gz /home/abc         Pack, And usegzip compress

tar -jcvf /home/abc.tar.bz2 /home/abc       Pack, And usebzip2 compress

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

Shutdown/ Restart machine

shutdown

     -r             Shutdown restart

     -h             Shutdown without restart

     now           Turn off immediately.

halt               Shutdown

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       stayhome Find all files in the directory, Includeclose Documents, 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.

For example installationtree Installation package for command, First willtree.deb Spread toLinux System. Then use the following command to install.

sudo dpkg -i tree_1.5.3-1_i386.deb         Installation software

sudo dpkg -r tree                                     Uninstall software

notes: taketree.deb Spread toLinux System, There are many ways.VMwareTool, Use mount mode; UsewinSCP 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 withtree take as an example

sudo apt-get install tree                         installtree

sudo apt-get remove tree                       uninstalltree

sudo apt-get update                                 Update software

sudo apt-get upgrade        

take.rpm Conversion of documents to.deb file

.rpm byRedHat Software format used. stayUbuntu 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. UseESC ori or: To switch modes.

In command mode:

:q                       Sign out

:q!                     forced return

:wq                   Save and exit

:set number     set number

:set nonumber   Hidden line number

/apache             Find in documentapache Pressn 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     toroot Set password

su root

su - root 

/etc/profile     System environment variable

bash_profile     User environment variables

.bashrc               User environment variables

su user               Switching users, Load profile.bashrc

su - user             Switching users, Load profile/etc/profile , Loadbash_profile

Change users and groups of files

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

for example: Also withjdk-7u21-linux-i586.tar.gz take as an example. Belonging to usershadoop, grouphadoop

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 as4

W           write         The value is expressed as2

X           Executable   The value is expressed as1