1. See what files/directories are in the directory
> ls//list listing file information for a directory
> ls-l or ll//list-list to view catalog files with "more information"
> ls-a//list-all View Directory "All" (including hidden files) files
> Ls-al//list-all List View directory "All" (including hidden files) file, with "More information" display
> ls directory//View what files are in the specified directory
> ls-i//view file index number
2. Make a directory switch
> CD dirname//For directory switching
> CD. Switch to Parent directory
> CD ~ or CD//switch directly to the home directory of the current user
3. See the full operating position
> pwd
4. User Switching
> Su-or su-root//switch to root user
> Exit//Return to original user
> SU user name//general user switch
Using the SU directive multiple times will cause the user to "overlay":
(Su and exit best match use)
Jinnan--->root--->jinnan--->root--->jinnan
5. See who the current user is
> WhoAmI
6. Graphical interface and command interface switch
Root user can switch
># Init 3
># Init 5
7. See where the execution program files for an instruction are
> which directive
8. Directory-related Operations
1) Create directory make directory
> mkdir Catalog Name
> mkdir-p newdir/newdir/newdir//Recursive creation of multiple contiguous catalogs
If the number of new multilevel catalogs is greater than or equal to 2, use the-p parameter
mkdir Dir/newdir//no-P parameter
Mkdir-p Dir/newdir/newdir//use-P parameter
Mkdir-p Newdir/newdir/newdir//use-P parameter
2) Move directory (Files and directories) move
> MV Dir1 dir2//Move Dir1 to the Dir2 directory
> MV Dir1/dir2 dir3//Move Dir2 to the DIR3 directory
> MV Dir1/dir2 DIR3/DIR4//Move Dir2 to the DIR4 directory
> MV Dir1/dir2.///Move the DIR2 to the current directory
3) Change names (Files and directories)
> MV Dir1 newdir//Modify Dir1 's name is Newdir
MV is the "move" and "Change name" merge instructions
> MV Dir1./newdir//dir1 move to the current directory and change the name to Newdir
> MV Dir1/dir2 dir3//dir2 moved to DIR3 directory and renamed "original name"
> MV Dir1/dir2 dir3/newdir//dir2 moved to DIR3 directory and renamed "Newdir"
> MV Dir1/dir2 dir3/dir4//dir2 moved to DIR4 directory and renamed "original name"
> MV Dir1/dir2 dir3/dir4/newdir//dir2 moved to DIR4 directory and renamed "Newdir"
4) Copy (change name) (file and directory) copy
Copy of the ① file
> CP file1 dir/newfile2//file1 is copied one copy to dir directory and renamed "Newfile2"
> cp file1 dir//file1 is copied to the Dir directory and changed to the name "formerly known"
> CP Dir1/filea dir2/newfile//filea was copied to Dir2 directory and renamed "NewFile"
Replication of the ② directory (need to set-r[recursive recursive] parameters, ignoring the hierarchy of directories)
> Cp-r dir1 dir2//dir1 was copied to the Dir2 directory and changed to the name "formerly known"
> Cp-r dir1/dir2 dir3/newdir//dir2 was copied to the Dir3 directory and renamed "Newdir"
> Cp-r dir1/dir2 dir3/dir4//dir2 was copied to the DIR4 directory and changed to the name "formerly known"
> Cp-r dir1/dir2 dir3/dir4/newdir//dir2 was copied to the DIR4 directory and renamed "Newdir"
> Cp-r dir1. /.. /newdir//dir1 was copied to the top level two directory and changed to the name "Newdir"
⑤ Delete (Files and directories) remove
> RM File
> rm-r directory//-r[recursive recursive] recursively delete a directory
> RM-RF File/directory//-r Force recursive forced removal of files
Force mandatory, no additional hints required
RM-RF/
9. File operation
1) View the contents of the file
Cat filename//Print file contents to output terminal
More filename//To view the contents of each line of a file row by line by hitting Enter
View by default from the first line
Not supported to look back
Q Exit View
Less//View the contents of a file by "up or down" keys
Support Back to see
Q Exit View
Head-n filename//View the top n rows of a file
Tail-n filename//View the end of the file n rows of content
WC filename//View the number of rows in the file
2) Create a file
> Touch Dir1/filename
> Touch filename
3) Append content to the file
> Echo Content > File name//append "content" to "file" in [Overwrite] mode
> Echo content >> file name//write "content" to "file" in [Append] form
(Create file If file does not exist)
10. User Action
Configuration file:/etc/passwd
1) Create user add
># Useradd
># useradd liming//Create liming user and create a group with the same name
># useradd-g Group number username//Set the user's group to avoid creating groups with the same name
># useradd-g Group number-u user number-D home directory username
2) Modify user Modify
># usermod-g Group number-u user number-D home directory-L new name username
(manual creation is required to modify the home directory)
3) Delete the user users delete
># Userdel username
># userdel-r username//delete user at the same time delete their home directory
4) Set a password for the user to log on to the system
> passwd User Name
11. Group Operations
Configuration file:/etc/group
1) Create Group add
># Groupadd Music
># Groupadd Movie
># groupadd PHP
2) Modify Group Modify
># groupmod-g gid-n new name GroupName
3) Delete Group Delete
># Groupdel groupname//group Bottom If there is a user exists, it is forbidden to delete
12. View the parameters that the directive can set
> Man command
13. Set Permissions for Files
1) Set permissions in a letter-relative manner
Set permissions for one group, other group permissions are not changed, called "Relative mode" permission settings
chmod directive
chmod u+rwx filename//Add "read, Write, execute" permission to the owner of the filename file
chmod g-rx filename//delete read, execute permissions for the same group of users to the filename file
chmod u+/-rwx,g+/-rwx,o+/-rwx filename
Description
① each unit "+" "-" can use only one
② can set permissions for one or more groups at the same time, using "," split between groups
③ the permissions for each cell can be one or more of the "rwx"
>chmod U+W,G-RX,O+RW filename//Add Write permission to filename file owner, delete read and Execute permissions in same group, add read and write permission to other groups
>chmod u+w,u-x filename//give filename owner "add Write permission" while "Delete Execute permission"
chmod +/-rwx filename//Disregard specific groups, unified set permissions for all groups
>chmod +RW filename//Add "read, write" permission to all filename users
2) Digital Absolute mode set permissions
R read: 4 W write: 2 x perform: 1
0: No Permissions
1: Execution
2: Write
3: Write, execute
4: Read
5: Read, execute
6: Read and Write
7: Read, Write, execute
chmod ABC filename//ABC represents the digital permissions of the owner, the same group, and other groups of users respectively
>chmod 753 filename//Master read, write, execute, same group read, execute, other group write, execute
Note: Use the "letter" mode when modifying the permissions relative to "less"
Instead, the "number" is used when the permissions change "very much"
14. Find content in a file
grep is searched for content file
> grep Hello passwd//Search for Hello content in the passwd file
Will print the contents of the Hello line to the terminal display
15. Calculate the size of the file to occupy disk space
> du-h Files (Directories)
16. File Search
Find Find table of Contents option option value option option value ...
1)-name option to search by name
> Find/-name passwd[full NAME]//"Recursive traverse" system all directories, looking for file name equals "passwd"
> Find/-name "pas*" [Fuzzy find]//In the system all directory, fuzzy find a name is "pas" the beginning of the file
> Find/-name "*er*"//File name has "ER" word can, do not position
2) Limit the directory hierarchy of lookups-maxdepth-mindepth
-maxdepth limit the deepest directory to find
-mindepth to limit the search to the lightest directory
> Find/-maxdepth 4-name passwd
> Find/-maxdepth 4-mindepth 3-name passwd
3) file Search according to the size of the condition
-size +/-digits
The + sign indicates that the size is larger than a range
-number indicates size is smaller than a range
Size Unit:
-size 5//Unit is "512 bytes" 5*512 bytes
-size 10c//unit is "byte" 10 bytes
-size 3k//Unit is "Kbytes" 3*1024 bytes
-size 6M//Unit is "1024* Kbytes" 6M Megabytes
> Find/-size 14c//Find files with size equal to 14 bytes in the current directory
> Find/-size +50m//search for files larger than 50M in all system directories
17. Program Port Related
NETSTAT-APN View all ports and usage
NETSTAT-APN | grep SVN finds in all
18. Check if the system is installing software
RPM-Installed software viewing mode
Rpm-qa | grep Tomcat
Make && make install software view mode
Find-name Tomcat
Reference: http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/12/2208205.html
19. View current Process information
PS Instruction
-A Show All processes
-U root specifies all processes for user root
-au Show more detailed information
-aux Show all itineraries that contain other users
Reference: http://www.cnblogs.com/peida/archive/2012/12/19/2824418.html
Linux Instruction Learning notes (i)