Study note _ linux-Basic linux commands

Source: Internet
Author: User
Tags unpack disk usage

Command operation
Commands in Linux
Shell Command Interpreter
Is a bridge between the kernel and the user, is a command interpreter, cmd in win
Common Shell types
Bsh basic command interpreter
Csh is a C syntax style. It provides command history, alias, file replacement, and job control functions.
Ksh advantages
Bash is currently used in Linux
Zsh is based on interactive operations
Bash
The default Shell program used in Linux
/Bin/bash
Common Bash Functions
Command history
Repeat input commands to reduce input
Clearly alias
You can name a complex command alias as a simple name.
Standard Input/Output and redirection
Use a file to describe system hardware and devices
MPs queue operations
Provides a mechanism for collaboration
Command line format
Command word [Option] [parameter]
Command name
Option to adjust the specific function of the command, determines how the command is executed
Can be used together, such as-ld
Parameters are usually file names, directories, user names, and so on.
Get Command help
Help Command
Used to view the information of Shell internal commands
"-- Help" option
Used to display help information of command words
Man command
Show online help in full screen
Info command
More detailed than man
Common commands
Directory operations
Ls display directory content
Parameter [directory name]
Option
-L display in long format
-A: displays all subdirectories and file information.
-D: displays the directory attributes.
-R: displays all contents of the specified directory and subdirectory.
Parameter directory name
Use wildcards
? Match
* Match any number
// ====================================
# Ls-lh/etc/ns * conf
Cd switch working directory
Parameter [target directory name], no parameter returned to home directory
Path
The absolute path starts with a slash (/).
The relative path starts with ".", indicating that it starts with the current directory.
Starting with ".." indicates starting with the parent directory
To ~ Start with the user name, indicating that it starts with the user's directory
Pwd displays the user's current working directory
Create a directory in mkdir
Parameter [directory name]
Option
-P: Create a multi-level directory
Du
Parameter [directory name]
Option
-A: the disk usage statistics include the files used.
-H humanized Display Structure
-S: only count the space occupied by each parameter.
File Operations
Common File
Text Files
Binary files
Directory files
Device Files
Block Device
Character Device
File Operation Command description
Touch creates a new file
Parameter [file name], separated ""
Cp Value assignment file or directory
Parameter [source file path] [target file directory]
Option
-F force copy, Overwrite
-I remind the user to confirm and overwrite
-P: keep original attributes unchanged
-R: Copy files and subdirectories
Rm deletes a file or a stranger
Parameter [deleted file]
Option
-F: Force Delete directly
-I remind the user to confirm
-R: Delete the entire directory.
Mv mobile files or directories
Parameter [source file path] [target file directory]
Option
Find a file or directory
Parameter [search range] [Search Condition expression]
Option
-Name: search by name
-Size: search by size
-User security owner search
-Type: search by file type
F common file, d directory, B fast device, c character device
Which
Parameter [program or command name]
Option
-A continues searching after the first one
File View file Type
Parameter [target file name]
Ln build shortcuts
Link file
Symbolic Link
Hard links cannot be created for directories or across partitions
Parameter source file directory connection file directory
Option
-S
File Content operations
Cat display file content
Parameter file name
Note: If the content of the CAT command file is too large, only the following parts may be displayed.
More/less display file content by PAGE
Press enter to scroll through the lines
Background screen with Space
B Jian goes up one screen
Q key exit
Parameter file name
Grep search and filter file content
Parameter Search Condition target file
Option
-I case insensitive when searching content
-V reverse lookup
Vi full-screen text editing
Three working modes
Command mode
Delete, assign, and paste content
Input mode
Enter the file content and modify the content. INSERT prompt information
Last Row Mode
Set the editing environment: Prompt
Basic commands in command mode
Mode switch
Input to the command: a, I, o key; command line Input: Esc
From the last line to the command: Esc key; from the command to the last line :":"
Common keys
A inserts content after the current cursor position
A inserts content at the end of the row where the current cursor is located
I insert content before the current cursor position
I insert content at the beginning of the row where the current cursor is located
O Insert a new line behind the row where the cursor is located
O Insert a new line before the row where the cursor is located
Move cursor
Direction key
Page Down and Page Up
In-row jump Home/0 rows first, End/$ row End
Last line G
Copy, delete, and other operations
Undo once u
Undo All U from the current row
Save and exit ZZ
Basic operations in last row Mode
: W save the file
: Q: exit the editor.
: Q! Force exit
: Wq/: x save and exit
: E open a new file and edit it.
: R reads other file content
Compression and Archiving
Compression command tools: gzip and bizp2
Archive command tool: tar
Tar archive command
Syntax tar [Option] source file or directory for archiving file names
Option description
-C: Create a package file in .tar format
-C: unpackage is the target folder specified for release.
-F indicates to use the archive destination folder
-J calls the bzip2 program for compression or decompression
-P indicates the file and directory permissions reserved when the package is opened.
-T list to view files in the package
-V: Output details
-X unpack the package file in .tar format
-Z calls the gzip program for compression or decompression
Unpack tar [Option] archive file name [-C target]
Compression command
Syntax gzip-9 tfile.exe
Gzip
Suggested use of extension name .gz
Bzip2
Suggestion: Use the extension name .bz2
-9 can increase the compression ratio,-d can be decompressed
User and group account
User Account
Superuser
Root User
Common User
Created by the Administrator and has full permissions on the Home Directory
Program user
Low-Permission user account, only maintain program running
Group Account
The permissions set for the group account apply to each user account.
Manage commands
Useradd Add User
Useradd [Option] User Name
Option description
-U: UID
-D specifies the Account expiration time
-E: Specifies the expiration time.
-G: Specify the basic group name.
-G: specify the name of the additional group.
-M does not create a user directory.
-S: Specifies the user to log on to Sheel.
Userdel delete user
Parameter Username
Option
-R: Delete the Home Directory together.
Passwd Set User Password
Root User manages the password of a specified account
Ordinary users can only change their own passwords
-D. Clear the specified password.
-L lock the user account
-S: view User Accounts
-U to unlock a user account
Groupadd add group account
Parameter group account life
Option
-G: Specifies the group account ID.
Groupdel Delete group account
Parameter group account life
Gpasswd Add/delete group members
Parameter user group account
Option
-A: add an idiom.
-D. delete a member.
-M: add multiple members.

