A simple Linux application

Source: Internet
Author: User
Tags disk usage

** 简述** linux是一套自由加开放源代码的类Unix操作系统,诞生于1991年10月5日(第一次正式向外公布),由芬兰学生linus Torvalds和后来陆续加入的众多爱好者共同开发完成的。 linux是一个基于POSIX和Unix多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的Unix工具软件,应用程序和网络协议,可以支持32位和64位硬件,Linux继承了Unix以网络为核心的设计思想,是一个性能稳定的多用户网路操作系统。 Linux存在许多不同版本,但他们都是用了Linux内核。Linux可安装再各种计算机硬件设备中,比如手机,平板电脑,路由器、视屏游戏控制台,台式计算机,大型和超大计算机。 严格来讲,Linux这个词本身只表示Linux内核,但实际上人们已经习惯了用Linux来形容整个基于Linux内核,并且使用GNU工程各种工具和数据库的操作系统。 但是也有些人使用Linux来做一些坏事,例如钓鱼WiFi,或者使用BTLinux和CBLinux这个两个版本来暴力破解别人的路由,进行抓包,可以获取使用这个路由器连上外网的人的信息,一般可以获取账号、信息、视屏、图片、之类的东西。曾今看到一个网站上的教学,上面著述,纯粹教学科技演示,不是不黑你,只是你没有黑的价值。** Linux内核** 内核是Linux系统最底层,提供了核心功能并且允许进行以一种有序的方式来访问硬件。 用于控制进程,输入输出设备,文件系统操作,管理内存,这个都需要内核来操作。 当以一个程序要运行,就会产生一个进程,shell翻译成内核所能理解的二进制指令,内核收到,把程序加载到CPU上,这个程序不是一直运行下去的,有个时间片,内核规定你在CPU运行多长时间,把这个这个程序放到内存的一个地方,给他表上地址,然后运行下一个进程,假如说这个进程运行完之后,内核就会找到上一个程序没有结束的地址,加载CPU上运行。这个进程需要什么,内核从磁盘放到内存里。

Software Installation
Take Ubuntu system as an example
dpkg command: When you have no network, you have a package, at this time, dpkg play the role of the decision

                -I: Install a Debian package that exists on the local file system-r: Overflow an already installed package-P: Remove installed packages and configuration files                                    -L: View software installed in those directories-s: Displays the installation state of the package-L: Lists all installed software for the system such as dpkg i + package name                                 Dpkg-p software Name The full uninstall software is corresponding to the dpkg apt-get, when there is a network you can install software apt-get through Apt-get:                                 -F: Fix software dependencies in System-M: the diagram continues to execute when a missing associated package is found                                 -Q: When the output is retained as a log and does not get the command execution Progress--purge: Used with remove, the fully uninstalled package is equivalent to Dpkg-p --reinstall: Use with install subcommand, reinstall package Apt-get install--reinstall-b: After downloading the source package , the compilation generates the corresponding package-s: Do not do the actual operation, only the simulation command execution results-y: All queries are answered positively, apt-get not                                 Make any prompt-u: Get list of upgraded packages-H: Get List of upgrade packages -V: Get Apt-get version LetterUse the Apt-cache command to complete the query for the source and package of the software +pkg show: Get a detailed description of the binary package search: according to regular expression                         Retrieve soft pack depends: Get all packages that depend on the package rdepends: Get all packages that depend on the software package Policy: Get package Current installation state stats: Get basic statistics for a software source * * Introduce a few common commands * * whereis find command commands, functions and other things where the bits            Whereis ls which: Find using program Whatis: View a command or function when the type of the time: the time of the function of the statistics of the Times LS shows the Times of execution                                              Shutdown-r +10:10 minutes after reboot required Superuser privilege to +now: Shut down now                                    -H +10:10 minutes after shutdown DF command: Show disk Usage-A: List all file systems                                    -B: List total free space-e: Only idle files are listed            -K: Lists allocation of disks-H: same-K, but size in G,m,k, units display-L: List only local file systems Touch + file Name: Create a text, or use > filename tocuh can modify the timestamp, when someone else invades your computer, leaving to do is to modify your file time and write a script to clear the Histroy (history) Kill killing process -9 + PID: Force kill Process -2 PID: Terminate is CTRL +c-19 PID: Process stop (Into the background) shortcut key CTRL +z Restore FG Killall-15 + process name: Send 15 signal to all this process name after killall5-9 Fatal: Kill all the cities

