Linux 的日常 tools
Linux基础命令里的就不再赘述了。
Table of Contents
一、下载(命令行工具,只给出常用的命令说明)
wget/cURL(一般系统自带)
- httpie:wget 和 curl 的替代品,功能更强大!!!
- wget: 轻量快速的下载工具
- 下载:
wget [-O filename] [-c] url - O 选项:给下载的文件指定文件名。(不加这个,会使用默认文件名)
- c 选项:断点续传
- 下载:
- cURL: 如果 wget 满足不了你的需求,就用 curl
- 下载:
curl [-o filename] url - o 选项:和 wget 的 -O 一样,是指定文件名。不过注意是小写。
- 下载:
aria2/axel多线程下载
wget/curl是单线程的,因此在下载大文件时,可能就显得不太合适了。因此出现了 aria2/axel
1. aria2: 神器
aria2 支持 HTTP(S)/FTP/SFTP/BitTorrent 的下载。
同时也是百度网盘下载神器,配合 baidu exporter 简直完美。
基础命令示例:
#download through http/ftp
aria2c download_url
#download through BitTorrent Magnet URI
aria2c "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C&dn=aria2"
#download through a local torrent file
aria2c --max-upload-limit=200K file.torrent
#The -x option specified the number of allowed connections, it should between 1 and 16.
aria2c -x16 "http://host/file.zip"
#-i, --input-file=<FILE> 指定从 files.txt 读取 url 下载
#-j,--max-concurrent-downloads=<N> 指定并行下载数.
aria2c -ifiles.txt -j3
通用的选项可以写入默认配置文件,文件地址是$HOME/.aria2/aria2.conf,也可通过--conf-path=<PATH>手动指定。配置内容可参考 Aria2 配置说明
2. axel
实测 axel 远没有 aria2 快
aria2 下载单文件最多只能开16线程,对付百度云这样限速严重的网站,可能不怎么好用。
而 axel 没这个限制,在需要开更多线程的时候,你就需要使用 axel 了。不过 axel 不支持 torrent,所以 BT下载还是得用 aria2。
使用示例:
-n, --num-connections=x # 开x线程
-o, --output=filename # 指定文件名
-H, --header=x # 设定请求头
-U, --user-agent=x # 设定请求头的代理字段
# 开 20 线程下载
axel -n 20 down_url
基本上了解这些就够了,可以看到 axel 比 aria2 简单很多。
youtube-dl
可以说是最火的视频/音乐下载工具了,支持 Youtube、Bilibili、优酷、爱奇艺、网易云音乐、QQ音乐等几乎所有你用得到的网站。(不过国内网站的支持,可能没 you-get及时)
使用正则匹配网站URL,你只需要给出 视频/playlist/channel 的观看用URL,它就从中解析出下载地址,并将视频下载下来。
安装:pip3 install youtube-dl
更新:pip3 install --upgrade youtube-dl
youtube-dl 的的配置文件位于~/.config/youtube-dl/config,可以把常用的配置写入该文件。以下是我的配置:
# Lines starting with # are comments
# default format is:[ -f bestvideo+bestaudio/best], we make it not better than 1080p
-f bestvideo[height<=?1080]+bestaudio/best
# download all subs
--all-subs
# don't overwrite files
--no-overwrites
# Use socks5 proxy, so if you want to download without proxy, you whould use `--ignore-config`
--proxy socks5://127.0.0.1:1080/
# Save all files under Movies directory in your home directory, with it's name: title.extension.
-o ~/Videos/%(title)s-%(id)s.%(ext)s
# 调用外部下载器下载,(aria2/axel)也许能提升下载速度
# --external-downloader aria2
# 设置外部下载器 (aria2) 的参数,可省略。
# --external-downloader-args -x 16
下载时的常用选项
-F, --list-formats List all available formats of requested videos
-f, --format FORMAT Video format code, see the "FORMAT
SELECTION" for all the info
-o, --output TEMPLATE Output filename template, see the "OUTPUT
--write-sub Write subtitle file
--write-auto-sub Write automatically generated subtitle file
(YouTube only)
--all-subs Download all the available subtitles of the
video
--embed-subs Embed subtitles in the video (only for mp4,
webm and mkv videos)
--list-subs List all available subtitles for the video
-w, --no-overwrites Do not overwrite files
-c, --continue Force resume of partially downloaded files.
By default, youtube-dl will resume
downloads if possible.
-a, --batch-file FILE File containing URLs to download ('-' for
stdin), one URL per line. Lines starting
with '#', ';' or ']' are considered as
comments and ignored.
--ignore-config just as its name
使用示例
# download a video
youtube-dl -o - "https://www.youtube.com/watch?v=BaW_jenozKcj"
# Download YouTube playlist videos in separate directory indexed by video order in a playlist
youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re
# Download all playlists of YouTube channel/user keeping each playlist in separate directory:
youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists
直接输出流到vlc
使用-o - 选项,将流直接输出到 stdio,再用管道重定向到 vlc.
youtube-dl -o - "https://www.youtube.com/watch?v=BaW_jenozKcj" | vlc -
you-get
这是另一个比较火的视频/音乐下载工具。(当然,文档/图片等也是可以下的,不过一般直接用wget就行了)
一般来说国外的网站如 Youtube 直接用 youtube-dl 就行了,而 you-get 对国内网站的支持好像是要比 youtube-dl 好,可以考虑用它。
安装:sudo pip3 install you-get
更新:sudo pip3 install --upgrade you-get
you-get 会自动合并同一个视频的流文件,只要你安装了 ffmpeg。
-i, --info to see all available quality and formats
-o, --output-dir
-O, --output-filename
-x, --http-proxy HOST:PORT set a http proxy
-s, --socks-proxy HOST:PORT set a socks5 proxy.
-p, --player output stream instantly to a player.
-l, --playlist 下载整个列表
example:
you-get 'https://www.youtube.com/watch?v=jNQXAC9IVRw' # just download it
you-get -i 'https://www.youtube.com/watch?v=jNQXAC9IVRw' # see the info, don't download it
you-get -o ~/Videos -O zoo.webm 'https://www.youtube.com/watch?v=jNQXAC9IVRw' # set output path
you-get -s 127.0.0.1:1080 'https://www.youtube.com/watch?v=jNQXAC9IVRw' # set http-proxy
you-get -p vlc 'https://www.youtube.com/watch?v=jNQXAC9IVRw' # player the video with vlc immediately.
二、音频/视频播放
视频:VLC and MPV
VLC 和 MPV 的 UI 和 性能 都挺不错的,可以尝试一下,看看中意哪个。我个人的感觉是,vlc 功能可能更全一点,但是有点太重,而且初始界面不喜欢。。mpv对我而言就刚刚好。
顺便这两个都有CLI(命令行接口)
音频:aplay、arecord
这些命令来源于 ALSA(Advanced Linux Sound Architecture),该模块是 Linux kernel 的一部分。
arecord -d 5 test-mic.wav
aplay test-mic.wav #只支持wav
对非 wav 音频,请直接用mpv xxx.mp3 或 vlc xx.mp3 播放. 个人强烈推荐mpv,它默认在命令行界面下播放。(命令行下也是支持快捷键快进快退的)
三、科学的上网
有名的当然是 shadow-socks 了,它的客户端是 sslocal, 客户端启动后,会在 localhost 的指定端口开始监听请求。
如果你的某软件需要走代理,首先它要支持 socks5 协议,然后它要主动把内容发送到 sslocal 监听的端口。为了满足这两个条件,就需要额外的工具:
- switchomega - GFWList: chrome 插件,使用它可实现仅 GFWList 翻墙这样的功能。
- proxychains-ng:对其它需要翻墙但是不满足上述两个条件的程序,可使用这个工具作为中间层。
四、文档处理
- icdiff - side-by-side highlight diff,见名知义
- A command-line fuzzy finder 文件模糊搜索,比 find 方便多了。
- ag 超快的全文搜索。(搜索指定字符串。)
- autojump - 替代 cd
- the fuck 出 Error?fuck 一下就好了。。
五、云
- 云仓库:开源项目用 Github 没说的、私有仓库可能会用 coding.net,它提供5个私人仓库(对我来说,完全够了)。
- 云硬盘:百度云 Wine 版,或者网页版。
- 云笔记:OneNote网页版
- 云文件:坚果云 Linux 版。(之前用 Windows 时用的 OneDrive,大概也是该换换了。)
- 云配置:mackup,自动搜索系统中的各种配置文件,并在 Dropbox/坚果云 的同步文件夹内建立配置文件的软链。并在其他系统上将配置文件从 同步文件夹 恢复到对应的位置。
五、其他实用
- mycli - A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting
- Anaconda Python 科学计算环境,不过用了这个后,Pycharm 每次 indexing 都要花好久。。所以机器不行的话,还是自己老实一个个安装吧。。
- Simplified and community-driven man pages: 如果你看不懂 man 或者懒得看,就用这个
- Variety - Wallpaper Changer - Slidshow 壁纸循环播放,虽然有人觉得没必要,不过我是挺喜欢的。这个项目因为是才迁移到 Github 上,所以 star 少,其实还挺有名的。
- htop - an interactive text-mode process viewer
- how to do somthing with CLI
画外
上面的软件,给出的链接基本都是 github 仓库,而且很多都是 Python 写的,一些小工具的源码很值得一读。也可以给 youtube-dl 更新一下 b站 的下载规则之类的。
熟悉了这些 tools 后,好像就很难再回到 Windows 了。。cmd.exe 太弱,powershell 在我的渣机器上冷启动要一分钟。。而且输中文还乱码,这还怎么玩?(更新1803后powershell启动倒是快了不少)
参考
Linux 的日常 tools的更多相关文章
- centos linux系统日常管理复习 CPU物理数逻辑核数,iftop ,iotop ,sar ,ps,netstat ,一网卡多IP,mii-tool 连接,ethtool速率,一个网卡配置多个IP,mii-tool 连接,ethtool速率 ,crontab备份, 第十八节课
centos linux系统日常管理复习 物理CPU和每颗CPU的逻辑核数,uptime ,w,vmstat,iftop ,iotop ,sar ,ps,netstat ,一个网卡配置多个IP,mii ...
- centos linux 系统日常管理4 scp,rsync,md5sum,sha1sum,strace ,find Rsync 常见错误及解决方法 第十七节课
centos linux 系统日常管理4 scp,rsync,md5sum,sha1sum,strace ,find Rsync 常见错误及解决方法 第十七节课 rsync可以增量同步,scp不行 ...
- centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,curl,ping ,telnet,traceroute ,dig ,nc,nmap,host,nethogs 第十六节课
centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,cur ...
- centos Linux系统日常管理2 tcpdump,tshark,selinux,strings命令, iptables ,crontab,TCP,UDP,ICMP,FTP网络知识 第十五节课
centos Linux系统日常管理2 tcpdump,tshark,selinux,strings命令, iptables ,crontab,TCP,UDP,ICMP,FTP网络知识 第十五节课 ...
- centos Linux系统日常管理1 cpuinfo cpu核数 命令 w, vmstat, uptime ,top ,kill ,ps ,free,netstat ,sar, ulimit ,lsof ,pidof 第十四节课
centos Linux系统日常管理1 cpuinfo cpu核数 命令 w, vmstat, uptime ,top ,kill ,ps ,free,netstat ,sar, ulimit ...
- 第一阶段考试:实战Linux系统日常管理
1. [项目名称] 实战Linux系统日常管理 [项目说明] 1.安装部署rhel系统,组建RAID磁盘阵列. 2.安装nginx 通过脚本编写 nginx服务服务启动脚本 [项目考核技能点] 1.安 ...
- Linux系统安装VMware tools
VMware tools还是挺有用的,在两个不同系统随意拖拽文件,甚至文字的复制粘贴,功能强大. 废话不多说... 虽然VMware tools的安装帮助文档写的不错但是实际操作中发现,...还是有坑 ...
- 基于Linux 的VM TOOLS Install
VMware Tools Install 在VMware中为Linux系统安装VM-Tools的详解教程 如果大家打算在VMware虚拟机中安装Linux的话,那么在完成Linux的安装后,如果没 ...
- linux系统日常管理
笔者在前面介绍的内容都为linux系统基础类的,如果你现在把前面的内容全部很好的掌握了,那最好了.不过笔者要说的是,即使你完全掌握了,你现在还是不能作为一名合格的linux系统管理员的,毕竟系统管理员 ...
随机推荐
- 转 zigbee学习笔记---Channel、PANID、发射功率及其它参数
现对z-stack里几个网络参数的设置以及如何获取总结一下.信道配置:Zigbee在3个频段定义了27个物理信道:868MHz频段中定义了1个20Kb/s信道,915MHz频段中定义了10个40Kb/ ...
- yii相关手册文档
1.Yii官方手册 Yii Framework 2.0 权威指南:http://www.yiichina.com/doc/guide/2.0/start-databases 2.yii高级应用程序手册 ...
- 微信jssdk实现分享到微信
本来用的是这个插件http://overtrue.me/share.js/和百度分享 相同之处:在微信分享的时候,分享的链接都不能获取到缩略图... 不同之处:百度分享在微信低版本是可以看到缩略图的( ...
- linux 命令——35 ln(转)
ln 是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同步的链接.当我们需要在不同的目录,用到相同的文件时,我们不需要在每一个需要的目录下都放一个必须相同的文件,我们只要 ...
- JS调试debug
1. debugger; 我以前也说过,你可以在JavaScript代码中加入一句debugger;来手工造成一个断点效果.需要带有条件的断点吗?你只需要用if语句包围它: if (something ...
- python redis基本操作
#!/usr/bin/env python #-*- coding:utf-8 -*- # author:leo # datetime:2019/4/24 16:26 # software: PyCh ...
- window10启用administrator 和启用组策略编辑器
1,启用administrator账户 net user administrator /active:yes 2,启用组策略编辑器 新建一个文本文件.把下面代码粘贴进去.修改后缀名为.cmd ...
- C#冒泡排序程序
考虑到很多面试可能会考察冒泡排序的用法,所以特地花时间厘清了一下思路.下面说一下我的思路:冒泡排序核心就是比较方法,冒泡排序的比较方法顾名思义就是像气泡一样,最大(或者最小)的数往上冒.普通比较几个数 ...
- SQL Server数据库日志清除
第一步 将数据库转换成 simple 模式 USE master GO ALTER DATABASE 所要删除日志的数据库名 SET RECOVERY SIMPLE WITH NO_WAIT GO 第 ...
- SpringBoot之自动配置原理
我在前面的Helloworld的程序中已经分析过一次,配置原理了: 1).SpringBoot启动的时候加载主配置类,开启了自动配置功能 @EnableAutoConfiguration 2).@En ...