1. Introduction to Linux Commands
Linux commands are commands for managing a Linux system. For Linux systems, both the CPU, the memory, the disk drive, the keyboard, the mouse, and the user are all files. Linux System Management commands are the core of its normal operation. There are two types of Linux commands in the system: built-in shell commands and Linux commands.
The first thing to know is a noun "console console", which is a human-computer interface that we usually see using the character-manipulation interface. We say the console command, which is an operating system command that is entered via the character interface.
Then what is the shell, in fact the shell is a command interpreter that interprets the commands entered by the user and sends them to the kernel. In addition, the shell has its own programming language for editing commands, which allows the user to write a program composed of shell commands to organize a large number of shell commands into a script file for automated processing purposes.
2, User management class command
Add User: Useradd [options] User name Eg:useradd xiaoming
Delete User: Userdel [options] User name Eg:userdel-r xiaoming; " -R "means to delete the user xiaoming directory under the/home directory
Change Password: passwd [options] User name eg:passwd xiaoming
Switch User: Su [option] User name eg:su-xiaoming; the option "-" means that the user's environment variables are also brought in at the same time when switching to the appropriate user.
Add user group: Groupadd [Options] [user group name] Eg:groupadd group1
Delete user group: Groupdel [user group name] Eg:groupdel group1
3. File and Directory class commands
View catalog: LS [options] [directory or file] eg:ls/home ls-a/home contains hidden files Ls-l/home can also list details with LL
Change Working directory: CD directory name "..." For the top level directory, CD-: Indicates fallback to the last directory.
Copy File/directory: CP [option] source file/directory destination file/directory eg: file-cp/home/test/tmp/directory: Cp-r/home/dim/tmp/
Move or rename: MV [options] source file/directory destination file/directory eg: Mobile: mv./txt/root/renamed: MV./txt./txt1
Delete file or directory: RM [options] file or directory eg: file: Rm/home/txt directory: Rm-r/HOME/RMB; Rm-rf/usr/local/jdle where-F is not prompt for deletion
Change file permissions: chmod [who] [+|-|=] [mode] File name
Who:u represents the file owner, G represents the user of the same group as the file owner, O represents the other user, and a: represents all users (system default) Eg:chmod G+w hello.c for hello.c to indicate that the same group of users with the file owner has writable permissions to hello.c.
Create directory: mkdir [options] Directory name Eg:mkdir/home/workdir mkdir-p/home/dir1/dir, when the directory is created, if Dir1 does not exist, it will automatically create the Dir1 directory.
View Directory Size: Du directory name
View current path: pwd
Create file: Touch file name
4, Compression Packaging class command
The extension is usually *.tar;*.tar.gz;*.tgz;*.gz;*.bz2; different suffixes of the file, using different commands to handle
*.gz<--->gzip;*.bz2<--->bzip2;*.tar<--->tar;*.tar.gz<--->tar after it is packaged and then gzip compressed. *.tar.bz2<--->tar command to package, then bzip2 compressed files.
gzip [option] File name eg:gzip/root/config.cfg to compressed file; gzip-d/root/config.cfg.gz to unzip the file.
bZIP Same as Gzip
Package compression Tar:tar [options] directory or file; Package is to change a directory into a file, but its size has not changed much, then you can compress the packaged files. Eg:tar CVF tmp.tar/tmp Package The directory as a file. Tar xvf Tmp.tar unpack the packaged files. Tar Cvzf tmp.tar.gz/tmp Package and compress the directory into a file.
Tar xvzf tmp.tar.gz unzip the file.
5. Disk Management class commands
Load disc: Mount [options] Device name mount directory eg;mount/dev/cdrom/mnt/(when a disc is inserted into a peripheral disk device, only one file is generated and the file cannot be accessed, the file should be converted to a directory, remember to make the disc connected).
Unmount disc: Umount mount directory eg:umount/mnt (to make sure the user has launched the/MNT directory)
View disk: DF [option] Eg;df-hl
Create a new file: Touch file name
File connection ln:ln [options] file name link name eg: Hard link: ln oldfile hlink Soft connection: ln-s oldfile slink Soft and hard link difference: After the source file is deleted, the hard link has the content, and the soft connection will appear red.
6. Find commands
Find a file or directory: Find lookup path-name file name eg:find/mnt/-name Install.log
Find string: grep "string" path [option] eg:grep "Hello"./-rn (look for the file containing the string hello under the current path) grep "he*"./-rn (looking for a file containing a string starting with "he" in the current path).
7. Process Management Class command
View process: PS [option] eg:ps aux
Kill process: Kill [options] pid
View Memory: Free [options]
CPU occupancy; top [options]
8. Miscellaneous command Daquan
Software Management: RPM [options] [package] eg:rpm-ivh/mnt/packages/xinetd-... (Install the file)
RPM-QA viewing all installed packages in the system
RPM-E xinetd-... Uninstall the file.
Pipeline operations: Command 1 | Command 2 Eg:rpm-qa | grep tar
View Help: Man command name
Shut down the Linux system: shutdown [Options] Time Eg;shutdown now.
Linux commands in a detailed