lf – ターミナル用のファイル管理

by MOONGIFT

MOONGIFT / 2017-06-26 08:02

ファイルを管理しようと思ったらファイルマネージャを使うのが一般的です。WindowsであればExplorerであったり、macOSであればFinderを使います。次期iOSでもファイル管理用のアプリが追加されます。ファイル管理はコンピュータの基本機能と言えます。

それなのにLinuxのターミナル上ではlsやmkdirなどのコマンドでファイルを管理してきました。今回はターミナル上で動作するファイル管理ツール、lfを紹介します。

lfの使い方

lfを起動したところです。3カラム構成になっています。

テキストファイルであればプレビューできます。

lfを使えば矢印キーだけでディレクトリを辿りつつ、内容をすぐに確認できます。まだドキュメントが殆どないので細かい使い方は不明ですが、2画面ファイラー風の表示もできるようです。個人的に2画面ファイラーはツボなので使ってみたいと思わされるソフトウェアです。

lfはGo製のオープンソース・ソフトウェア(MIT License)です。

gokcehan/lf: A terminal file manager

Shared via Inoreader

lf – ターミナル用のファイル管理

Tubutler – とてもシンプルなYouTubeプレイヤー

by MOONGIFT

MOONGIFT / 2017-08-11 12:01

YouTubeはとても楽しいサービスですが、動画を見るために不要な情報がたくさん並んでいます。コメントや余計なメニューはいらない、とにかく動画を見たいんだと考える人は多いでしょう。

そうした人にお勧めなのがTubutlerです。とてもシンプルで使い勝手の良いYouTubeプレイヤーです。

Tubutlerの使い方

動画の検索結果です。

動画再生画面です。

Tubutlerでは動画の検索結果と再生画面くらいしかありません。とてもシンプルで、動画を再生することに集中できます。YouTubeが公式でこうしたUIを提供できるとは思いませんが、Web APIを使ったマッシュアップだからこそ実現できるのでしょう。

TubutlerはTypeScript製のオープンソース・ソフトウェア(MIT License)です。

joe-re/tubutler: Simple and useful YouTube Player for Desktop

Shared via Inoreader

Tubutler – とてもシンプルなYouTubeプレイヤー

gtop – ターミナル上のシステムダッシュボード

by MOONGIFT

MOONGIFT / 2017-08-27 12:01

システム管理者はシステム全体のステータスを把握する必要があります。そのためにサーバ側データを送信して可視化するダッシュボードソフトウェアがたくさんあります。

しかしデータをあえて飛ばすことなく、ターミナル上でそのまま確認できるのがgtopです。

gtopの使い方

メイン画面です。

データはリアルタイムに書き換わります。CPU、ディスク容量、プロセス、メモリ、ネットワークなどの多数の情報が可視化できるようになっています。何よりターミナル上で実行されるので、別途表示するツールを用意しないので良いのが利点です。なおデータは蓄積されないので、実行したタイミングから表示されていく形になります。

gtopはnode/JavaScript製のオープンソース・ソフトウェア(MIT License)です。

aksakalli/gtop: System monitoring dashboard for terminal

Shared via Inoreader

gtop – ターミナル上のシステムダッシュボード

Manage Your File Versioning Like a Programmer With Git

by Aaron Peters

MakeUseOf / 2017-08-26 02:02

If you’ve ever worked with colleagues on a document, you know this pain: someone takes the first pass (document.doc), then emails it to everyone. The next person does the same, as does the third, each tacking a revision (document_rev3.doc) to the file’s name. The manager likes what she sees and tags it as complete (document_final.doc)… until last-minute changes come along (document_final_Aaron’s changes_reviewed_by_Bob_now_really_final.doc).

Now imagine changes like this in dozens of source code files. Programmers created version control systems (VCS) to solve this problem. They’re a bit technical in nature, but can be useful for power users as well. Let’s look at the basics of version control using the top system today, Git.

Overview of Version Control in Use

The primary purpose of VCSs is to capture versions (also called revisions) of a file over time. This means not relying on crude methods like the one described above. In these systems, when you access “document.doc” you’re working on the most recent version by default. But you can also go back into the file’s history and retrieve past versions. Systems built specifically to manage file versions began in software development, but have made their way into more “mainstream” applications as well.

The Evolution of Version Control in Software Development

Version control applications originally came about as a way to prevent programmers from breaking each others’ code. The first systems simply allowed users to lock files from other edits, while second-generation systems (such as Subversion How To Control WordPress Versions Using Subversion [Linux] How To Control WordPress Versions Using Subversion [Linux] Most of you probably already know that WordPress powers a large amount of websites that we look at every day. With the large userbase and support, you can do a lot of cool things with… Read More ) added full-project checkout from a central repository.

