Introduction to Linux distributions, getting Started with Linux system basics, Linux command Help, Linux basic commands

Source: Internet
Author: User
Tags parent directory readable syslog


Basic knowledge of computer playing:
CPU (operator, Controller), memory, I/O (input device, output device)

Program running mode: User space: user space, us (executable ordinary instructions) Kernel space: system space (executable privileged instructions) POS: Postable Operating System Portable operating system POSIX Portable operating system specification Running program format: Windows: EXE , Library file dll (dynamic link library) Linux: ELF, library file so (shared object) program: instruction + data instruction: read-only data: read-write program: algorithm + data structure library call, system call: Programs allowed to be called; malloc () applies for memory space; free () releases memory space; programming language assembly language: microcode programming (system-level programmer) Certain hardware-specific code and driver development in the system; advanced Language: C, C ++ system level application, driver advanced application: java, python, php application Linux distribution: slackware: suse: sles suse enterprise edition opensuse debian: ubuntu mint redhat: rhel: redhat enterprise linux enterprise version releases a new version every 18 months CentOS: rhel compatible format fedora: personal desktop version testing new software programs release a new version every 6 months ArchLinux Gentoo LFS: Linux From scratch Android: kernel + busybox + java virtual machine GNU: GPLv2, GPLv3, LGPL (lesser GPL) Apache: apache BSD: bsd





Package Manager:
Rpm:
RHEL, Fedora, SuSE, CentOS
Dpt:
Debian, Ubuntu



Free Software:
Free to use, freely learn and modify, freely distribute, freely create derivative versions



The philosophical thinking of Linux:
1, all documents; almost all resources, including hardware devices, are organized into file formats;
2, consisting of a number of small programs for a single purpose; A program that only implements a function, and does well, the combination of small programs to complete complex tasks;
3, try to avoid interacting with the user; Objective: To implement script programming to automate certain functions;
4, the use of plain text files to save configuration information; target: A text editor used to complete the system configuration function;



How to obtain a release version of CentOS:
Http://mirrors.aliyun.com
Http://mirrors.sohu.com
Http://mirrors.163.com



Terminal:
The user interacts with the host, the device that must use, the terminal equipment

Physical terminal: directly connected to the display and keyboard of this machine: / dev / console virtual terminal: a virtual terminal implemented in software on top of the physical terminal. The six virtual terminals Crtl + Alt + F # started by default in CentOS 6: [1-6] Graphical terminal: a terminal that is virtualized in software and attached to a physical terminal, but additionally provides a desktop environment; device file path: / dev / tty # emulated terminal: a command line interface opened in a graphical interface , Remotely opened interface device files based on ssh protocol or telnet protocol: / dev / pts / # [0, oo) Zero-positive infinity



View current terminal devices: TTY
The command examples are as follows:
[[email protected] ~]# TTY
/dev/pts/2



Interactive interface: After you start the terminal, attach an interactive application to the end device
Gui:
X protocol, Windows Manager, desktop

Desktop: GNOME (C, gtk graphic development library) KDE (C ++, qt graphic development library) XFCE (lightweight desktop) CLI: Shell program: sh (bourn) csh tcsh ksh bash (bourn again shell) follows the GPL agreement zsh display The shell currently in use: #echo $ SHELL [[email protected] ~] # echo $ SHELL / bin / bash shows all shells used by the current system: #cat / etc / shells [[email protected] ~] # cat / etc / shells / bin / sh / bin / bash / sbin / nologin / bin / tcsh / bin / csh / bin / ksh command prompt: prompt [[email protected] ~] # [[email protected] ~]: PS1 prompt: Management Member: # Ordinary user: $ [[email protected] ~] # echo $ PS1 [\ [email protected] \ h \ W] \ $ u: User h: Host name W: Working directory



Command:
Input command, enter
Draw the shell program to find the executable program or code corresponding to the typed command, and analyze it or submit it to the kernel to allocate resources to run it;
Manifested as one or more processes;

There are two types of commands that

 can execute in the shell: The built-in command: The shell comes with, and it is shut down by a command; external command: There is an executable program file under the system path of a file system in the current system which, Whereis [[ Email protected] ~]# which tty/usr/bin/tty [[email protected] ~]# which cat/bin/cat [[Email p] Rotected] ~]# whereis TTY TTY:/usr/bin/tty/usr/share/man/man4/tty.4.gz/usr/share/man/man1/tty.1.gz/usr/share/man/m an1p/tty.1p.gz [[email protected] ~]# whereis cat Cat:/bin/cat/usr/share/man/man1/cat.1.gz/usr/share/man/man 1p/cat.1p.gz differentiate internal or external commands: #type command built-in commands: [[email protected] ~]# type CDCD is a shell builtin external command: [[Email prot Ected] ~]# type Ttytty is hashed (/usr/bin/tty)

 


