Linux basic commands - 02 study notes

Linux:

Shutdown command: halt init0

reboot: reboot init6

linux directory structure:

bin storage system executable command file

boot file storage system equivalent to the c drive under the [windows]

dev storage media devices

etc System configuration files

ordinary home user's home directory

lib basic software compiled libraries

Users opt to install the software directory

proc Device Information

run process tasks pid

root administrator home directory

tmp temporary storage of files in the directory [php session file]

usr file storage directory of your installed php [environment]

Log var various services, scheduled tasks


linux common commands:

Change directory # XXXX path cd

sl [show file directory path of the directory does not fill in the default display current path]

For more information ll show file directory file

[cal Year - time to view the calendar [optional] Add the specified time period to view the calendar]

date view time

yum install xxxx install the system packages

man command to view the command specification

rm -rf / * delete all files

fdisk -l lists the file belongs to disk

cat does not enter the file that lists the contents of the file

netstat -nltp View all processes running

ip ip addr View

mkdir create a folder

rm -rf (*) mandatory delete folders

touch to create a file

rm -f delete files

mv dir1 dir2 dir2 dir1 dir2 directory name change does not exist

cp -r dir1 dir2 copy all the contents of dir1 to dir2

pwd view the current location

uname [-a] View System Version

top view server (cpu memory) to run state

exit exit

tree -L n [filename] lists the file tree

more split-screen view file contents (spacebar Next, b Previous)

less split screen to view the contents of the file (you can look back, you must exit by Q)

head a few lines before displaying the file (default 10 lines)

Former head num display file contents -n num lines

tail -f to see the last few lines of the file content, and real-time updates (generally used for real-time query log log)
tailf

wc see the number of characters in the file, the number of lines

> Output redirection Example: echo nihao> test01.txt (test01.txt written inside the nihao)

>> output redirection Example: echo nihao> test01.txt (test01.txt written inside the cover nihao)

<Input redirection

<< input redirection

find / -name filename File Find File

which command query command executable file

tar:
* .tar unzip with tar-xvf

* .Tar.gz compressed file

Name after the tar czf compression to compress the file name of the compressed file

tar xf extracting archive file name

rz local upload files to the server

unzip archive Unzip the file name can only extract the .zip format []

sz file name to download the file to a local

wget download link address to the server

curl

ps -ef to list all processes

kill -9 PID closed process

killall process name] [MySQL php closed a task of all processes

 


 

---------------------------------------------------------------

linux editor vim command:

Edit mode: i / a / o

Edit mode is switched to the command mode by ECS

: set num display line numbers
: set nu

:! Set nu not display line numbers

: N (number of rows) to jump to the n-th row

: Wq save and exit
: wq exit without saving!

: Q Force Quit
: q forced to exit without saving!

: U revocation

: S / xx / yy find the cursor to the first row is replaced xx yy

:% S / xx / yy xx will find all replaced YY
: delete the current cursor row dd

: N (number of rows) row dd delete the cursor to the next line in the current n

yy Copy current line

nyy cursor line to copy the current row n

p Paste

Repeat once on a command execution

0 to the beginning of the line

$ To end of line

G is moved to the end of file

move to the first line of the file gg gg jump diverted No.


Ctrl + v bulk operations

:% S # # to be replaced is replaced #g

/ N to select the character string search down a selection on the next N

? Search string up

awk -F 'separator' '{print $ 1 [Numerical - of how many columns]}' file name // file acquires the content of the i-th column

grep 'to get the value' // get the file name row

grep -V '^ query value' file name // negated

| Achieve a plurality of pipe symbol synchronization command Example: cat index.php | awk '{print $ 1}'

wc -l // line statistics


sed -i 's ### g' does not enter the batch file with the same function to replace the contents [% s ### g]

sort sort

linux user / administrator:

add users useradd username

useradd -g (subscriber group) -M username (remove) -s

usermod -g (group id) -d home directory -u user id -l modify the user name

Delete user userdel username
userdel -r Delete the user and remove the user's home directory corresponding

Creating user groups groupadd
groupadd -g group user id to add a user group specify a user group id

groupmod modify user groups
groupmod -n rent new name of the old group name of
the user group id groupmod -g group id to modify the group name

groupdel group name to delete a user group (group there is also a user, then delete failed)

passwd change password

passwd username modify the specified user name (only the root user can operate)

---------------------------
query for all users: tail -n 5 etc / passwd

You discover all user groups: tail -n 5 / etc / group

Query the current user's user group: groups id

------------------------
Linux user permission settings command:

chmod permissions filename value set user rights

chnod R filenames recursively set user rights

Chown user belongs to the user to modify the file filename

User belongs to the user chown R filename recursively modify file

chgrp Change the file belongs to group

--------------------------------------------------------------------------


Intermediate knowledge of linux

2.1 Shell Scripting

File creation: vim * .sh

Script format: # / bin / bash!

Script execution command: bin / bash filename | ./ execute permissions to modify the file filename


2.2 Variable Assignment: name = 'haha' age = 23

Variable splicing: echo $ name $ age

String interception: echo $ {name: 2: 4}

Array assignments: username = ( 'haha' 'hehe')

Array output echo $ {username [0]}

All values ​​print array echo $ {username [*]} | echo $ {username [@]}


2.3 traditional values

execute scripts value 1 value 2

Gets the count by value: $ #

Gets the incoming value: $ 1 $ 2 .....

Get the current process PID: $$

query script whether the error: $? [127 0 no error error]

2.4 Flow Control if

! // non -o // or -a // and

if [Condition] @ conditions must be spaced brackets and
the then
elif
the else
Fi

-d // directory exists -f // judge to determine whether a file exists -e // determine whether the directory or file exists
------------------------ -------------------------------------------------- -------------------------

apache nginx difference

apache: 1. 2. stable handling dynamic requests have an advantage 3. feature-rich, but take up more than 4.select model blocked resources

nginx: lightweight, small footprint 2. Anti-concurrent 3. easy to configure

Summary: Both the core difference: apache is the simultaneous multi-threading model is asynchronous nignx

Guess you like

Origin www.cnblogs.com/grhbaby/p/11737926.html