Other common commands
Shutdown delay is the shutdown command
Only the administrator can execute
Parameter restart time (for example, now, + 15 things minutes later)
Option description
-R restart
-H Shutdown
-C. Cancel the operation.
Halt quick shutdown command
Option description
-P shutdown and power off the host
Reboot system

Netstat view Network Configuration
Option description
-A: displays the addresses of all network connections.
-N indicates the address and port number using numbers.
-P displays the process information of each network protocol at the same time.
-T displays TCP-related network protocols
-U: displays UDP-related network information.
-R: view the route table information of the system.
Mount mounted to the file system
Mount View File Mounting Information
Mount [-t file system type] [-o mounting option] <device or network shared directory> <mount point directory>
Umount unmount the mounted file system
Parameter device location or mount point location
File/directory attributes
Permission
Read write executable
Permission character file directory
R/4 read and view directory content
W/2 writable and modified directory content
X/1 run the cd command to enter the directory.
File Information Representation
File Type of the first character
2-4 Owner permissions on files
Access Permissions of Group 5-7 users
Access Permissions of 8-10 Users
Permission settings
Syntax 1
Chmod [ugoa] [+-=] [rwx] file directory
[Ugoa] user category for which this permission is set
U main file
Users in the g group
O stands for any other user
A Represents the user used
[+-=] Set permission operation actions
+ Add permissions
-Permission reduction
+ Set the permission
[Rwx] Permission character combination
Syntax 2
Chmod nnn file or directory
Attribution
Set attribution
Chown owner [: [group] file or directory
Set owner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.