While these second-gen systems are still widely used, the industry is migrating towards third generation systems. The main characteristic of these systems is that they are distributed, meaning there is no central repository. Rather, each user has their own full copy of the repository (including all past revisions). But any changes (even full revisions) are “local” until he “pushes” them to another repository. That user can then pull a clone in order to make changes and repeat the process.

version control system flow

Current Version Control for Non-Programmers

The ability to capture multiple versions of the same thing is also a common feature for average users too Not Just For Coders: Top Version Control Systems For Writers Not Just For Coders: Top Version Control Systems For Writers The mention of version control or revision control makes it seem like something for geeks. You will be surprised to know that version control systems have their place not only in academic writing but in… Read More . With access to cheaper storage, both on the local machine and via easy-to-use cloud services, users now have the ability to track the history of their files. General-purpose programs do this in a number of ways.

Operating systems can capture a history of files or folders The Ultimate Windows 10 Data Backup Guide The Ultimate Windows 10 Data Backup Guide Windows 10 makes data backups effortless. We have summarized every native backup, restore, recovery, and repair option we could find on Windows 10. Use our simple tips and never despair over lost data again! Read More . This can happen automatically every time a file is saved, or on a regular schedule. Some desktop applications also let you capture versions or snapshots of files. For example, LibreOffice provides the “Save Version” feature (as shown in the top image below) that allows you to save multiple versions of the document in one file. Lastly, web/cloud applications such as Google Drive, ownCloud, etc. will also keep past iterations of a file or document (as shown for Google Docs in the bottom image below), either behind the scenes or at your express command.

version control system lo versions

version control system google docs versions

Why Use Programming-Centric Version Control Then?

Since all these options at the OS or application level already exist, why bother with these nerdy programmer tools? There are a couple of drawbacks to the above methods, including:

version control system dropbox history

If any or all of these issues make you want something more, check out the next section where we solve them with Git.

Version Control With Git

In the following sections we’ll go through each of these steps for a very important project: this very article. We’ll do so using the command line version of Git. Knowing the terminal commands will make it easy enough to find their GUI equivalents, and it’ll guarantee you can use it on every platform.

1. Setting Up the Git Repository

If your machine doesn’t have git installed (Macs do, as do some Linux distributions), you can either grab the Windows installer from the project’s download page or install on Linux with a command (specific to your distro) such as:

sudo apt install git  

The next thing we need to do is set up a git repository, which is just a folder holding your project. To take advantage of Git versioning, you need to initialize the folder as a repository. You can do this at a command line with the following command:

git init  

git init fileman

You may not see anything once this completes, but enable the “show hidden files” option in your file manager, and you’ll see there’s a new .git folder (as shown in the above image). This is where git keeps all its info so it’s out of your way.

2. Add and Commit Your First File

The next step is to create some content (files) in your project. These can be any type of file, as most programming projects are made up of code (text) and assets like graphics (binary) Everything You Need to Know About File Formats and Their Properties Everything You Need to Know About File Formats and Their Properties We use the word file interchangeably: music, image, spreadsheet, slideshow, and so on. But what makes a file a “file,” anyway? Let’s try and understand this fundamental part of computing. Read More . Once created, do the following at the command line while still in your project directory:

git status  

git status

The first step to a commit is to “stage” the new or updated items. See how the above output lets you know there are “unstaged” changes? You can stage everything in your directory (recursively, i.e. to include sub-folders and their files) with this command:

git -a .  

The “-a” flag is for “add,” and the period refers to the current directory. It’s basically saying “add all files to the my commit.” Now to actually make the commit, type the following:

git commit -m "WHOOP, my first commit!"  

git add commit

Now when you check the status again, there should be no waiting changes. To see the commit itself, check the git log, using graph mode, with listing cut to one line, and decorated for readability:

git log --all --decorate --oneline --graph  

git log

This will show you a nice timeline of your commit, with the most recent on top.

3. Create a Branch to Experiment

As you’re working, you may want to go off in a particular direction, not knowing if it’s going to work out. For this you’ll want to create a branch with the following command:

git branch experiment1  git checkout experiment1  

git branch

The second command switches you to the “experiment1” branch. You can switch back by replacing it with “master.” As you start working on your text, note the difference between the same file from each branch. First, the “experiment1” branch with your new text:

git branch experiment1

Compare this to the original:

