2018年4月26日:開源日報第49期

每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,歡迎關注開源日報。交流QQ群:202790710;電報群 https://t.me/OpeningSourceOrg


今日推薦開源項目:《python教程full-speed-python

推薦理由:full-speed-python從如何安裝python講起,講基本的數據類型、數值和字元串、數列,講模塊和函數,講遞歸函數,講循環,也講字典、類、迭代器和生成器。對有其他語言基礎的人來說很容易理解,只需要注意格式上的不同。對把python作為第一門語言來學的人來說,full-speed-python也很細緻,面面俱到,除了講解、例子,還有給學習者的課後練習。

full-speed-python使用pandoc完成。本文稍後也會介紹pandoc。在此,我們就函數來做一個小小的例子:

開源項目精選:python教程full-speed-python

如圖所示,函數的基本格式為 def 函數名(參數): 。

再來一個關於生成器(如while和for)的例子:

開源項目精選:python教程full-speed-python

但是,如果不加range它會輸出:

開源項目精選:python教程full-speed-python

一些手抖(並不)的導致的小錯誤有時候會變成一個大bug,有時候也會成為一個小彩蛋,更多精彩內容請打開full-speed-python和python,自己動手試一試吧!

關於 pandoc

pandoc是一款開源的標記語言轉換工具,它能夠識別Markdown, CommonMark, PHP Markdown Extra, GitHub-Flavored Markdown在內的諸多格式,並且能生成XHTML, HTML5, ConTeXt, RTF, OPML, DocBook, JATS, OpenDocument, ODT, Word docx等諸多格式的文件,在安裝了LaTeX,ConTeXt, pdfroff, wkhtmltopdf, prince, or weasyprint後,也能輸出pdf文件

 

安裝:

1.全平台方式:安裝Haskell後使用cabal工具安裝

cabal update
cabal install pandoc

 

2.windows:

下載後執行安裝程序即可

 

3.linux:

先使用包管理工具直接安裝,失敗則使用全平台方式

 

使用:

你可以直接在命令行中輸入文本將其轉換,例如

輸入pandoc -f html -t markdown 指令

而後輸入 <p>hello,world</p><em>hello,pandoc</em>

然後windows用戶按ctrl+z後回車(其他為ctrl+d)

看到如下結果:

開源項目精選:python教程full-speed-python

當然,以上只是最基本的用法,如若感興趣,請自行參閱官方文檔

用戶指南:https://pandoc.org/MANUAL.html

pandoc github鏈接:https://github.com/jgm/pandoc/

 

作者介紹:

João Ventura

開源項目精選:python教程full-speed-python

作者的其他項目:

開源項目精選:python教程full-speed-python

 


今日推薦英文原文:《An introduction to the GNU Core Utilities》作者:David Both

原文鏈接:https://opensource.com/article/18/4/gnu-core-utilities

推薦理由:關於 GNU 核心工具的一份簡介。GNU核心工具組英語:GNU Core Utilities,亦常縮寫為Coreutils)是一個包含了多個類Unix所需的基本工具的軟體包,其亦是之前許多類似軟體包(如textutils(文本工具組)、shellutils(shell工具組)、fileutils(文件工具組)等)所包含工具的集合。

An introduction to the GNU Core Utilities

Introduction to the GNU Core Utilities
Image credits : Bella67 via Pixabay. CC0.

Two sets of utilities—the GNU Core Utilities and util-linux—comprise many of the Linux system administrator's most basic and regularly used tools. Their basic functions allow sysadmins to perform many of the tasks required to administer a Linux computer, including management and manipulation of text files, directories, data streams, storage media, process controls, filesystems, and much more.

These tools are indispensable because, without them, it is impossible to accomplish any useful work on a Unix or Linux computer. Given their importance, let's examine them.

GNU coreutils

To understand the origins of the GNU Core Utilities, we need to take a short trip in the Wayback machine to the early days of Unix at Bell Labs. Unix was written so Ken Thompson, Dennis Ritchie, Doug McIlroy, and Joe Ossanna could continue with something they had started while working on a large multi-tasking and multi-user computer project called Multics. That little something was a game called Space Travel. As remains true today, it always seems to be the gamers who drive forward the technology of computing. This new operating system was much more limited than Multics, as only two users could log in at a time, so it was called Unics. This name was later changed to Unix.Over time, Unix turned out to be such a success that Bell Labs began essentially giving it away it to universities and later to companies for the cost of the media and shipping. Back in those days, system-level software was shared between organizations and programmers as they worked to achieve common goals within the context of system administration.

Eventually, the PHBs at AT&T decided they should make money on Unix and started using more restrictive—and expensive—licensing. This was taking place at a time when software was becoming more proprietary, restricted, and closed. It was becoming impossible to share software with other users and organizations.

Some people did not like this and fought it with free software. Richard M. Stallman, aka RMS, led a group of rebels who were trying to write an open and freely available operating system they called the GNU Operating System. This group created the GNU Utilities but didn't produce a viable kernel.

