Common linux commands
Pwd: Query the current directory
'/'Indicates the root directory./root is not the root directory. '.'Indicates the current directory. '..'Indicates the upper directory
Cd: Change directory. Switch the directory.Cd/: Switch to the root directory.Cd ..: Return to the upper-level directory. Tab auto-completion.
Ls: View the files or directories in the current directory.
Ls-l: View the following details: drwxr-xr-x 2 cyborg 4096 Jun 1 Desktop
Drwxr-xr-x (d: Directory type. Rwx: permission, Group 1: owner; Group 2: group; Group 3: Other users) 2 (number of file hard links)
Cyborg (owner) cyborg (Group) 4096 (size, in byte bytes) Jun (modification time) Desktop.
Ls-lh: H = human, user-friendly display list.
Ls-: View all (including hidden)Ls-l Folder/: You do not need to go to view files or directories in the folder.
Touch. test: Create a file named. test to hide the empty file. Empty folders also occupy 4 k of capacity ).
Mkdir: Create a directory.Mkdir-p cn/shandong/jinan: Recursively create a bunch of directories at a time
Vim test: Create a document named test.
Cat test: View the file content.-N: Display row number-T: Do not display tabsMerge: Cat new1 new2 new3> fly.rar
More test: A little bit, press enter to jump to a line or space to jump to a page, q to exit.LessTest: more advanced Edition
TailTest: Check the last few lines.-Number: set the number of lines to be displayed.-f is used to view the trial files of other processes. It is applicable to monitoring logs.
HeadTest: the first few lines are the same as those of tail, but the-f function is not available.
Mv:Move
Tree folder name: View the folder Tree Structure
Man command name: View help, orCommand name -- help or help command name: View built-in commands
Cp: Copy and paste all in one;Cp-RRecursive copy inside the Directory
Find/-name 'yum. Log': Find the yum. log file from the root (/) directory.'*. Log'Wildcard, the path can be written according to the actual situation, such as find/var/-name 'index. php'
Find/-size + 10 M | xargs ls-lhFind a file larger than 10 MB and view the details of the result
> File name: Clear files
Grep-n hello yum. log: Locate the hello string-n in yum. log and display the row number;-VA: excluding;-C: Displays only the total number of matching rows;-E:Multiple matches (OR) such as grep-e a-e B-e c file1 are equivalentGrep [abc] file1EquivalentGrep [a-c] file1
Wc file name: Statistical Return: number of rows, number of words, number of bytes, file name
Dd: Disk dump, for example, dd if1_1.txt bs = 1 skip = 364 of1_new.txt
Verify md5:Md5sum fly.rarCheck sha:Shasum fly.rar
More elegant restart:Init 6
Sensors:View Temperature
Modify ip Address:Sudo ipconfig eth0 192.168.18.128
CreateSoft link: A real file. Only the inode numbers of The Link file of the source file are different. Create ln-s data sl_data.
CreateHard Link: The same as the source file, inode. Create: ln data hl_data
Rm-f: Force DeleteRmdir: Delete directoryRm-ri my_dir: Recursively Delete and askRm-rf my_dir: Delete all at once
File Name: View File Types
Ps: Monitor processes at specific time pointsTop: Real-time MonitoringKill pid: Try to terminate the processKillallProcess name (wildcard characters supported)
Top: wa indicates the cpu I/O. If it is busy, it is either a network port or a hard disk; id indicates idle; mem total free = free + buffer + cache
Mount:Mount: the list of devices mounted by the system is output by default.Mount/dev/sdb1(Device)/Media/disk(Mount point ).Umount path or device: Unmount. You must unmount the mobile device before removing it.
Df-h: View disk usage.Du: View the usage of a specific directory-c: display the total size of all columns;-h: user-friendly
Tar-zcvfXxx.tar.gz or tgz a.txt B .txt c.txt: package.
Tar-zxvfXxx.tar: Extract
Gzip*. Txt: compressed to gz (batch conversion of wildcards is supported );Gzcat: View the content of gz text.Gunzip: Decompress the gz File
/Etc/passwd: Root: x: 0: 0: root:/bin/bash indicates the login Username: Password: UID: Group ID: remarks field: Home directory location: default shell
The password is stored in/Etc/shadowMedium
Useradd: Add a user;Userdel-r xx: Delete a user;Usermod: Modify/etc/passwd ConfigurationPasswd xxx: Change your password to xxx
Chpasswd <users.txt(Users content is userid: pass)
Chsh-s/bin/csh xxModify default shellChfnModify remarksFinger xxView user information
/Etc/group: Group files
GoupeaddCreate a new groupUsermod-G ga ua: Add the ua user to the group gaGroupmodModify group-g modify GID-n modify group name; for example: goupemod-n gb ga change group name ga to gb
For files, the full limit is 666 (all users rw -)
For directories, the full value is 777 (all users rwx)
R: 4 w: 2 x: 1-: 0
ChmodChange permission: Method 1: chmod 777 file1 Method 2: chmod [ugoa] [[+-=] [rwxXstugo]
Method 2 parameter description:
Parameter 1: u user, g group, o others; a all parameters 2: Add + remove on existing basis-set to =
Parameter 3: X: if the object is a directory or an existing execution permission, grant the execution permission; s: re-set UID or GID during runtime; t: keep the file or directory;
U: Set the permission to the same as the owner; g: Set the permission to the same as the group; o: Set the permission to the same as other users.
Chown: Change link usage: chown owner [. group] file
For example, chown dan file1 changes the owner chown dan. ga file2 and changes the owner and group chown. ga file3 at the same time.ChgrpGa file4: Change the 'default' Group of the file
Free-m: View memory remaining