Run command:
Command format:
Commmand [Options ...] [Arguments parameters ...]
Options: One or more features of the command that the user enables or turns off
short options:-C, for example:-L,-H
Multiple short options can be combined, for example:-L,-H, can be written:-lh
[[email protected] ~]# ls-l-H
Total 72K
-rw-------1 root root 1.3K mar 16:47 anaconda-ks.cfg
drwxr-xr-x 2 root root 4.0K Mar 16:53 Desk Top
-rw-r--r--1 root root 37K mar 16:47 install.log
-rw-r--r--1 root root 3.6K Mar 16:47 install.log.syslog< br>-rw-r--r--1 root root 195 Mar 16:51 Scsrun.log


[[email protected] ~] # ls -lh total 72K -rw ------- 1 root root 1.3K Mar 15 16:47 anaconda-ks.cfg drwxr-xr-x 2 root root 4.0K Mar 15 16 : 53 Desktop -rw-r--r-- 1 root root 37K Mar 15 16:47 install.log -rw-r--r-- 1 root root 3.6K Mar 15 16:47 install.log.syslog -rw -r--r-- 1 root root 195 Mar 15 16:51 scsrun.log Long option: --word, for example: --long, --human-readable Long options cannot be combined [[email protected] ~] # ls --human-readable anaconda-ks.cfg Desktop install.log install.log.syslog scsrun.log Parameters: the role of the command; provide data to the command; Note: 1, multiple options, and between multiple parameters and the command They should be separated by whitespace characters; 2. Cancel command execution, Ctrl + c;

 


File system:
Windows C:\Program Files\office1\word\word.exe
Linux/etc/sysconfig/network-scripts/ifcfg-eth0

Files have two types of data: metadata: metadata data attribute information, data stored in the index: data1, file names are strictly case sensitive: file1, File1, FILE1 are different parts; 2, file names can use other than / Any character, it is not recommended to use special characters; / is the root directory, path separator; 3, the length of the file name can not exceed 255 characters; 4, all files beginning with. Are hidden files; path: absolute path, Path from root: [[email protected] ~] # cd / etc / sysconfig / network-scripts / [[email protected] network-scripts] # pwd / etc / sysconfig / network-scripts relative path from the current Directory starting path: [[email protected] ~] # cd / etc [[email protected] etc] # pwd / etc [[email protected] etc] # cd sysconfig / network-scripts / [[email protected] network- scripts] # pwd / etc / sysconfig / network-scripts.: indicates the current directory ..: indicates the parent directory of the current directory, parent directory, current directory: current directory, also known as w orking directory; working directory pwd: print working directory LSB: linux standard base linux standard library



Access to Linux command help