File System
Users who have been using Microsoft's Windows operating system seem to have become accustomed to several partitions of the hard disk and are identified with a:, B:, C:, D: And so on, and the access file must be cleared from the directory that is stored on that disk.
Linux's file organization mode is like an inverted tree, which differs greatly from the Windows file system. All storage devices are stored as a subdirectory of this tree. This is difficult to understand, but just contact with Linux users are not used to
The following is a brief introduction to the Linux file system classification
/:linux File root directory
/bin: The most common executable file for storing system files (binary)
/boot: Store Linux kernel and system boot files, including GRUB, LILO launcher program
/dev: Store all device files, including hard disk, partition, keyboard, mouse, USB, TTY, etc.
/etc: Store all the configuration files of the system. For example, passwd deposit account information
/home: The default location of the user directory, where the user is in this folder is local despot
/INITRD: Store the directory where the initrd.img image files are mounted at startup and load the required device modules
/lib: Storing shared library files, including many library files used by programs in/bin and/sbin
/lost+found: Storing fsck to place fragmented files
/media:ubuntu automatically mount Cd=rom, floppy drive, USB memory, temporarily read into the file
/mnt This directory is typically used as a mount point for mounted file systems
/OPT: As a directory of optional files and programs, primarily used by third party developers to easily install and uninstall their installed programs
/proc: Store all the processes marked as files, they are identified by process number or other system dynamic information, such as Cpuinfo file holds the data of the current working state of the CPU
/root: Home directory for root user (super User)
/sbin: Store more executable files (binary), including system management, directory query and other key command files
/tmp "Store user temporary files, all users read and write access to key commands such as directory queries
Connection
The connection is divided into hard links and soft links, hard link is when the file is new, the file system will give the file an index, according to index to create the file, the source file modification has an impact on the target file. However, deleting the source file does not have any effect on the destination file, which is equivalent to creating a non-copy of the source file and modifying its content source and destination files accordingly. However, hard links cannot create hard-link folders, soft Links: Similar to Windows shortcut keys, a soft link only corresponds to the specified path and file name or folder name, if the soft file changes the path or a new name, the soft link will expire.
LN: Used to create a file link.
Grammar
ln (option) (parameter)
-B: Delete, overwrite the backup before the target file
-F or--force: Forcibly establish a connection to a file or directory, regardless of whether the file or directory exists;
-I or--interactive: Ask the user before overwriting the existing file;
-N or--no-dereference: treats the destination directory of the symbolic connection as a generic file;
-S or--symbolic: Establish a symbolic connection to the source file, not a hard connection;
-s< tail Backup string > or--suffix=< tail backup string;: After backing up the target file with "-B" parameter, the tail of the backup file is added a backup string, the default backup string is the symbol "~", the user can change it by "-S" parameter;
-V or--verbose: Displays the instruction execution process;
-v< Backup method > or--version-control=< backup method;: After backing up the target file with the "-B" parameter, the tail of the backup file is added with a backup string that can be changed not only by the "-S" parameter, when the "-V" parameter is used < backup method > Specify different backup methods, also produce different tail of the backup string;
Alias Command aliases
For example, LS hand speed is easy to beat into SL then give LS seven name SL so there will be no error
Alias sl = ' ls '
tar file archive compression decompression
Role: Mainly used to merge several folders or directories into a file for backup and compression, of course, later on the TAR program's improved version, you can implement the merge archive while compression,
Format: tar [-T |-x |-u |-F |-j |-Z | tarfile filelist

         -T: Displays the contents of the archive-x: Release Archive file-u: More Line Archive-C: Create a new archive file-V: Shows the process of archiving and releasing-j: generated by tar Archive, then compressed by bzip2-Z: Generated by tar, then by gzip compressed ping address to see the network does not pass the TTL: display after several routes to reach the destination URL time: From your start to the destination site and back        Time to use Nslookup: View domain name address sudo dhclient set to get **shell script automatically * * Shell is an ordered collection of command line interpreter shell scripts                    Shell scripts explain common shell environment variables using the shell of Bash #!/bin/bash: The user home directory listed in the HOME:/ETC/PASSWD file Ifs:internal Field Separator, default view space, tab and line break Path:shell command search path PS1,PS2: Default prompt ($) level Line break prompt (>) Shell: Default shell such as print first jargon echo "Hello World" print string Length: string= "Ni hao" echo ${#string} display character length 6 UN Set string: Delete this variable is typically used in shell programming with all uppercase variables to facilitate the identification of $COUNT = 1 variable call: Add $ $echo before the variable $HOME l  Inux Shell/bash assignment from right to left       Y=y Use the unset command to delete a variable assignment Z=hell echo $Z unset Z Strong type when single quote in shell script, double quotation mark when weak type, use single quotation mark reference                        The time-varying amount does not change, for example: Echo ' $Z ' print out or $z [email protected] in the For loop is an output read-s input hidden    -N: Limit the number of outputs-p: print a word in output expr: can only be used for simple positive arithmetic.    Expr 12+5\*3 The result of the test command is used to check whether a condition is true, similar to square brackets ([]).            Test file type: test-d files: Test for a directory-D: whether the test is a directory-e: is a file-f: is a normal file-L: is a symbolic link            -R: Whether there is a readable-w: writable-X: Whether or not to execute-S: The file exists and is not 0 f1-nt F2: Test is newer than file F2 F1-ot F2: Is it better to decide which branch to execute than the file F2 if, elif, and Continue,break use the IF statement to determine the true or false of an expression by using the relational operator. The Shell has three if ... else statements: If ... fi statements, if ... else ... fi statements; if ... elif. . else ... the syntax of the IF ... else statement for the FI statement:

if [expression]
Then
Statement (s) to BES executed if expression is true
Fi
If expression returns True,then, the statement is executed and no statement is executed if False is returned.

Finally must end with FI to close the if,fi is if the inverted spelling, the back will also meet.

Note: There must be a space between expression and square brackets ([]), or there will be a syntax error.

As an example:

#!/bin/sh
a=10
B=20
if [$a = = $b]
Then
echo "A is equal to B"
Fi
if [$a! = $b]
Then
echo "A is not equal to B"
Fi
Operation Result:
A is not equal to B

If ... elif. Fi statement
The If ... elif. FI statement can judge multiple conditions, with the syntax:
If [expression 1]
Then
Statement (s) to being executed if expression 1 is true
elif [Expression 2]
Then
Statement (s) to being executed if expression 2 is true
elif [Expression 3]
Then
Statement (s) to being executed if expression 3 is true
Else
Statement (s) to being executed if no expression is true
Fi
Which expression evaluates to true, executes the statement after which expression is executed, and if it is false, no statement is executed.

Case...esac
The multi-branch statement case is used for multiple conditional tests, the syntax structure is clear and natural, its syntax is
Case string variable in #case语句只能测试字符串变量
Mode 1)
Command table
;;
Mode 2| mode 3)
Command table
;;
*)
Command table
;; #最后一个双分号可以省略
Esac #结束标志

        for...do..done        当循环次数已知或确定时,使用for循环语句来多次执行一条或一组命令。循环体由语句括号do和done来限定        格式为:        for 变量名  in 单词表   #意味者在变量名的大小从单词表中查找        do                        命令表        done        变量一次取单词表中的各个单词,每取一次单词,就执行一次循环体中的命令,循环次数由单词表中的单词数确定。命令表中的命令可以时一条,也可以是由分号或换行符分开的多条        如果单词表使命令行上的所有位置参数时,可以在for语句中省略in单词表部分。        用for实现死循环        例如:            for i             do                         echo            done

Break,continue: Different from C language, Java and other languages

    break 后面不加数字,表示跳过一个循环    break 2 意味着:跳过两成循环    continue后面什么也不加意味着结束本次循环    continue 2 意味着 第一层为break;第二层为continue。    写的不好勿喷,嘻嘻。如果有错的,请多多指教。鄙人将不胜感激。

A simple Linux application

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.