Common Linux commands, including VI, SVN

Source: Internet
Author: User

/etc/init.d/network restart
//===========================================
Update Script
Cd/www/scripts
Update site
./staging_deploy.sh-d Web
Update Resource
./staging_deploy.sh-r Resource
./staging_deploy.sh-n Webplus

31 on hand-received package
cd/www/staging/svn/php
Rm-rf
wget http://i.fx-func.com/svn/juxiang/php/webplus.tar.gz--user=connect--password=20110609
//===============
/usr/local/nginx/conf/vhosts.enabled

Sed modify File
SED-E View
Sed-i '/newbuddy/s/9072/9010/g '/www/wwwroot/website/system/config.php
==============================================
192.168.200.5 SVN code base
/home/www/jenkins/jobs/website-package-online/workspace/application

Cd/www/tar/resource
/www/tar
SVN St resource/
SVN ci resource/-M "Manual"
CD resource/
SVN St pc/
Pwd
SVN revert-r/WWW/TAR/RESOURCE/PC
SVN up
Cd..
SVN St resource/
SVN ci-m "Manual"
SVN info resource/
CD resource/
SVN info

SVN Basic Operation

Check out Checkout (CO)
SVN Co ${url}

Updating update (UP)
SVN up

Commit commit (CI)
SVN ci-m "Fix xxx Problem"

View current Catalog last 5 commit Records
SVN log-l 5

View current Working Copy information
SVN info

View the currently uncommitted file status (ST)
SVN St
This command outputs each added, modified, deleted directory and file, with the preceding C representing the conflict, with particular attention. SVN St can also be used under Linux | grep ^c to view the conflicting entries.

See what's currently being modified
SVN diff

Undo current changes, overwrite the latest version of the repository
svn revert Path/filename

Recursively revokes the current directory modification, overwriting the latest version of the repository. Note that the new files will not be deleted, you can also delete the working copy, re-checkout
svn revert. --recursive

Merge

SVN Merge

Recursive version file: SVN add *--force
Find gamesite/system/-maxdepth 100-name. SVN
=============================
/ETC/INIT.D/PHP-FPM restart
/etc/init.d/nginx Reload | Restart
scp/www/run/fdfsclient/picture.php [Email protected]:/www/temp

Find./-mtime 0: Returns files that have been modified in the last 24 hours

Files modified within the last one hours of the find/home/user-cmin-60 folder

VI Editor
: Number of occurrences of 50,100S/NEW//GN

:%s/a/b/g Replace All or: s/a/b/If you don't add/g, you mean replace the first line
Or use: Set Nu

: 10,20s/a/b/g replaces the 10--20 line with a

ll | grep. PHP lists all the files that are PHP
ll viso* list folders that contain Viso keywords
LS [p-x]*-D lists files beginning with P to X

:%s/\/images/http:\/\/static.kunlun.com\/web\/kl\/images/g Replace All

Http://static.kunlun.com/web/sg/images/input_bg1.jpg

Unzip Test.zip

Sudo-i Permissions

