One, the file directory Operation command
1, CD Description: Change the working directory format: CD [directory name]
Cases:
Cd/home/nadim Enter Absolute path
Cd.. /nadim Entering relative path
CD/Access and Path
CD into the user's home directory
CD ~ Go to User home directory
CD-Returns the directory where it was before entering this directory
2. PWD Description: View the full path to the current working directory.
3. LS Description: Lists all subdirectories and file formats in the target directory: LS [options] [directory name]
Common parameters:
1 Each column displays only one file or directory name.
-A lists all files under the directory, including the. The implied file at the beginning.
-D Displays the directory as if it were a file, rather than displaying the file below it.
-t the LS command option can be sorted in time.
-L lists, in addition to the file name, the permissions, owner, file size, and more
The 1th column: Drwxr-xr-x represents the type and permissions of the file, starting with D as a folder, starting with a file, and starting with the connection file
2nd Column: The number of links to the file.
3rd, 4 columns: Users and Groups with files
5th column: The size of the file.
6th column: The last modification time of the file.
7th column: File name
-r,–recursive listing all subdirectory tiers at the same time
Cases:
# Ls-al |more When there are too many files and directories under the folder, a screen display can be combined with pipe character and more command to achieve split screen display
# LS-LH h parameter combined with L parameter, more reasonable to display the size of the file.
# ls-d * * Only directory information is listed, not files displayed. Sometimes folders under too many files and directories, you can use the-D parameter to display only the directory #ls-r display directory and multi-level subdirectory of the file and directory information #ls-lt sorted by the modified time, the positive sequence display #ls-ltr by the modified time, reverse order display
4, mkdir Description: Set up a directory. mkdir can create a directory and set the directory's permission format: mkdir [-p][--help][--version][-m < directory properties >][directory name]
Cases:
mkdir test1 Create an empty directory
Mkdir-p test2/test22 Create multiple directories recursively
MKDIR-M 777 Test3 Create a directory with permissions of RWXRWXRWX
Mkdir-v test4 Creating a new directory displays information
MKDIR-VP scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}} A command to create a directory structure for a project
5, RM Description: Delete the file or directory, if you want to delete the directory must add the parameter "-r", otherwise the default will only delete the file format: RM [-rf][--help][--version][file or directory ...]
Cases:
Rm-r ml Force Delete Whether the directory is empty, one by one to ask if each folder is deleted;
RM-RF ml do not ask to forcibly delete directories and files
6, rmdir Description: Delete empty directory.
Example: RmDir test1 Delete an empty directory
7. Touch Description: Create this new file. Format: Touch [options] ... File...
8, vi Description: The text editor under Linux (a Add, W save, Q quit, q! do not save the exit, Wq Save, dd delete select row, dw delete the entire word word content).
Cases:
VI FileName: Opens or creates a new file and places the cursor at the beginning of the first
VI +n FileName: Opens the file and places the cursor at the beginning of nth
VI + FileName: Opens the file and places the cursor at the beginning of the last line
VI +/pattern FileName: Opens the file and places the cursor at the first string that matches the pattern
Vi-r filename: A system crash occurred last time you were editing with VI, restore filename VI filename....filename: Open multiple files, edit them sequentially
9. CP Description: Copy file or directory format: CP [-r][source file or directory] [destination file or directory]
10. MV Description: Move or rename an existing file or directory format: MV [-r][source file or directory] [destination file or directory]
11, More/less/cat/tac/head/tail/head Description: Read the file filter on the monitor.
Cases:
Cat 3.txt is serialized out file contents
TAC 3.txt Reverse sequence out of file contents
Head 3.txt lists pre-file content
Head-3 3.txt lists the first three lines of the file
Tail 3.txt lists end-of-file content
Head-3 3.txt Lists the end of the file three lines of content
12, find description: Used in the file tree species to find files, and make the appropriate processing format: Find Pathname-options [-print-exec-ok ...]
Common parameters:
-name finds files by file name.
-perm to find files according to file permissions.
-type find files of a certain type, such as: B-block device files. D-Directory. C-character device file. P-Pipeline file. L-Symbolic link file. F-Normal file.
-amin N Find the last n minutes of access to a file in the system-atime N Find the last n*24 hour Access file in the system
-cmin n Find files in the system that last n minutes were changed file status-ctime N Find the last n*24 hours in the system file status changed
-mmin N Find the last n minutes of the system changed file data files-mtime N Find the last n*24 hours in the system file data changed file
Cases:
Find-atime-2 find the files that have been modified within 48 hours. -name "*.log" finds files that end with. Log in the current directory. ". " Represents the current directory
find/opt/soft/test/-perm 777 Find a file with permission 777 in the/opt/soft/test/directory
Find. -size +1000c-print find files larger than 1K in the current directory
Find. -type f-name "*.log" to find common files that end with a. Log in a directory
13. grep Description: Find the string that matches the condition in the file.
Cases:
The $ grep ' test ' d* shows all the lines in the file that begin with D that contain test.
The $ grep ' test ' AA bb cc Displays the line in the aa,bb,cc file that matches the test.
The $ grep ' [a-z]\{5\} ' AA displays all lines that contain a string of at least 5 consecutive lowercase characters per string.
$ grep ' Wes T.*\1′aa if West is matched, es is stored in memory, labeled 1, and then searched for any character (. *) followed by another ES (\1), which is found to display the row. If you use Egrep or GREP-E, you do not have "\" number to escape, directly written as ' W (es) t.*\1′ on it.
14, WC Description: Statistics Specify the number of bytes in the file, the number of words, lines, and the statistical results display output.
Second, user Rights management
1, Useradd/usermod/userdel/passwd/groupadd Description: User Management
Cases:
Useradd testuser2-g testuser Create a user testuser2 and specify the group TestUser
When adding a user in the/home directory, one more TestUser folder
A line of information is added to the/etc/passwd file
Add user does not specify user group system will default to a group with the same user name
Usermod-g Testg testuser Modify the TestUser group to TESTG
Userdel testuser Delete User when delete user is the/home directory user name folder will not be deleted can delete it manually
passwd testuser Add a password for testuser users
Groupadd Testg Adding groups
2. chmod Description: Rights Management
Example: chmod 755 4 corresponds to 9 bits (111011011) corresponding permission is (RWX-WX-WX)
Third, help class command
1, man Description: Format and display the online Help manual page
2, help description: Most of the commands have a-help option to get instructions for using the command.
Iv. Other
1, Shutdown Description: Shutdown instructions can be closed all programs, and according to the needs of users, to restart or shut down the action. Example: Shutdown now
2 . Clear Description: Clears the terminal screen.
3, Su Description: Change user identity, Su can allow users to temporarily change the identity of the login. Changes must be entered in the user account and password to be changed.
4. Pipeline
s-rl/etc | More '|' is Pipe connector view PPT
5. redirect
s > cmd.txt writes LS results to Cmd.txt wall < cmd.txt
Linux Common Commands