git branch master

Now after working for a while (ending with a new commit), the best you could come up with is “Lorem ipsum dolor sit amet…?” What is that? It’s nonsense, and should be stricken from your project immediately. You can trash your branch with the following command (“-D” for force delete):

git branch -D experiment1  

git branch delete

Now start another branch and add something intelligent, along with some images:

git branch experiment2  git checkout experiment2 git add . git commit -m "More text, added images"  

git add commit branch

4. Merge Your Changes

Finally, once you’re happy with the changes in your current branch the following command will merge them with the “master” branch. Provided you haven’t been doing a lot of hopping back and forth between the two, this will result in all your new changes being applied, and a new revision created. The following at the command-line will combine them for you:

git merge experiment2  

git post merge

Now you’ll have a revision that combines the latest in “master” with the latest in “experiment2.” At this point you can get rid of the experiment (it was successful after all) with the following:

git branch -d experiment2  

Note that you’ll only lose any of the incremental changes you made within that branch if you do so.

5. Push to a Safe Place

Lastly, Git is a distributed system, which means you can have multiple copies of your repository and sync them up. For example, create a new repository on a server you can SSH into How to Remotely Manage a Linux Server with SSH How to Remotely Manage a Linux Server with SSH SSH is very functional, which is why it’s a go-to for remote server management. Learn how to remotely manage a Linux server via SSH, from connection, to installing software, and file transfers. Read More with this command:

git init --bare  

The “–bare” flag sets it up as a sort of read-only repository, in that you can’t modify the files directly. Then you can set that as a remote copy of your local repository with the following (the first command ensures new local branches are created remotely):

git config push.default matching  git remote add central ssh://[username]@[URL]/path/to/repository git push --set-upstream central master  

git remote

Set Up for Versioning and Backup With Git

With the above setup, you can follow a simple process to keep all the work you do on a project not only versioned, but backed up as well.

  1. Make changes to project files.
  2. Issue “git add .” to add all changes to a commit.
  3. Issue “git commit -m [some message]” to commit the changes to your local repository. Repeat from the start.
  4. Issue “git push” to commit the changes to a remote repository at regular intervals.
  5. Issue “git clone ssh://[username]@[URL]/path/to/repository” from some other machine to

Do the benefits of version control systems something that interests you? Or are the non-development backup applications enough for your needs? Let us know your thoughts in the comments below!

0 comments Write a Comment

Shared via Inoreader

Manage Your File Versioning Like a Programmer With Git

如何免费的让网站启用HTTPS

by 陈皓

IT牛人博客聚合网站 / 2017-08-26 17:08

enable-https-banner.png今天,我把CoolShell变成https的安全访问了。我承认这件事有点晚了,因为之前的HTTP的问题也有网友告诉我,被国内的电信运营商在访问我的网站时加入了一些弹窗广告。另外,HTTP的网站在搜索引擎中的rank会更低。所以,这事早就应该干了。现在用HTTP访问CoolShell会被得到一个 301 的HTTPS的跳转。下面我分享一下启用HTTPS的过程。

我用的是Let’s Encrypt这个免费的解决方案。Let’s Encrypt 是一个于2015年推出的数字证书认证机构,将通过旨在消除当前手动创建和安装证书的复杂过程的自动化流程,为安全网站提供免费的SSL/TLS证书。这是由互联网安全研究小组(ISRG – Internet Security Research Group,一个公益组织)提供的服务。主要赞助商包括电子前哨基金会Mozilla基金会Akamai以及Cisco等公司(赞助商列表)。

2015年6月,Let’s Encrypt得到了一个存储在硬件安全模块中的离线的RSA根证书。这个由IdenTrust证书签发机构交叉签名的根证书被用于签署两个证书。其中一个就是用于签发请求的证书,另一个则是保存在本地的证书,这个证书用于在上一个证书出问题时作备份证书之用。因为IdenTrust的CA根证书目前已被预置于主流浏览器中,所以Let’s Encrypt签发的证书可以从项目开始就被识别并接受,甚至当用户的浏览器中没有信任ISRG的根证书时也可以。

以上介绍文字来自 Wikipedia 的Let’s Encrypt 词条

为你的网站来安装一个证书十分简单,只需要使用电子子前哨基金会EFF的Certbot,就可以完成。

1)首先,打开 https://certbot.eff.org网页。

2)在那个机器上图标下面,你需要选择一下你用的 Web 接入软件 和你的 操作系统。比如,我选的,nginx 和Ubuntu 14.04

3)然后就会跳转到一个安装教程网页。你就照着做一遍就好了。