External command: There is an executable program, located in a file system directory: which, Whereis Shell program Search executable program file path defined in the PATH environment variable # echo $PATH [[Email pro Tected] ~]# echo $PATH/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/u Sr/bin:/root/bin Note: The search format from left to right: command [Options ...] [Arguments ...] (Command Options ...) Parameters... ) built-in command: # Help command external command: 1, # command--help # command-h 2, User manual (manual) # Man command 3, info page # info Command 4 , the program's own Help document readme, install, Changelog 5, the official program document, the official site of documentation 6, the official version of the release of document 7, Google internal command Help # comma nd [[email protected] ~]# help CD CD:CD [-l|-p] [dir] The path result of external command found by Shell is cached to KV (Key-value key value) store h istory command: What is the function? What are the relevant environment variables? Useful options? Manages command history and reads commands recorded in the command history file: ~/.bash_history [[email protected] ~]# cat. Bash_history cat. Bash_history echo "" &G t;. bash_history Cat. Bash_history history-a The newly executed command will only be recorded in the cache when logged into the shell: These commands are "appended" to the command history file when the user exits: historical: -A: Append the newly executed command history for this sessionList to the history file; [[email protected] ~]# history-a [[email protected] ~]# cat. Bash_history echo " >. bash_history history-a Cat. Bash_history Init 6 history-a-D #: Deletes the command specified in history; -C: Empty command History [[[Email protected] ~]# history-c [[email protected] ~]# historical 1 hi Story Quick action:! #: Call the "#" command in history [[[Email protected] ~]# 1 historical 2 ls 3 [[EMAIL&N bsp;protected] ~]#!2 ls anaconda-ks.cfg install.log scsrun.log Desktop Install.log . syslog! String: Invokes the most recent command in history that starts with a string; [[email protected] ~]# 1 historical 2 CD 3 ls 4 History [[email protected] ~]#!c CD!! : Executes the previous command [[email protected] ~]# history1 history2 LS3 CD4 history [[email protected] ~]#!! History1 History2 LS3 CD4 History5 histOry external command Get help: Man Command manual page:/usr/share/man man1...man8 man1: User command man2: System call MAN3:C Library call MAN4: Device files and special files man5: Configuration file Format man6: Game man7: Miscellaneous man8: Managing Commands for classes Note: Some commands exist in more than one chapter help manual to view the specified chapter Manual in section: Man # command;whatis commands This command can help to query the chapters in which sensitive Ling has a help manual; [[email protected] ~]# whatis passwd passwd (1)-Update user ' s authentication tokens passwd (5)-Password file passwd (RPM) -The passwd utility for setting/changing passwords using PAM passwd [sslpasswd] (1SSL)-Compute password hashes [[email protected] ~]# man 1 passwd [[Email protected] ~]# Mans 5 passwd man command configuration file:/etc/man.config ma Npath/path/to/somewhere: Specify a new manual file search location Manpath_map/bin/usr/share/man manpath_map/sbin/usr/sh Are/man Manpath_map/usr/bin/usr/share/man Manpath_map/usr/sbin/usr/share/man Manpath_map/usr/lo cal/bin/usr/local/Share/man Manpath_map/usr/local/sbin/usr/local/share/man Manpath_map/usr/x11r6/bin/usr/x11r6/man Man Path_map/usr/bin/x11/usr/x11r6/man Manpath_map/usr/bin/mh/usr/share/man man-m/path/to/somewhere com Mand: Search the manual page of the comand command to the specified location and display it; [[email protected] ~]# man-m/usr/share/man passwd The paragraph description in the Help Handbook: name, basic Can synopsis use the brief help DESCRIPTION describe the details of the options option EXAMPLE Use the example AUTHOR author REPORTING BUGS report BUGS's civilian see A LSO reference Synopsis: []: Optional content <>: Required a|b: Two select one, or choose one more ... : The same content can appear several times the man command operation method: space space, CTRL + V, CTRL+F, ctrl+f: To the end of the file screen B, ctrl+b: To file The first turn screen D, Ctrl+d: to the end of the file Half screen u, ctrl+u: to the text The first half screen return enter, CTRL + N, Ectrl+e, J, Ctrl+j: Turn to the end of the file line y, Ctrl+y, ctrl+p, K, ctrl+k: The end of the file to the end of the line Q: Exit #: Jump to the # line; 1G: Back to the top of the file Part G: Turn to the end of file search:/keyword: Keyword The specified string as the keyword, from the current position to the end of the file search; case-insensitive; N: Next N: Previous? Keyword: The string specified by the keyword keyword, from the current position to the file header search, non-partitioned character case; N: Same direction as the search command, next N: With the search command in the opposite direction, the last infoThe help document for the Info command program itself/usr/share/doc/command-version [[email protected] ~]# cd/usr/share/doc [[EMA Il protected] doc]# ll total 3864 drwxr-xr-x 2 root root 4096 Mar 16:45 a2ps-4.13b drwxr-xr-x 2 root ro OT 4096 Mar 16:44 acl-2.2.39 drwxr-xr-x 2 root root 4096 Mar 16:47 alacarte-0.10.0 drwxr-xr-x 2 root root 40 16:45 alchemist-1.0.36 drwxr-xr-x 2 root root 4096 Mar 16:45 alsa-lib-1.0.17


Underlying command:
Date:
Date [option] ... [+format]: Display
Format: Display symbol
%y Two-bit year
[[email protected] doc]# date +%y
+