When Linus Torvalds first wrote and compiled the Linux kernel, he needed a set of very basic system utilities to even begin to perform marginally useful work. The kernel does not provide commands or any type of command shell such as Bash. It is useless by itself. So, Linus used the freely available GNU Core Utilities and recompiled them for Linux. This gave him a complete, if quite basic, operating system.

You can learn about all the individual programs that comprise the GNU Utilities by entering the command info coreutils at a terminal command line. The following list of the core utilities is part of that info page. The utilities are grouped by function to make specific ones easier to find; in the terminal, highlight the group you want more information on and press the Enter key.

* Output of entire files::       cat tac nl od base32 base64
* Formatting file contents::     fmt pr fold
* Output of parts of files::     head tail split csplit
* Summarizing files::            wc sum cksum b2sum md5sum sha1sum sha2
* Operating on sorted files::    sort shuf uniq comm ptx tsort
* Operating on fields::          cut paste join
* Operating on characters::      tr expand unexpand
* Directory listing::            ls dir vdir dircolors
* Basic operations::             cp dd install mv rm shred
* Special file types::           mkdir rmdir unlink mkfifo mknod ln link readlink
* Changing file attributes::     chgrp chmod chown touch
* Disk usage::                   df du stat sync truncate
* Printing text::                echo printf yes
* Conditions::                   false true test expr
* Redirection::                  tee
* File name manipulation::       dirname basename pathchk mktemp realpath
* Working context::              pwd stty printenv tty
* User information::             id logname whoami groups users who
* System context::               date arch nproc uname hostname hostid uptime
* SELinux context::              chcon runcon
* Modified command invocation::  chroot env nice nohup stdbuf timeout
* Process control::              kill
* Delaying::                     sleep
* Numeric operations::           factor numfmt seq

There are 102 utilities on this list. It covers many of the functions necessary to perform basic tasks on a Unix or Linux host. However, many basic utilities are missing. For example, the mount and umount commands are not in this list. Those and many of the other commands that are not in the GNU coreutils can be found in the util-linux collection.

util-linux

The util-linix package of utilities contains many of the other common commands that sysadmins use. These utilities are distributed by the Linux Kernel Organization, and virtually every one of these 107 commands were originally three separate collections—fileutils, shellutils, and textutils—which were combined into the single package util-linux in 2003.

agetty          fsck.minix      mkfs.bfs        setpriv
blkdiscard      fsfreeze        mkfs.cramfs     setsid
blkid           fstab           mkfs.minix      setterm
blockdev        fstrim          mkswap          sfdisk
cal             getopt          more            su
cfdisk          hexdump         mount           sulogin
chcpu           hwclock         mountpoint      swaplabel
chfn            ionice          namei           swapoff
chrt            ipcmk           newgrp          swapon
chsh            ipcrm           nologin         switch_root
colcrt          ipcs            nsenter         tailf
col             isosize         partx           taskset
colrm           kill            pg              tunelp
column          last            pivot_root      ul
ctrlaltdel      ldattach        prlimit         umount
ddpart          line            raw             unshare
delpart         logger          readprofile     utmpdump
dmesg           login           rename          uuidd
eject           look            renice          uuidgen
fallocate       losetup         reset           vipw
fdformat        lsblk           resizepart      wall
fdisk           lscpu           rev             wdctl
findfs          lslocks         RTC Alarm       whereis
findmnt         lslogins        runuser         wipefs
flock           mcookie         script          write
fsck            mesg            scriptreplay    zramctl
fsck.cramfs     mkfs            setarch

Some of these utilities have been deprecated and will likely fall out of the collection at some point in the future. You should check Wikipedia's util-linux page for information on many of the utilities, and the man pages also provide details on the commands.

Summary

These two collections of Linux utilities, the GNU Core Utilities and util-linux, together provide the basic utilities required to administer a Linux system. As I researched this article, I found several interesting utilities I never knew about. Many of these commands are seldom needed, but when you need them, they are indispensable.

Between these two collections, there are over 200 Linux utilities. While Linux has many more commands, these are the ones needed to manage the basic functions of a typical Linux host.


每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,歡迎關注開源日報。交流QQ群:202790710;電報群 https://t.me/OpeningSourceOrg

()
定位於家用防火牆的 Linux 發行版 Smoothwall Express 發布 3.1 Update9/SP4
開源項目精選: Vue.js 簡介
暫無評論
做你所想,開源工場

開源工場是一個校園風格的古典開源文化社區,通過開源協作形式來創造生產力和寓技術於樂趣的頻分多址非盈利開源社區。主張享受開源審美和動手做開源。目前有全球流行開源項目榜中榜開源周報、開源日報、媛寶、猿帥、開源尚青、開源工寮等原創欄目及主辦學生開源年會(sosconf)。了解我們加入我們

聯繫我們

中國:重慶市沙坪壩區沙正街174號重慶大學
新加坡:113 Jalan Besar, Singapore 208833

編程浪子
編程浪子
人不堪其憂,我不改其樂 base64 -d "d2VuQGJvb3RpbmdtYW4ub3Jn"
153
文章
35
評論
97
喜歡