Coolshell.cn为例 – Nginx + Ubuntu

首先先安装相应的环境:

   $ sudo apt-get update   $ sudo apt-get install software-properties-common   $ sudo add-apt-repository ppa:certbot/certbot   $ sudo apt-get update   $ sudo apt-get install python-certbot-nginx   

然后,运行如下命令:

   $ sudo certbot --nginx   

certbot会自动检查到你的nginx.conf下的配置,把你所有的虚拟站点都列出来,然后让你选择需要开启 https 的站点。你就简单的输入列表编号(用空格分开),然后,certbot 就帮你下载证书并更新nginx.conf了。

你打开你的nginx.conf 文件 ,你可以发现你的文件中的server 配置中可能被做了如下的修改:

listen 443 ssl; # managed by Certbot   ssl_certificate /etc/letsencrypt/live/coolshell.cn/fullchain.pem; # managed by Certbot   ssl_certificate_key /etc/letsencrypt/live/coolshell.cn/privkey.pem; # managed by Certbot   include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

 # Redirect non-https traffic to https   if ($scheme != "https") {     return 301 https://$host$request_uri;   } # managed by Certbot

 

这里建议配置 http2,这要求 Nginx 版本要大于 1.9.5。HTTP2 具有更快的 HTTPS 传输性能,非常值得开启(关于性能你可以看一下这篇文章)。需要开启HTTP/2其实很简单,只需要在nginx.conf 的listen 443 ssl; 后面加上http2 就好了。如下所示:

listen 443 ssl http2; # managed by Certbot   ssl_certificate /etc/letsencrypt/live/coolshell.cn/fullchain.pem; # managed by Certbot   ssl_certificate_key /etc/letsencrypt/live/coolshell.cn/privkey.pem; # managed by Certbot   include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

然后,就nginx -s reload 就好了。

但是,Let’s Encrypt 的证书90天就过期了 ,所以,你还要设置上自动化的更新脚本,最容易的莫过于使用crontab 了。使用crontab -e 命令加入如下的定时作业(每个月都强制更新一下):

0 0 1 * * /usr/bin/certbot renew --force-renewal   5 0 1 * * /usr/sbin/service nginx restart

当然,你也可以每天凌晨1点检查一下:

0 1 * * * certbot renew 

注:crontab 中有六个字段,其含义如下:

  • 第1个字段:分钟 (0-59)
  • 第2个字段:小时 (0-23)
  • 第3个字段:日期 (1-31)
  • 第4个字段:月份 (1-12 [12 代表 December])
  • 第5个字段:一周当中的某天 (0-7 [7 或 0 代表星期天])
  • /path/to/command – 计划执行的脚本或命令的名称

这么方便的同时,我不禁要问,如果是一些恶意的钓鱼网站也让自己的站点变成https的,这个对于一般用来说就有点难以防范了。哎……

当然,在nginx或apache上启用HTTPS后,还没有结束。因为你可能还需要修改一下你的网站,不然你的网站在浏览时会出现各种问题。

启用HTTPS后,你的网页中的所有的使用http:// 的方式的地方都要改成https:// 不然你的图片,js, css等非https的连接都会导致浏览器抱怨不安全而被block掉 。所以,你还需要修改你的网页中那些 hard codehttp:// 的地方。

对于我这个使用wordpress的博客系统来说,有这么几个部分需要做修改。

1)首先是 wordpress的 常规设置中的 “WordPress 地址 ” 和 “站点地址 ” 需要变更为 https 的方式。

2)然后是文章内的图片等资源的链接需要变更为 https 的方式。对此,你可以使用一个叫 “Search Regex” 插件来批量更新你历史文章里的图片或别的资源的链接。比如:把http://coolshell.cn 替换成了https://coolshell.cn

3)如果你像我一样启用了文章缓存(我用的是WP-SuperCache插件),你还要去设置一下 “CDN ” 页面中的 “Site URL” 和 “off-site URL” 确保生成出来的静态网页内是用https做资源链接的。

基本上就是这些事。希望大家都来把自己的网站更新成 https 的。

嗯,12306,你什么时候按照这个教程做一下你的证书?

(全文完)

qrcode_for_gh_dd9d8c843f20_860-300x300.j
关注CoolShell微信公众账号可以在手机端搜索文章

(转载本站文章请注明作者和出处酷 壳 – CoolShell,请勿用于任何商业用途)

——===访问酷壳404页面寻找遗失儿童。===——

Shared via Inoreader

如何免费的让网站启用HTTPS