%Y Four-bit year [[email protected] doc]# date +%y 2018%m Month [[email protected] doc]# date + %m%h Month English abbreviation [[email protected] doc]# date +%h Mar%d the date of the month [[email protected] doc]# date + %d%H hours [[email protected] doc]# date +%h%M minutes [[email protected] doc]# Date +%m 03 %s seconds [[email protected] doc]# date +%s%s Unix the number of seconds to present [[email protected] doc]# date +%s 1521428720%d Date [[email protected] doc]# date +%d 03/19/18%F Date [[email protected] doc]# date +%f 2018-03-19%T time [[email protected] doc]# date + %T 11:07:57 Date [MMDDHHMM[[CC]YY][.SS]: Set Date time MM: Month DD: What's HH: Hour MM: Minute yy: Two-bit year CCYY: four-bit year. SS: seconds [[email protected] doc]# date 0319112018.00 Mon Mar 11:20:00 CST 2018 [[email protected] doc]# da Te 031911202018.00 Mon Mar 11:20:00 CST 2018

 


Two types of clocks for Linux:
System clock: Timing by the operating frequency of the Linux kernel CPU: Date
Hardware clock: Hwclock


[[email protected] doc]# date;hwclockMon Mar 19 11:22:51 CST 2018Mon 19 Mar 2018 11:23:12 AM CST -0.812703 seconds

 


Hwclock: Display Hardware clock
-s,--hctosys set the system clock to the hardware clock
[Email protected] doc]# hwclock-s
[Email protected] doc]# Date;hwclock
Mon Mar 11:24:59 CST 2018
Mon-Mar 2018 11:25:00 AM CST-0.634669 seconds


-w, --systohc Set the hardware clock based on the system [[email protected] doc] # hwclock -w [[email protected] doc] # date; hwclockMon Mar 19 11:26:14 CST 2018Mon 19 Mar 2018 11: 26:16 AM CST -0.537715 seconds


Cal: Show Calendar
[[email protected] doc]# cal
March 2018
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31



Directory-related commands
Current directory or working directory
home directory; home directory
Root:/root
Normal users:/home/username,/home/tom

~: Represents the user's home directory CD CD or cd~: Represents the switch to the current user's home directory [[email protected] ~]# CD [[email protected] ~]# Pwd/root [[email protected] tom]# cd ~ [[email protected] ~]# pwd/root CD ~username: Represents the switch to the home directory of the specified user [[EMAIL&NB Sp;protected] ~]# cd ~tom [[email protected] tom]# pwd/home/tom CD-: Switch back and forth between the previous directory and the current directory [[Email pro] Tected] home]# CD-/root [[email protected] ~]# CD-Home.: Represents the current directory. : Represents the current directory's parent directory related environment variables PWD: Saved current directory path oldpwd: Last directory path [[email protected] home]# echo $PWD/home [[Emai L protected] home]# echo $OLDPWD/root pwd: Displays the current working directory ls:list a list of files under the specified path LS [option] ... [Dir]...-a,--all: Displays all files, including hidden files [[email protected] home]# ls-a. .. tom[[email protected] home]# ls--all. .. Tom-l: Long format-rw-r--r--1 root root 37412 Mar 16:47 install.log-rw-r--r--leftmost first bit: file type-: normal file D: Directory file L: Link file B: Block device C: Character device P: Pipe file S: 9 bits after socket file, access rights, perm number 1: Number of times the file was hard-linked; Left Root: Owner of file, main right root of file: Group of file, genus of file 37412: size of file Mar 15 16:47: Last modified time of file Install.log: file name-h,- -human-readable: unit conversions, displaying file sizes in a human-readable format, typically with option-l [[email protected] ~]# ls-lh total 72k-rw-------1 root ro OT 1.3K Mar 16:47 anaconda-ks.cfg drwxr-xr-x 2 root root 4.0K Mar 16:53 desktop-rw-r--r--1 root root 37K Ma R 16:47 install.log-rw-r--r--1 root root 3.6K mar 16:47 install.log.syslog-rw-r--r--1 root root 195 Mar 1 5 16:51 scsrun.log-d: Displays the relevant properties of the directory itself; typically used with-l; [[email protected] ~]# ls-ld drwxr-x---root root 4096 Mar 16 08:30. -r,--reverse: Reverse display [[email protected] ~]# ls-lr total 72-rw-r--r--1 root root 195 Mar 16:51 Scsrun.lo g-rw-r--r--1 root root 3672 mar 16:47 install.log.syslog-rw-r--r--1 root root 37412 Mar 16:47 Install.log Drwxr-xr-x 2 root root 4096 Mar 16:53 desktop-rw-------1 root root 1264 Mar 16:47 anaconda-ks.cfg-r,- -recurisvE: Recursive display [[email protected] ~]# ls-r/root/root:anaconda-ks.cfg Desktop install.log install.log.syslog Scsrun.log/root/desktop:


