Basic Linux Basics Command 1

Source: Internet
Author: User
Tags log log parent directory file permissions

Basic commands
First, the basic principles of Linux:
1, consisting of a small program with a single purpose; a combination of small procedures to complete complex tasks;
2, all documents;
3, try to avoid capturing the user interface; (try not to interact with the user, is a program one but start to run, there is no need for users to do anything, such as the LS command, ifconfig command)
4, the configuration file is saved in plain text format;
User interface: A unique application that provides a mechanism for users to launch other applications
CLI: Command prompt, user input command
Shell:sh,csh,ksh,bash,zsh,tcsh
GUI: graphical interface user interface, usually click to launch the application
Gnome:c language
Kde:c++
XFCE: Lightweight
Terminal type: TTY command to view
Virtual Terminal (tty1-6)/dev/tty# #号为数字号码
Pseudo terminal (SSH, telnet connection is called Pseudo terminal or terminal opened under graphical interface)/dev/pts/#
Physical terminal (console)/dev/console
Serial terminal (print out characters at a specific rate and connect via serial interface)/dev/ttys#
Graphics Terminal: You can start startx with the StartX command--: 2 You can start a second graphics terminal
5, two, the form of command
Command format:
Command option Parameters
Options:
Short options:-Fast and easy to enter
Multiple options can be combined:-a-b =-ab
Long options:--meaning clear
Parameters: The Action object of the command
Commands are divided into internal commands and external commands
Internal command is the command that comes with the system shell
External commands are commands that are generated by installing other programs.
You can see whether the command is internal or external by type: The type command keyword
Ii. ways to help:
1. Internal commands can be passed: Help Command example:
2, external command can pass: command--help for example: LS--help
3, can get command help through the man command: For example: Man CD Whatis see which man chapters
4, you can get command help through the info command: for example: Info CD
5, through Baidu \google and other search engines can seek help
6, can download a linux chinese command Daquan
Example of command: LS
Ls-l: Long format
File type: Can be viewed using the file command
-: Normal file (f)
D: Catalog file
B: Block device files (blocks) are interface devices that store data for system access, and in simple terms, hard drives
C: Character device file (character) is a serial port interface device, such as keyboard, mouse, etc.
L: Symbolic Link files (symbolic link file)
P: the command Pipe file (pipe) is a special type of file that is primarily intended to resolve errors caused by multiple programs accessing a file at the same time
S: Socket file (socket) This type of file is typically used in network data connections.
We can start a program to listen to the client's requirements, and the client can communicate through the socket.
This type of file is most often seen in the/var/run directory. Example of command: LS
Ls-l: Long format
File type: Can be viewed using the file command
-: Normal file (f)
D: Catalog file
B: Block device files (blocks) are interface devices that store data for system access, and in simple terms, hard drives
C: Character device file (character) is a serial port interface device, such as keyboard, mouse, etc.
L: Symbolic Link files (symbolic link file)
P: the command Pipe file (pipe) is a special type of file that is primarily intended to resolve errors caused by multiple programs accessing a file at the same time
S: Socket file (socket) This type of file is typically used in network data connections.
We can start a program to listen to the client's requirements, and the client can communicate through the socket.
This type of file is most often seen in the/var/run directory.
File permissions: 9-bit, every 3-bit group, each group: rwx (Read, write, execute), r--
Number of hard links to files
Owner of the file
Genus Group of files
File size (size), in bytes
Timestamp (timestamp): Last Modified Time (mtime), you can use the Stat command to see
Access: Access Atime is changed when reading a file or executing a file
Modified: Modify, Mtime is changed when writing to a file with changes to the contents of the file
Changed: Change, ctime metadata, metadata state change is changed when writing to a file, changing owner, permission, or link settings with inode content changes
LS-H: Do unit conversions
Ls-a: Show hidden files starting with.
. Represents the current directory
.. Represents the parent directory
LS-LD: Show directory itself properties
Ls-li:index node, inode
LS-LR: Reverse Display
LS-LR: Recursive (recursive) display
Iv. File System
Fhs:filesystem hierarchy standard file system level standards
Rootfs: Root file System/
/boot: System startup related static files, such as kernel, INITRD or INITRAMFS, and grub (bootloader)
/dev: Device files for all devices, device files also known as special files (metadata only, no data, device entry)
Device files:
Block devices: Random access, data blocks
Character Devices: Linear access, by character
Device number: The primary device number (major) and the secondary device number (minor) have the same device number as the same device (using the same driver)
To view the main device number of a device driver that is currently loaded by using the Cat/proc/devices command
Example: Ls-l/dev/sr0
BRW-RW----1 root cdrom 11, 0 April 1 08:59/dev/sr0 11 Main device number, 0 is secondary device number
/etc: Configuration file
Home directory for normal users, home directory for each user usually defaults to/home/username
/root: Administrator's home directory;
/lib: Basic shared libraries and kernel modules
A library file is essentially a binary form of executable code that can be loaded into memory by the operating system.
static libraries,. A static library code has been loaded into the executable program during the compilation process, so the volume is large
The code for the dynamic library,. dll,. So shared library is loaded into memory when the executable is running, only simple references during compilation, so the code is small.
/lib/modules: Kernel module files
/media: To move a device's mount point directory, such as a CD-ROM, USB flash drive
/MNT: mount point directory, additional temporary file system
/OPT: Optional directory, installation directory for third-party programs
/proc: Virtual file system for kernel and process information, pseudo file system, kernel mapping file, only in memory, it provides the interface to the operation of accessing system kernel data in the way of file system.
/sys: Pseudo file system, hardware device information virtual file system interface, and hardware device-related property mapping file, which is the global device architecture, contains all the found registered on various bus of various physical devices
/tmp: Temp file,/var/tmp
/var: a variable file
/var/log Log Information
/bin: Basic user Command binary program for all users
/sbin: System binaries, typically administrative commands
Core binary commands that may be used by the/bin and/sbin systems themselves when they start up and run
/usr:shared, Read-only (Unix system Resource, an abbreviation for UNIX systems resources), not suitable for additional tools placed in/bin or/etc directories
/usr/bin commands that are used by most users
/usr/sbin non-core system commands
/usr/bin and/usr/sbin when the system is running, the user may use the command to complete an operation
/usr/lib
/usr/local: The main storage of those manually installed software
/usr/local/bin
/usr/local/sbin
/usr/local/lib
/usr/share/man/usr/share/doc Help Files
Components of the application:
binary files, library files, configuration files, Help files
Path:
Absolute path: An absolute path is the way in which an input path begins with "/"
Relative path: usually with "." or ".." All that starts with a relative path
Each absolute path can be cut into 2 parts:
Base name: Basename/path/to/somewhere result is somewhere
Directory Name: dirname/path/to/somewhere result is/path/to
V. View server basic information:
Cat/proc/cpuinfo Viewing CPU information
Cat/proc/meminfo Viewing memory information
Free to view memory usage
Uptime Monitoring CPU Status
Uname-r Viewing the kernel version
Cat/etc/redhat-release Viewing release information
Hostname Viewing host names
Hostnamectl set-hostname SUNDAY-CENTOS7 Setting the host name to SUNDAY-CENTOS7, the configuration file will be changed to take effect permanently
Ip
Addr Viewing IP information
Ifconfig Viewing IP information
NETSTAT-ANPT | grep [port number or service name] View network connection information, routing table, etc., commonly used to view port open condition
Ethtool eth0 viewing NIC information
Fdisk-l Viewing hard disk information
DF-HT Viewing device mount information
Vi. Other common commands
1, the basic operation of the directory command:
Tree chart lists the contents of the table of contents
-C adds color to the list of files and directories, making it easy to differentiate between types
Ls
View Catalog Contents
CD Switch Directory
PWD View current directory location
mkdir Create a directory,
-P Create a multilevel directory
-Z Set security context, valid when setting SELinux
RmDir: Delete Empty directory
RM: You can delete one or more files or directories in a directory, or you can delete a directory and all of its subordinate files and subdirectories. For linked files, only the entire linked file is deleted, and the original file remains unchanged.
-F Force Delete
-R or-R: Recursive processing, all files under the specified directory are processed in conjunction with subdirectories;
The MV is used to rename a file or directory, or to move a file from one directory to another.
CP is used to copy one or more source files or directories to a specified destination file or directory.
-A: The effect of this parameter is the same as specifying the "-DPR" parameter;
-D: When a symbolic connection is copied, the destination file or directory is also established as a symbolic connection and points to the original file or directory connected to the source file or directory;
-F: Forcibly copy the file or directory, regardless of whether the destination file or directory already exists;
-I: Ask the user before overwriting existing files;
-P: Preserves the properties of the source file or directory;
-R/R: Recursive processing, all files under the specified directory are processed together with subdirectories;
2. File view and Processing commands:
Touch Create File
Touch changes the file's Atime and Mtime (CTime will change)
-A change Atime
-M Change Mtime
Stat View the properties and metadata of a file
Cat used to display the contents of a file
Cat M1 m2 > file (merging Files ml and m2 into file files)
-N Display Line number
Generate files with standard input testfile
[email protected] ~]# cat > Testfile << EOF

