Linux Common Commands

Source: Internet
Author: User
Tags add numbers clear screen

Tools:
Virtual machine software: VMware, Virtualbox
Linux operating systems: CentOS, Redhat, FreeBSD
Tools for remote connection to Linux operating systems: Xshell, putty

WAMP Browser + Windows Server + [Apache (webserver) + MySQL + PHP]
LNMP Browser + linux server + [Nginx (webserver) + MySQL + PHP]

Learn what Linux must master:
Text operating system
Disk partitioning
Powerful command-line


Linux Common 30 commands

Help commands
Man command name man LS (need to look up the parameters of a command without having to go online to find it, as long as man)
Command name-H ls-h (get file)
Command name--help ls--help

Common
echo//output content
Reboot//restart
wget resource address//download file
Top//View system load
Ifconfig//View network conditions
Df-h//View disk status
History//View historical commands

Working Directory Toggle Commands
PWD//Print current directory
CD//switch directories, switch to the previous level, CD. /, Switch home directory CD ~
LS//View the contents of the directory

Text File View commands
CAT//View file contents
more//view files with more content, use space to flip the screen
Head//view file header several lines of content Head-n + file name
TAIL-F//Dynamic display a few lines of content Tail-n + file name

File Directory Management commands
Touch file name//create file
mkdir directory Name//create directory
CP source file address destination file address//Copy
MV source file address destination file address//move or rename
RM file name//delete file
Rm-r Directory//Delete empty directory
RM-RF Directory//Forced deletion of content directories

Package compression and Search commands
TAR-ZCVF ETC.TAR.GZ/ETC//Package the/etc directory into etc.tar.gz
TAR-ZXVF etc.tar.gz-c/root/etc//Will etc.tar.gz this file to/root/etc this directory, in advance to create a well-extracted directory
Unzip Etc.zip//decompression Etc.zip
grep text content Destination file//search for specified content in specified file
Find find path Find conditions//Locate specific files in a directory

REDIRECT, Pipe break
>//output content to a file, empty the file before output
>>//output content to end of file in Append mode
| Use the data from the previous command to output to the screen as a standard input to the latter command


User-related
Useradd User name//Add a user
PASSWD username//Modify the user's password
chmod permissions file path//Modify permissions for the specified file
SU user name//switch to the specified user
WHO//view current logged in user
Last//Show N Records Last-n (there are other uses) to log in to the system

In the Linux terminal first enter ll, you can see such as:
-rwx-r--r--(altogether 10 parameters) represents the corresponding permissions for the group and user to which the file belongs.
The first parameter belongs to the administrator, regardless of the chmod, first of all.
2-4 parameter: belongs to user
5-7 parameter: belongs to group
8-10 parameter: belongs to others
And then it's simple.:r==> readable w==> writable x==> executable
R=4 w=2 X=1
So 755 stands for rwxr-xr-x.


Skills:
Q exit
CTRL + C terminating command execution
Tab completion file name
Ctrl+l clear screen up and down to view history commands
Ctrl+u Delete all input contents
CTRL + a cursor jumps to the beginning
Ctrl+e jump to end of line

15 commonly used VIM commands
Tip: You can add numbers to the command before you do the same thing many times
. Operator can repeat the last action (not move)
; Continue the last Lookup

Insert: I O
Move: H (left) J (bottom) K (UP) L (right) W (beginning of next word) B (beginning of previous word) GG (first) G NG F character
Copy: yy (copy whole line) yw (copy a word)
Paste: P
Modification: CW S
Delete: X (single character) DD (whole line) DW (delete a word)
Visual Operation: V V
Find:/Find string N (Find next same string) n (Find previous same string)
Indent: >> <<
Back: U
Redo: Ctrl+r
Save:: W (Save): Wq (Save exit) ZZ (Save exit): q! (Forced exit not saved)
Combination: DW (delete to the end of the word without leaving a space behind the word) de (cut to the end of the word, leaving the space behind the word) d$ (deleted to the end of the line) DD (delete line) D0 (deleted to the beginning of the row)
CW CE C $ cc C0
yw ye y$ yy y0
Display line number:: Set Nu

Ps-ef | grep mysql//View the currently running process
Ps-ef | Nginx
Vim/usr/local/nginx/conf/nginx.conf
Cd/home/wwwroot/default
Yum-y Install Lrzsz//installation Lrzsz this software
Kill Master Process number//kills a process
/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf

netstat-tpln//viewing the currently open ports
Top
./install.sh
Head install.sh
Vim test.sh
#!/bin/bash
Echo ' It is a shell script file ';

SH test.sh
which SH//view the location of the command
Which Useradd
echo $PATH//The value of the output environment variable PATH
chmod u+x test.sh
./test.sh
Mkdir/root/bin
MV test.sh/root/bin/
test.sh
MV Test.sh Testsh


Crontab-e
*/1 * * * * echo $ (date) >>/root/date.txt
Time-sharing Weekly command

Service Crond restart//Restart scheduled Tasks
Tail-f/root/date.txt

Linux Common Commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.