rsync-aqc/data/app/www/cms1.kunlun.com/mf/*/data/app/www/www.mffy.renren.com/

cp-arf/data/app/www/www.mffy.renren.com/login.php/data/app/www/cms1.kunlun.com/mf/

/usr/sbin/nginx-t-c/data/app/conf/nginx.conf

Common commands
Touch generates an empty file/bin/touch
CD-Back to the last visited directory
CD!$
Cp-a Copy Directory
Cp-f forced copy
Cp-p copy retains the original file date
Cat reads it no matter how long it is
Count the number of rows that appear
Cat xxx.txt |grep "xxx" |wc-l
If the number of statistics occurs
awk ' {s+=gsub (/target string/, ' & ')}end{print s} ' target file name
awk ' {s+=gsub (/w/, "&")}end{print s} ' aa.txt

More split screen read file F or space display next return key show next line Q exit
Less split screen view file PageUp previous screen PageDown next screen home back to the beginning end end
Head-n to view the first n rows of a file
Tail-n viewing the last n rows of a file
Find/-name. Metadata |xargs ls-lt//view files by time

ln-s [source file] [target file] Note: The source and destination files must use absolute paths, hard links cannot cross devices (DF-T)
Mkdir-p Sub-Directory/A/B/C/D
Whereis commands for displaying system commands and help manuals

Find [Search path] [search keywords] [file or directory] find/etc/-name ' f* '
Locate httpd.conf entire file search "UpdateDB re-update index file for easy access"
grep root passwd find matching content in the file grep-v "#"/etc/passwd Exclude lines with #

Compress files
Only files can be compressed and the original files are not preserved
Gzip GUN Zip
Gzip-1 file means fast compression
gzip-9 file Nine nice best state compression
Gunzip file.gz Decompression
Gzip-d file.gz

Compress gzip route.php
Decompression Gunzip route.gz

Compressed directory
Tar packaging
Tar-c produce a. tar file
Tar-v viewing the compression process
Tar-f Specify the file name after compression
Tar CVF can be omitted-tar cvf testdir.tar TestDir
Tar xvf decompression
Unzip to the specified directory tar zxf testdir.tar.gz-c web
Tar ZCVF best Compressed tar zcvf testdir.tar.gz testdir[directory name]
Tar zxvf Decompression

TAR-TF Viewing packaged Content

Communication commands
Write send message Write Yuejide SFDSF
Wall send messages to all users wall FDFDF
MESG y Accept Message
MESG N Masking messages
Mail Receive Letter
H View List
R reply
Q exit
Mail Recipient

Init 0 shutdown
Init 6 Restart
Shutdown-h now
Reboot

Export SZ Test.txt
Import RZ

Linux Network Commands
Write send message to user Ctrl+d save end
Write Linzhilin
Xiang He ni chifan ctrl+d save exit
Ping Test network connectivity
Ping 192.168.0.1
Ifconfig Viewing and setting network card information
Ifconfig eth0 192.168.0.2
Mail to view the files sent by the system
Enter serial number to view directly
H View List
D Serial Number Delete message
Q exit
Last displays the time information for all user logins on the computer
Lastlog command to view all user logon information
Last-u UID View a user login information
Traceroute show the path between packets to the host
Netstat "options" to display network-related information
-T View information for the TCP protocol
-U View UDP protocol information
-L Monitoring
-R Routing
-N Display IP address and port number
Netstat-tlun viewing the port on which this machine listens
Netstat-an View all network connections on this machine Netstat-an | Grep-v "10.10.208.84" | grep established view current and native connected users
Netstat-rn viewing the native routing table

Setup configures the network,
Mount Mount
Create mount point Mkdir/mnt/cdrom
mount/dev/src0[Device Name]/mnt/cdrom
UMOUNT/DEV/SRC0 Unload mount point

Strace command to trace a process strace-p 10747
#已易读的格式显示指定目录或文件的大小,-s option specifies that each subdirectory or file size is not displayed in detail for the directory
Du-sh [Dirname|filename]
Such as:
Size of current directory:
Du-sh.
The size of the next file or directory in the current directory:
Du-sh *
Show the top 10 most space-occupying files or directories:
Du-s * | Sort-nr | Head

VI Edit
I a O
Ctrl+f Next Page
Ctrl+b previous Page
Ctrl+d Next Screen
Ctrl+u on a screen
G last line
GG First Line

I insert the cursor where
I cursor is positioned to the beginning of the insertion

A specifier insertion of the word where the cursor is located
A the end of the line where the cursor is inserted

o Insert anchor to next line
O Insert anchor to previous line

0 Navigate to the beginning of a line
$ navigates to the end of a line

R replaces the character at the beginning of the cursor

N Search Down
N Search Up

:/1067,1060s/logs/php/g N1 Line---n2 line replace all

X Backward Delete
X forward Delete
DD Delete a row
NDD Delete N rows
DG deletes all data from the row to the last row of the cursor
D1G Delete all data from the row to the first row of the cursor
d$ Delete the last character of the line to which the cursor is located
D0 Delete the first character of the line to which the cursor is located
P copy down n columns where the cursor is located
P The up n column where the cursor is copied
U undo Operation

: r/etc/issue Import to Cursor location: R + file name
: R!date Import command result to current file

: Map Shortcut Trigger command
: Map ^p (ctrl+v+p) i#<esc>
: Map ^b 0x
: Map ^m [Email protected]<esc>

Comment Multiple lines
: 4,8s/^/#/g
Cancel Comment
: 4,8s/^#//g
: 4,8s/^/\/\//g

: AB mymail [email protected] Just enter MyMail to display the email address

Create save Shortcut Vim command
VI/ROOT/.VIMRC Root User
VI/HOME/YUEJIDE/.VIMRC Ordinary Users
Set Nu
Map ^p i#<esc>

Scheduling task commands at once
To execute a program (command) at a point in time, be sure to use the full path of the command
At 17:40
>/bin/cp/www/test/*/www/xsphp/
Ctrl+d exit
At-l or ATQ View task execution
at-d or ATRM task number
At 17:30 month/day/year
At-f file point in time
At < One.txt Point in time
At configuration file
This command is available to users listed in the/etc/at.allow file
This command is not available to users listed in the/etc/at.deny file
Two files do not exist, only the root user can use this command, both exist and are empty all users can use this command