Hello world!
Wellcome to China
Eof
TAC Reverse View File contents
More displays the contents of the file, one screen at a time
Press SPACE key: Displays the next screen of text.
Press Enier: Displays only the next line of text.
Press h: Displays the help screen with relevant help information.
Press the B key: Displays the previous screen content.
Press the Q key: Exit command.
Less split screen up and down to browse the contents of the file, with the PageUp key up page, with the PageDown key down page
Head displays the beginning of the file
Tail show end of file
-F Monitor A file change
Date Time
Date, clock, Hwclock,
Cal Open Calendar
BC Open Calculator
Number of rows in WC statistics file \ Number of words \ Characters
-L Number of rows
-W Number of words
-C Character Count
Size of DU statistics files and directories
-S summary display size
-H easy-to-read format display
Alias alias A= ' mount/dev/cdrom/me
Seven, Vim
VIM: Three modes: Command mode, insert mode, last line mode

  1. I i a a o O enter into insert mode
    2: Last line mode W save Q exit Wq Save and Exit! Mandatory three can be used in combination
    3. Command line mode: DD delete [Cut] yy copy [n]yy multi-line copy p paste
    4. Make vim display line number, create a. vimrc file below/root, open with Vim, add set Nu, Wq save exit
    Operation in command mode:
    1, page Page DOWN or ctrl+f down a full page of Contents page UP or ctrl+b up a full page of content
    2. Quick Jump Home button or "^", number "0" Jump to beginning End or "$" key to jump to end of line
    3. Quick jump 1G or GG jump to the first line of the file
    G jump to the end of the file line
    #G Jump to line # in a file
    4, line number display: Set NU display line number in editor
    : Set Nonu cancels the line number display in the editor
    5. Delete x or del delete single character at cursor
    DD deletes the current cursor in the row
    DD Delete the # line content that starts at the cursor
    d^ Delete all characters before the current cursor to the beginning of the line
    d$ Delete all characters at the end of the line at the current cursor
    6, copy yy copy the contents of the entire row of the current line to the Clipboard
    YY Copy # line content starting at cursor
    7. Paste P lowercase to paste the contents of the buffer after the cursor position
    P-caps pasted before the cursor position
    8. Find/word from top to bottom in file find string "word"
    Word bottom finds the string "word" in a file
    N locates the next matching found string
    N locates the previous matched lookup string
    9. Cancel Operation u Press Cancel the most recent operation
    Double-Press the U key multiple times to redo a multi-step operation
    U is used to cancel all edits made to the current line
    10. Save Exit ZZ Save current file contents and Exit VI Editor
    11, visual block operation interface Ctrl + V into the block operation interface
    Top, bottom, left, and right arrows to select blocks
    Y Copy the selected fast
    P Paste the selected fast
    Last-line mode operation:
    1, Save the file: W Save the modified content
    : W/root/newfile Save As other files
    2, exit Vi:q not modified exit
    : q! Discard changes to the contents of the file and Exit VI
    3. Save the file exit Vi:wq Save the modified content and exit
    4. Open new file: E ~/install.log open a new file for editing
    5. Read the contents of other files: R/etc/filesystems read the contents of other files in the current file
    6. Replace: S/old/new Replace the first character "old" string found in the current line with "new"
    : S/old/new/g replaces all the string "old" found in the current row with "new"
    : #,# s/old/new/g Replace all strings "old" with "new" in the line number "#,#" range
    :% s/old/new/g Replace all strings "old" with "new" for the entire file range
    : s/old/new/c the C command at the end of the Replace command, prompting the user to confirm each substitution action

Basic Linux Basics Command 1

Related Article

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.