Basic linux commands and basic linux commands
1. Create a directory using mkdir
Mkdir-p create directory in a loop
Touch creates a file
2. ls displays directories or files
Ls-ld = ll view in a long directory
Ls-a (a = all) view all files or directories, including hidden
Ls-F view files by file type
3. Switch directory levels with cd
Cd .. back to the previous directory
4. view the current path file in pwd
5. cat view the File Content
Cat-n: number of lines displayed
Cat> a.txt replaces the content of the original file
Cat> a.txt add new content to the file without changing the original file content
6. Run vi/vim to enter the command (vim is better, because vim reports an error and the color is displayed)
7.> used to overwrite a single line of text
> The append object content does not replace the original content.
8.; delimiter of multiple commands
9./root or path Separator
10. copy an object using cp (copy)
Cp-a copy directory
11. move the music video to paste the mobile file.
Rename Command
12. rm (remove) delete an object
Rm-fr force Delete directory or file
Rmdir Delete directory
13. grep-v exclude the content in the file. One of the grep core commands (the third of the three swordsmen), filtering means filtering by row, which is very important.
14. sed (the second of swordsmanship) takes various contents,
-N cancel default Deletion
-P print (good at row output)
Sed-n 20, 30 p cai.txt
15. awk (boss) is good at column output
16. view the first n rows of the file in the head (the first 10 rows are displayed by default)
The last n rows of the tail display file (the last 10 rows are displayed by default)
Tail-f: view the changes at the end of the file
17. man + command explanation command (-- help can also be used)
18. which + command reporting command Location Path
Find SEARCH Command
Find-type (f d)-name "ddd" search by name
Find-mtime search by Time
19. alias view the alias of the computer
Unalias cancel alias
Alias function: 1) To prevent misoperation, add protection parameters to Dangerous commands to prevent human misoperation 2) to convert complex strings into simple command characters, for example: alias cai = "cd/data/" AND unalias cai
20. | the MPs queue sends the output of the previous command to the latter command for further processing.
21. tree View directory structure (tree shape)
22. Crtl + c terminate the currently running command line
Crtl + d Exit the current user environment
Ctrl + a to the beginning of the command line
Ctrl + e to the end of the command line
23. view history
! + You can run this command for the number of historical rows.
! + The command starting with the letter can be called.
History-c clear all history records
History-d row number to clear a row
24. In vim mode:
Set nu display row number
Dd deletes the current row
Yy copy the current row p and paste it
Row number + gg locate when this row
Shift + g to the end of the file
Gg to the beginning of the line
25. ll/dev/sd * is used to view partitioned hard disks.
26. Run cat/etc/redhat-release to view the installed linux version.
Uname-r view kernel version
Uname-m view system version
Uname-a show all
27. Currently, most linux vendors use 64-bit linux operating systems to maximize system performance.
28. A hard disk can have up to four primary partitions. One of the primary partitions can be replaced by one extended partition, and one hard disk can have only one extended partition, multiple logical partitions can be divided in this extended partition. Because the logical partition is on the primary partition, the number of the logical partition can only start from 5.
29. Names of common external devices in linux:
Floppy Disk:/dev/fdN (N = 0, 1, 2 .....)
Optical Drive (IDE):/dev/cdrom
Optical Drive (SCSI):/dev/scdN
Hard Disk (IDE):/dev/hdx
Hard Disk (SCSI):/dev/hdx
USB flash drive:/dev/sdx/
30. Differences between diff and file content: diff log1.txt log2.txt
31. passwd Change User Password
32. Change vi/etc/selinux/config to Selinux = disabled (disable selinux)
33. Run the chkconfig command to view and set the auto-start software.
34. How to add a service:
1) The Service script must be placed in the/etc/init. d/directory.
2) chkconfig -- add servicename add this service to the chkconfig tool service list
3) chkconfig -- level 35 mysqld on modify the default Service Startup level
35. netstat view the network status lntup or
Netstat-lntup | grep content
36. Creating a soft connection with ln-s
37. shutdown-h now shut down immediately (frequently used in production)
Shutdown-h + 1 minute later shutdown
Poweroff immediately stops the system and power off
Reboot restart
38. chown (change owner) command used to change file or directory permissions
Groupadd Add User Group (useradd cai-g cai_home Add User cai belongs to cai_home user group)
R = 4, w = 2, x = 1
Readable, writable, and executable
38. fdisk-l view disk status
Fdisk/dev/sdb directly partitioning sdb
39. lsof-I: 52113 check port running status
40. view the showmount-e server nfs
Showmount-
View showmount-e NFSIP Client