pwd: Query the current directory
'~' represents your own home directory
'/' represents the root directory, and /root is not the root directory. '.' represents the current directory. '..' represents the upper directory
cd:change directory, switch directories. cd /: Switch to the root directory. cd ..: Return to the previous directory. Tab auto-completion.
ls: View files or directories in the current directory.
ls -l:View the following details: drwxr-xr-x 2 cyborg cyborg 4096 Jun 1 10:45 Desktop
drwxr- xr-x (d: type is directory. rwx: permissions, group 1: owner; group 2: group; group 3: other users) 2 (number of file hard links)
cyborg (owner) cyborg (group) 4096 (size in bytes) Jun 1 10:45 (modification time) Desktop.
ls -lh:h=human, humanized display list.
ls -a: View all (including hidden) ls -l folder/: No need to enter to view the files or directories in the folder
touch .test: Create a file named .test to hide the empty file. Empty folders also occupy capacity (4k).
mkdir:Create a directory. mkdir -p cn/shandong/jinan: Recursively create a bunch of directories at once
##vim test: Create A document named test.
cat test: View the file content. -n: Display line number -T: Do not display tab character Merge: cat new1 new2 new3 > fly.rar
more test: Read a little bit, press Enter to jump a line or space to jump a page, q to exit. less test: the advanced version of more
#tail test: View the last few lines, -Number: Settings Display the number of lines; -f View when other processes try the file, suitable for monitoring logs
head test: the first few lines, the same as tail , but no -f function
mv:move move
tree Folder name : View the tree structure of the folder
man Command name : View help, or Command name --help or help command Name: View built-in commands
cp: Copy and paste in one;cp -R Recursively copy inside the directory
find / -name 'yum.log': Start looking for the yum.log file from the root (/) directory, or '*.log' Wildcard, the path can be written according to the actual situation, such as find /var/ -name 'index.php'
find / -size +10M | xargs ls -lh Find files larger than 10M and view the detailed information of the results
>File name: Clear the file
grep -n hello yum.log: Locate the hello string -n in yum.log and display the line number; -v a: does not contain a; -c:Only display the total number of matched lines; -e :Multiple matches (or) such as: grep -e a -e b -e c file1 Equivalent to grep [abc] file1 Equivalent to grep [a-c] file1
wc file name: Statistics return: number of lines, number of words, number of bytes, file name
dd: means disk dump, such as: dd if=1.txt bs=1 skip=364 of=new.txt
Verify md5:md5sum fly.rar Verify sha: shasum fly.rar
Restart more gracefully:init 6
sensors:View temperature
Modify ip:sudo ipconfig eth0 192.168.18.128
CreateSoft link: A real file, only if the inode number of the link file of the source file is different, create: ln -s data sl_data
CreateHard link: It is the same file as the source file, with the same inode. Create: ln data hl_data
##rm -f: force deletion rmdir: delete directory rm -ri my_dir:Recursive deletion and query rm -rf my_dir:Delete all in one go
file File name: View file type
ps: Monitor the process at a specific point in time top: Real-time monitoring kill pid: Terminate the process as much as possible killall Process name (supports wildcards)
Top: wa Indicates the I/O of the CPU. If it is busy, it is either the network port or the hard disk; id means idle; mem total free=free+buffer+cachemount:Mount, the default output is the list of devices mounted by the system. mount /dev/sdb1(device) /media/disk(mount point). umount path or device: Unmount, removable devices must be unmounted first and then removed.
df -h: Check the usage of mounted disk. du: View the usage of a specific directory -c: Display the total size of all listed files; -h: Humanized
tar -zcvf xxx.tar.gz or tgz a.txt b.txt c.txt: package.
tar -zxvf xxx.tar: decompress
gzip *.txt: compress into gz (wildcard batch conversion is possible); gzcat: View the gz text content. gunzip: Decompress the gz file
/etc/passwd: root:x:0:0:root: /root:/bin/bash means login username: Password: UID: Group ID: Remarks field: Home directory location: Default shell
Password is stored in/etc/shadow中
useradd: Add user; userdel -r xx: Delete user; usermod: Modify the /etc/passwd configuration passwd xxx: Modify your password to xxx
chpasswd < users.txt (The content in users is userid:pass)
##chsh -s /bin/csh xx Modify Default shell chfnModify remarks finger xxView user information
/etc/group :Group file
goupeadd Create a new group usermod -G ga ua:Put Add user ua to group ga groupmod Modify group -g Modify GID -n Modify group name; for example: goupemod -n gb ga Change the group name ga to gbFor files, the full permission value is 666 (all users rw-)
For directories, the full permission value is 777 (all users rwx)
r: 4 w:2 x:1 -:0
chmod Change permissions: Method 1: chmod 777 file1 Method 2: chmod [ugoa] [[+-=] [rwxXstugo]]Method 2 parameter description:
Parameter 1: u user; g group; o other; a all Parameter 2: Add + remove on the existing basis - set to =
Parameter 3:
u: Set the permissions to be the same as the owner; g: Set the permissions to be the same as the group; o: Set the permissions to be the same as other users
chown: Change ownership usage: chown owner[.group] file
For example: chown dan file1 changes the owner chown dan.ga file2 changes the owner and group at the same time chown .ga file3 changes the group chgrp ga file4: Change the file's 'default' group
free -m: Check the remaining memory
Communication instructions:
rusers: Check who is on the machine
ku is easier to use than Russers and provides finger, talk, write, mail and other functions
mesg y accepts messages from other users ( System default)
mesg n Deny other user messages
talk Online pairing For a chat system, use ctalk
# to give an example: if you want to chat with hijack, hijack is using the computer 192.168.1.3, just talk hijack@192.168.1.3, provided that hijack is online and the other party can mesg yaccept or mesg nrejectfinger yes Query the local machine or remote machine user brief information, for example: finger hijack@192.168.1.3
##rlogin,rsh,telnet Remote login (login)
System information:quota -v Check your available disks Space size (unit: KB) and number of files
date Current date and time
who Check who are currently using the same machine as you and their login time and location
w Check the detailed status of those currently logged on
whoami View your account name
groups [Account name] View someone’s group
passwd Change password
chsh Change your login shell
chfn Change your full name (not your account name)
cal Print out the monthly or annual calendar
tty Display the name of the current terminal
history Check the commands you have issued
nslookup Query the hostname and IP to the Name Server
Process controlkill Stop the processing program. Usually use the ps command to check the Process ID first, and then kill it. kill -9 immediately stops a process. kill -9 -1 kills all the processes belonging to you in the system. The process
jobs lists the jobs currently being executed
fg will be aborted Job returns to the foreground and continues execution
bg Background execution
at Execute at the specified time Command
batch Execute multiple commands in sequence
crontab Requires the system to execute specific commands regularly Command
nice Adjust the priority of the process
nohup Make the process continue after logout Execute
pipe and input and output redirectionStandard input (stdin): usually the keyboard, you can use< to redirect. Example: mail b82000 < myfile can send the myfile file to b82000
Standard output (stdout): usually the screen, use> to redirect, use >> The result can be appended to the end of the file. Example: finger b81045 > myfile can write the query results on the myfile file.
Pipeline: The symbol of the pipe is "|", which is used to connect two commands. The output of the command on the left of "|" serves as the input of the command on the right of "|". For example: ls -l .. | more can output the contents of the upper-level directory page by page; who | grep b.503 | sort| more can sort the list of electrical engineering students currently online and output it in pages.
The above is the detailed content of linux command list. For more information, please follow other related articles on the PHP Chinese website!