Stat/path/to/somefile: Gets the metadata attribute information for the specified file:
[Email protected] ~]# Stat/etc/fstab
File: '/etc/fstab '
size:534 blocks:16 IO block:4096 Regular file
device:fd00h/64768d inode:652169 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2018-03-19 09:01:14.000000000 +0800
Modify:2018-03-15 16:44:22.000000000 +0800
Change:2018-03-15 16:47:52.000000000 +0800



File View commands: Cat, TAC
Cat [option] ... [File] ...
[Email protected] ~]# cat/etc/fstab/etc/issue
/DEV/VOLGROUP00/LOGVOL00/EXT3 Defaults 1 1
Label=/boot/boot ext3 Defaults 1 2
TMPFS/DEV/SHM TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0
/DEV/VOLGROUP00/LOGVOL01 swap swap defaults 0 0
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
Kernel \ r on an \m



[Email protected] ~]# tac/etc/fstab/etc/issue
/DEV/VOLGROUP00/LOGVOL01 swap swap defaults 0 0
PROC/PROC proc Defaults 0 0
Sysfs/sys Sysfs Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
TMPFS/DEV/SHM TMPFS Defaults 0 0
Label=/boot/boot ext3 Defaults 1 2
/DEV/VOLGROUP00/LOGVOL00/EXT3 Defaults 1 1



Kernel \ r on an \m
Red Hat Enterprise Linux Server release 5.7 (Tikanga)



-E: Display line terminator $
[Email protected] ~]# cat-e/etc/issue
Red Hat Enterprise Linux Server release 5.7 (tikanga) $
Kernel \ r on an \m$
$



-N: Numbering each line displayed
[Email protected] ~]# cat-n/etc/issue
1 Red Hat Enterprise Linux Server release 5.7 (Tikanga)
2 Kernel \ r on an \m
3



File content Type view command: File
File/path/to/somewhere
[Email protected] ~]# file/etc/issue
/etc/issue:ascii text
[Email protected] ~]# File/bin/ls
/bin/ls:elf 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for Gnu/linux 2.6.9, dynamically linked (uses shared Lib s), for Gnu/linux 2.6.9, stripped
[Email protected] ~]# File/dev/console
/dev/console:character Special (5/1)



Echoing command: Echo
-N: Prevent automatic addition of newline symbols
[Email protected] ~]# echo "How is it?"
How is it?
[Email protected] ~]# Echo-n "How is it?"
How is it? [Email protected] ~]#

-e: allow escapes \ n newline

[Email protected] ~] # echo-e "how \ nare?"

How

Is that you?

\ b backspace

[Email protected] ~] # echo-e "how \ b is You?"

Ho is you?

\ t Tab



[Email protected] ~]# echo-e "how\t is You?"
How is it?



echo "$VAR _name": Variables are replaced, double quotes indicate weak references
[[email protected] ~]# echo "$PS 1"
[\[email protected]\h \w]\$



Echo ' $VAR _name ': variables are not replaced, single quotes represent strong references
[Email protected]lhost ~]# echo ' $PS 1 '
$PS 1



Which: Displays the program file path for the command
which [option] command
[[email protected] ~]# which LS
Alias ls= ' ls--color=tty '
/bin/ls
[email protected] ~]# which cat
/bin/cat


--skip-alias: Disable alias [[email protected] ~] # which lsalias ls = 'ls --color = tty' / bin / ls [[email protected] ~] # which --skip-alias ls / bin / ls


The whatis:whatis command displays the header line of the manual section. You can then issue the man command to get additional information
[[email protected] ~]# Whatis CD
CD (1p)-Change the working directory
CD [Builtins] (1)-bash built-in commands, see Bash (1)
[Email protected] ~]# Whatis mkdir
mkdir (1)-Make directories
mkdir (1p)-Make directories
mkdir (2)-Create a directory
mkdir (3p)-Make a directory
[Email protected] ~]# Whatis useradd
Useradd (8)-Create a new user or update default new user information



Use the Makewathis command to create a database of all help manuals and their corresponding keywords on the current system.



Introduction to Linux distributions, getting Started with Linux system basics, Linux command Help, Linux basic commands


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.