Recurring Scheduled Tasks crontab
Service Crond Status//view state
PS aux | grep Crond
Start/sbin/service crond Start
Stop/sbin/service Crond Stop
* * * * * */www/test/btest.sh
Time-sharing Week
Crontab-l List
CRONTAB-E Edit
Crontab-r Delete
/etc/cron.allow If this file exists, the user name contained in the file can be used crontab.
/etc/cron.deny If this file exists, the user name contained in the file cannot be used crontab.
*/5 * * * */usr/local/php/bin/php/www/faetest/yuejide/tt.php//5 minutes Add a record to the database

View process
Ps-el
Ps-aux
S Sleep D non-interruptible sleep R run Z Zombie State T stop State
Kill process
Killall httpd kills all and httpd related processes
Kill Process Number
Kill-9 kills Zombie Process
Date +%y-%m-%d

Linux Users
1, Superuser Root has all the privileges of the operating system UID is 0
2, ordinary users have limited access to the operating system UID 500--6000
3, pseudo-user is to facilitate the system management, to meet the corresponding system process file owner requirements, can not login UID 1-499
PASSWD/ETC/PASSWD Manage users through this file, only define the account does not define the password

Account Name: Root
User password: X
User identification (User ID): 0
User ID (user group ID): 0
User-related information: root
User home directory: User's own directory
User environment:/bin/bash

Useradd Creating a user
-u-g-g-d-s-c-e-k-m-m-R
Userdel Deleting a user
tail-5/etc/passwd User Information
tail-5/etc/shadow Password
-R Delete User home directory and all information
change user name
Usermod-l Thisueser MyUser
Usermode-l thisuser Lock User
Usermode-u thisuser Unlocking user

Passwd-l
Passwd-u
Passwd-s Unlocking
Linux User groups
/etc/group
1. Group name
2. Group password
3. GID
4. List of users in the group (all user name tables that belong to the group)

Useradd-g mygroup myuser1 Add user to owning group
Userdel-r myuser1 Delete user
Groupadd add
groupmod Modify
Groupdel Delete
Gpasswd-a redhat newgroup Modify user belongs to group
gpasswd-d Redhat newgroup Delete the owning user group

ID view UID and GID for a user
id[option] User name
Id-g Yuejide
Id-g Yuejide
Finger to view information about the user, including the user's group directory to start the shell
Finger Yuejide

Chmod-r Permissions File
Chown change the file or directory owner
Chown-r including sub-directories
Chown-r Www:www/www/run Modifying both the owner and the owning group
CHGRP changing the owning group of a file or directory
Find views/-maxdepth 100-type d-name. SVN | Xargs Chown-r www:www
Find/-iname *?//not case-sensitive, accurate search?
Find/-size +204800 files larger than 100M
Find/-size-204800 files less than 100M
Find/home-user www//According to the owner to find
Find/home-group www//belongs to group
find/home-cmin-5 files and directories with properties modified within 5 minutes
-amin//visited
-cmin//changing properties
-mmin//Modifying content
-type D Catalogue
F file
Find/etc-name initab-exec ls-l {} \; List the file properties after checking
Shell programming
View History Command Historical list all!99 execute 99th instruction!str the nearest command
History-c Clear All Instructions
Input/output ls > test.txt write to test.txt file, output redirect >> append output redirect
How many lines ll | Wc-l

Set view all variables in the system unset delete variables
ENV global variable
Export changes local variables to global variables
Do not invalidate environment variables after reboot
Vi/etc/profile

Operation
Expr $aa \* $bb multiplication, there must be a space in the middle

Number of positional parameters in the $# command
$* the contents of all positional parameters
$? Status returned after the last command was executed, current return status 0 is normal, non-0 indicates an exception or an error
$$ the process number of the current process
$! the last process number running in the background
The currently executing process/program name

-d is catalog file directory
-e file exists exist
-F is File
-R whether Read permission
-W Whether write permission is written
-X whether there is execute permission excute
-L is a symbolic connection file link

-eq: Equals equal
-NQ: Not equal to no equal
-GT: greater than greater than
-lt: Less than lesser than
-le: Less than or equal to lesser or equal
-ge: greater than or equal to greater or equal
string comparison
= string content is the same
! = string content is not the same
-Z String content is empty
&& and
|| Or
! Take counter

Statement
if; then
elif;
Else
Fi

For variable name in value list
Do
Command sequence
Done

while[true]
Do
Command sequence
Done

Case $i in
Start
echo "Start ..."
;;
Stop
echo "Stop ..."
;;
Restart
echo "Restart ..."
;;
Esac

Rpm
Rpm-qa|grep Yum|xargs rpm-e--nodeps
Rpm-e--nodeps Uninstall

Common Linux commands, including VI, SVN

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.