mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-27 02:30:10 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
3ecb4a8213
published
201512
20150410 How to Install and Configure Multihomed ISC DHCP Server on Debian Linux.md20150806 Installation Guide for Puppet on Ubuntu 15.04.md20150824 How to Setup Zephyr Test Management Tool on CentOS 7.x.md20150831 Linux workstation security checklist.md20150917 A Repository with 44 Years of Unix Evolution.md20151012 The Brief History Of Aix HP-UX Solaris BSD And LINUX.md20151020 how to h2 in apache.md20151022 9 Tips for Improving WordPress Performance.md20151030 How To Install FreeBSD on Raspberry Pi 2 Model B.md20151104 How to Install Redis Server on CentOS 7.md20151105 Linus Torvalds Lambasts Open Source Programmers over Insecure Code.md20151109 How to Monitor the Progress of a Linux Command Line Operation Using PV Command.md20151109 How to Set Up AWStats On Ubuntu Server.md20151117 Install PostgreSQL 9.4 And phpPgAdmin On Ubuntu 15.10.md20151123 7 ways hackers can use Wi-Fi against you.md20151123 How to access Dropbox from the command line in Linux.md20151123 How to install Android Studio on Ubuntu 15.04 or CentOS 7.md20151123 LNAV--Ncurses based log file viewer.md20151125 How to Install GIMP 2.8.16 in Ubuntu 16.04 or 15.10 or 14.04.md20151125 The tar command explained.md20151130 eSpeak--Text To Speech Tool For Linux.md20151201 How to Install The Latest Arduino IDE 1.6.6 in Ubuntu.md20151201 Linux and Unix Port Scanning With netcat [nc] Command.md20151202 How to use the Linux ftp command to up- and download files on the shell.md20151204 How to Remove Banned IP from Fail2ban on CentOS 6 or CentOS 7.md20151208 Apple Swift Programming Language Comes To Linux.md20151208 How to Customize Time and Date Format in Ubuntu Panel.md20151208 Install Wetty on Centos or RHEL 6.X.md20151215 How to enable Software Collections (SCL) on CentOS.md20151215 Linux or UNIX Desktop Fun--Let it Snow On Your Desktop.md20151215 Linux or UNIX Desktop Fun--Steam Locomotive.md20151215 Linux or UNIX Desktop Fun--Terminal ASCII Aquarium.md20151215 Linux or Unix Desktop Fun--Cat And Mouse Chase All Over Your Screen.md20151229 Watch Star Wars In Linux Terminal.md
20151222 Turn Tor socks to http.mdsources
talk
20150921 14 tips for teaching open source development.md20151020 30 Years of Free Software Foundation--Best Quotes of Richard Stallman.md20151125 20 Years of GIMP Evolution--Step by Step.md
tech
20151123 How to Install Cockpit in Fedora or CentOS or RHEL or Arch Linux.md20151215 How to Install Light Table 0.8 in Ubuntu 14.04, 15.10.md20151215 Linux or Unix Desktop Fun--Text Mode ASCII-art Box and Comment Drawing.md20151225 What are the best plugins to increase productivity on Emacs.md20160104 How to Check Hardware Information on Linux Using Command Line.md20160104 How to use KVM from the command line on Debian or Ubuntu.md20160104 What is good stock portfolio management software on Linux.md
LFCS
Part 10 - LFCS--Understanding and Learning Basic Shell Scripting and Linux Filesystem Troubleshooting.mdPart 5 - LFCS--How to Mount or Unmount Local and Network Samba and NFS Filesystems in Linux.mdPart 6 - LFCS--Assembling Partitions as RAID Devices – Creating & Managing System Backups.mdPart 7 - LFCS--Managing System Startup Process and Services SysVinit Systemd and Upstart.mdPart 8 - LFCS--Managing Users and Groups File Permissions and Attributes and Enabling sudo Access on Accounts.md
[翻译中]20151223 How to Setup SSH Login Without Password CentOS or RHEL.mdtranslated/tech
20151123 How to Install Cockpit in Fedora or CentOS or RHEL or Arch Linux.md20151225 What are the best plugins to increase productivity on Emacs.md20151229 Watch Star Wars In Linux Terminal.md
LFCS
Part 2 - LFCS--How to Install and Use vi or vim as a Full Text Editor.mdPart 4 - LFCS--Partitioning Storage Devices, Formatting Filesystems and Configuring Swap Partition.mdPart 5 - LFCS--How to Mount or Unmount Local and Network Samba and NFS Filesystems in Linux.mdPart 8 - LFCS--Managing Users and Groups File Permissions and Attributes and Enabling sudo Access on Accounts.md
@ -0,0 +1,55 @@
|
||||
在 Linux 终端下看《星球大战》
|
||||
================================================================================
|
||||

|
||||
|
||||
《星球大战(Star Wars)》已经席卷世界。最新一期的 [《星球大战》系列, 《星球大战7:原力觉醒》,打破了有史以来的记录][1]。
|
||||
|
||||
虽然我不能帮你得到一张最新的《星球大战》的电影票,但我可以提供给你一种方式,看[星球大战第四集][2],它是非常早期的《星球大战》电影(1977 年)。
|
||||
|
||||
|
||||
不,它不会是高清,也不是蓝光版。相反,它将是 ASCII 版的《星球大战》第四集,你可以在 Linux 终端看它,这才是真正的极客的方式 :)
|
||||
|
||||
### 在 Linux 终端看星球大战 ###
|
||||
|
||||
打开一个终端,使用以下命令:
|
||||
|
||||
telnet towel.blinkenlights.nl
|
||||
|
||||
等待几秒钟,你可以在终端看到类似于以下这样的动画ASCII艺术:
|
||||
|
||||
(LCTT 译注:有时候会解析到效果更好 IPv6 版本上,如果你没有 IPv6 地址,可以重新连接试试;另外似乎线路不稳定,出现卡顿时稍等。)
|
||||
|
||||

|
||||
|
||||
它将继续播映……
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
要停止动画,按 ctrl +],在这之后输入 quit 来退出 telnet 程序。
|
||||
|
||||
### 更多有趣的终端 ###
|
||||
|
||||
事实上,看《星球大战》并不是你在 Linux 终端下唯一能做有趣的事情。您可以运行[终端里的列车][3]或[通过ASCII艺术得到Linux标志][4]。
|
||||
|
||||
希望你能享受在 Linux 下看《星球大战》。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/star-wars-linux/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.gamespot.com/articles/star-wars-7-breaks-thursday-night-movie-opening-re/1100-6433246/
|
||||
[2]:http://www.imdb.com/title/tt0076759/
|
||||
[3]:http://itsfoss.com/ubuntu-terminal-train/
|
||||
[4]:http://itsfoss.com/display-linux-logo-in-ascii/
|
@ -1,16 +1,18 @@
|
||||
将Tor socks转换成http
|
||||
将 Tor socks 转换成 http 代理
|
||||
================================================================================
|
||||

|
||||
|
||||
使用tor服务你可以使用不同的工具像Tor浏览器、Foxyproxy和其他事情,有些下载管理器像wget和aria2不能直接直接使用tor socks开始匿名下载,因此我们需要一些工具来将tor socks转换成http代理这样就能用它来下载了。
|
||||
你可以通过不同的 Tor 工具来使用 Tor 服务,如 Tor 浏览器、Foxyproxy 和其它东西,像 wget 和 aria2 这样的下载管理器不能直接使用 Tor socks 开始匿名下载,因此我们需要一些工具来将 Tor socks 转换成 http 代理,这样就能用它来下载了。
|
||||
|
||||
**注意**:本教程基于Debian下,其他发行版会有些不同,因此如果你的发行版是基于Debian的,就可以直接使用下面的配置了。
|
||||
**注意**:本教程基于 Debian ,其他发行版会有些不同,因此如果你的发行版是基于 Debian 的,就可以直接使用下面的配置了。
|
||||
|
||||
**Polipo** : 这个服务会使用8123端口和127.0.0.1的IP,使用下面的命令来在计算机上安装Polipo:
|
||||
### Polipo
|
||||
|
||||
这个服务会使用 8123 端口和 127.0.0.1 的 IP 地址,使用下面的命令来在计算机上安装 Polipo:
|
||||
|
||||
sudo apt install polipo
|
||||
|
||||
现在使用这个命令打开Polipo的配置文件:
|
||||
现在使用如下命令打开 Polipo 的配置文件:
|
||||
|
||||
sudo nano /etc/polipo/config
|
||||
|
||||
@ -21,17 +23,19 @@
|
||||
socksParentProxy = "localhost:9050"
|
||||
socksProxyType = socks5
|
||||
|
||||
用下面的命令来重启Polipo:
|
||||
用如下的命令来重启 Polipo:
|
||||
|
||||
sudo service polipo restart
|
||||
|
||||
现在Polipo已经安装好了!在匿名的世界里做你想做的吧!下面是使用的例子:
|
||||
现在 Polipo 已经安装好了!在匿名的世界里做你想做的吧!下面是使用的例子:
|
||||
|
||||
pdmt -l "link" -i 127.0.01 -p 8123
|
||||
|
||||
用上面的命令PDMT(Persian下载器)会匿名地下载你的文件。
|
||||
通过上面的命令 PDMT(Persian 下载器终端)会匿名地下载你的文件。
|
||||
|
||||
**Proxychains** : 在此服务中你可以设置使用tor或者Lantern代理,但是在使用上它和Polipo和Privoxy有点不同,它不需要使用任何端口!使用下面的命令来安装:
|
||||
### Proxychains
|
||||
|
||||
在此服务中你可以设置使用 Tor 或者 Lantern 代理,但是在使用上它和 Polipo 和 Privoxy 有点不同,它不需要使用任何端口!使用下面的命令来安装:
|
||||
|
||||
sudo apt install proxychains
|
||||
|
||||
@ -39,17 +43,19 @@
|
||||
|
||||
sudo nano /etc/proxychains.conf
|
||||
|
||||
现在添加下面的代码到文件底部,这里是tor的端口和IP:
|
||||
现在添加下面的代码到文件底部,这里是 Tor 的端口和 IP:
|
||||
|
||||
socks5 127.0.0.1 9050
|
||||
|
||||
如果你在命令的前面加上“proxychains”并运行,它就能通过tor代理来运行:
|
||||
如果你在命令的前面加上“proxychains”并运行,它就能通过 Tor 代理来运行:
|
||||
|
||||
proxychains firefoxt
|
||||
proxychains aria2c
|
||||
proxychains wget
|
||||
|
||||
**Privoxy** : Privoxy使用8118端口,并且首次可以很轻松地通过privoxy包来安装:
|
||||
### Privoxy
|
||||
|
||||
Privoxy 使用 8118 端口,可以很轻松地通过 privoxy 包来安装:
|
||||
|
||||
sudo apt install privoxy
|
||||
|
||||
@ -71,7 +77,7 @@
|
||||
|
||||
sudo service privoxy restart
|
||||
|
||||
服务已经好了!端口是8118,IP是127.0.0.1,就尽情使用吧!
|
||||
服务已经好了!端口是 8118,IP 是 127.0.0.1,就尽情使用吧!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -79,7 +85,7 @@ via: http://www.unixmen.com/turn-tor-socks-http/
|
||||
|
||||
作者:[Hossein heydari][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,3 +1,5 @@
|
||||
GHLandy Translating
|
||||
|
||||
14 tips for teaching open source development
|
||||
================================================================================
|
||||
Academia is an excellent platform for training and preparing the open source developers of tomorrow. In research, we occasionally open source software we write. We do this for two reasons. One, to promote the use of the tools we produce. And two, to learn more about the impact and issues other people face when using them. With this background of writing research software, I was tasked with redesigning the undergraduate software engineering course for second-year students at the University of Bradford.
|
||||
|
@ -1,3 +1,5 @@
|
||||
For my dear RMS
|
||||
|
||||
30 Years of Free Software Foundation: Best Quotes of Richard Stallman
|
||||
================================================================================
|
||||
注:youtube 视频
|
||||
@ -167,4 +169,4 @@ via: https://tlhp.cf/fsf-richard-stallman/
|
||||
|
||||
[a]:https://tlhp.cf/author/paul/
|
||||
[1]:http://www.gnu.org/
|
||||
[2]:http://www.fsf.org/
|
||||
[2]:http://www.fsf.org/
|
||||
|
@ -1,3 +1,5 @@
|
||||
GHLandy Translating
|
||||
|
||||
20 Years of GIMP Evolution: Step by Step
|
||||
================================================================================
|
||||
注:youtube 视频
|
||||
@ -168,4 +170,4 @@ via: https://tlhp.cf/20-years-of-gimp-evolution/
|
||||
|
||||
[a]:https://tlhp.cf/author/paul/
|
||||
[1]:https://gimp.org/
|
||||
[2]:http://www.gnu.org/
|
||||
[2]:http://www.gnu.org/
|
||||
|
@ -1,148 +0,0 @@
|
||||
How to Install Cockpit in Fedora / CentOS / RHEL/ Arch Linux
|
||||
================================================================================
|
||||
Cockpit is a free and open source server management software that makes us easy to administer our GNU/Linux servers via its beautiful web interface frontend. Cockpit helps make linux system administrator, system maintainers and DevOps easy to manage their server and to perform simple tasks, such as administering storage, inspecting journals, starting and stopping services and more. Its journal interface adds aroma in flower making people easy to switch between the terminal and web interface. And moreover, it makes easy to manage not only one server but several multiple networked servers from a single place at the same time with just a single click. It is very light weight and has easy to use web based interface. In this tutorial, we'll learn how we can setup Cockpit and use it to manage our server running Fedora, CentOS, Arch Linux and RHEL distributions as their operating system software. Some of the awesome benefits of Cockpit in our GNU/Linux servers are as follows:
|
||||
|
||||
1. It consist of systemd service manager for ease.
|
||||
1. It has a Journal log viewer to perform troubleshoots and log analysis.
|
||||
1. Storage setup including LVM was never easier before.
|
||||
1. Basic Network configuration can be applied with Cockpit
|
||||
1. We can easily add and remove local users and manage multiple servers.
|
||||
|
||||
### 1. Installing Cockpit ###
|
||||
|
||||
First of all, we'll need to setup Cockpit in our linux based server. In most of the distributions, the cockpit package is already available in their official repositories. Here, in this tutorial, we'll setup Cockpit in Fedora 22, CentOS 7, Arch Linux and RHEL 7 from their official repositories.
|
||||
|
||||
#### On CentOS / RHEL ####
|
||||
|
||||
Cockpit is available in the official repository of CenOS and RHEL. So, we'll simply install it using yum manager. To do so, we'll simply run the following command under sudo/root access.
|
||||
|
||||
# yum install cockpit
|
||||
|
||||

|
||||
|
||||
#### On Fedora 22/21 ####
|
||||
|
||||
Alike, CentOS, it is also available by default in Fedora's official repository, we'll simply install cockpit using dnf package manager.
|
||||
|
||||
# dnf install cockpit
|
||||
|
||||

|
||||
|
||||
#### On Arch Linux ####
|
||||
|
||||
Cockpit is currently not available in the official repository of Arch Linux but it is available in the Arch User Repository also know as AUR. So, we'll simply run the following yaourt command to install it.
|
||||
|
||||
# yaourt cockpit
|
||||
|
||||

|
||||
|
||||
### 2. Starting and Enabling Cockpit ###
|
||||
|
||||
After we have successfully installed it, we'll gonna start the cockpit server with our service/daemon manager. As of 2015, most of the linux distributions have adopted Systemd whereas some of the linux distributions still run SysVinit to manage daemon, but Cockpit uses systemd for almost everything from running daemons to services. So, we can only setup Cockpit in the latest releases of linux distributions running Systemd. In order to start Cockpit and make it start in every boot of the system, we'll need to run the following command in a terminal or a console.
|
||||
|
||||
# systemctl start cockpit
|
||||
|
||||
# systemctl enable cockpit.socket
|
||||
|
||||
Created symlink from /etc/systemd/system/sockets.target.wants/cockpit.socket to /usr/lib/systemd/system/cockpit.socket.
|
||||
|
||||
### 3. Allowing Firewall ###
|
||||
|
||||
After we have started our cockpit server and enable it to start in every boot, we'll now go for configuring firewall. As we have firewall programs running in our server, we'll need to allow ports in order to make cockpit accessible outside of the server.
|
||||
|
||||
#### On Firewalld ####
|
||||
|
||||
# firewall-cmd --add-service=cockpit --permanent
|
||||
|
||||
success
|
||||
|
||||
# firewall-cmd --reload
|
||||
|
||||
success
|
||||
|
||||

|
||||
|
||||
#### On Iptables ####
|
||||
|
||||
# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
||||
|
||||
# service iptables save
|
||||
|
||||
### 4. Accessing Cockpit Web Interface ###
|
||||
|
||||
Next, we'll gonna finally access the Cockpit web interface using a web browser. We'll simply need to point our web browser to https://ip-address:9090 or https://server.domain.com:9090 according to the configuration. Here, in our tutorial, we'll gonna point our browser to https://128.199.114.17:9090 as shown in the image below.
|
||||
|
||||

|
||||
|
||||
We'll be displayed an SSL certification warning as we are using a self-signed SSL certificate. So, we'll simply ignore it and go forward towards the login page, in chrome/chromium, we'll need to click on Show Advanced and then we'll need to click on **Proceed to 128.199.114.17 (unsafe)** .
|
||||
|
||||

|
||||
|
||||
Now, we'll be asked to enter the login details in order to enter into the dashboard. Here, the username and password is the same as that of the login details we use to login to our linux server. After we enter the login details and click on Log In button, we will be welcomed into the Cockpit Dashboard.
|
||||
|
||||

|
||||
|
||||
Here, we'll see all the menu and visualization of CPU, Disk, Network, Storage usages of the server. We'll see the dashboard as shown above.
|
||||
|
||||
#### Services ####
|
||||
|
||||
To manage services, we'll need to click on Services button on the menu situated in the right side of the web page. Then, we'll see the services under 5 categories, Targets, System Services, Sockets, Timers and Paths.
|
||||
|
||||

|
||||
|
||||
#### Docker Containers ####
|
||||
|
||||
We can even manage docker containers with Cockpit. It is pretty easy to monitor and administer Docker containers with Cockpit. As docker isn't installed and running in our server, we'll need to click on Start Docker.
|
||||
|
||||

|
||||
|
||||
Cockpit will automatically install and run docker in our server. After its running, we see the following screen. Then, we can manage the docker images, containers as per our requirement.
|
||||
|
||||

|
||||
|
||||
#### Journal Log Viewer ####
|
||||
|
||||
Cockpit has a managed log viewer which separates the Errors, Warnings, Notices into different tabs. And we also have a tab All where we can see them all in a single place.
|
||||
|
||||

|
||||
|
||||
#### Networking ####
|
||||
|
||||
Under the networking section, we see two graphs in which there is the visualization of Sending and Receiving speed. And we can see there the list of available interfaces with option to Add Bond, Bridge, VLAN. If we need to configure an interface, we can do so by simply clicking on the interface name. Below everything, we can see the Journal Log Viewer for Networking.
|
||||
|
||||

|
||||
|
||||
#### Storage ####
|
||||
|
||||
Now, its easy with Cockpit to see the R/W speed of our hard disk. We can see the Journal log of the Storage in order to perform troubleshoot and fixes. A clear visualization bar of how much space is occupied is shown in the page. We can even Unmount, Format, Delete a partition of a Hard Disk and more. Features like creating RAID Device, Volume Group is also available in it.
|
||||
|
||||

|
||||
|
||||
#### Account Management ####
|
||||
|
||||
We can easily create new accounts with Cockpit Web Interface. The accounts created in it is applied to the system's user account. We can change password, specify roles, delete, rename user accounts with it.
|
||||
|
||||

|
||||
|
||||
#### Live Terminal ####
|
||||
|
||||
This is an awesome feature built-in with Cockpit. Yes, we can execute commands, do stuffs with the live terminal provided by Cockpit interface. This makes us really easy to switch between the web interface and terminal according to our need.
|
||||
|
||||

|
||||
|
||||
### Conclusion ###
|
||||
|
||||
Cockpit is a good free and open source software developed by [Red Hat][1] for making the server management easy and simple. It is best for performing simple system administration tasks and is good for the new system administrators. It is still under pre-release as its stable release hasn't been released yet. So, it is not suitable for production. It is currently developed on the latest release of Fedora, CentOS, Arch Linux, RHEL where systemd is installed by default. If you are willing to install Cockpit in Ubuntu, you can get the PPA access but is currently outdated. If you have any questions, suggestions, feedback please write them in the comment box below so that we can improve or update our contents. Thank You !
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-how-to/install-cockpit-fedora-centos-rhel-arch-linux/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
||||
[1]:http://www.redhat.com/
|
@ -1,3 +1,4 @@
|
||||
翻译中
|
||||
How to Install Light Table 0.8 in Ubuntu 14.04, 15.10
|
||||
================================================================================
|
||||

|
||||
@ -101,4 +102,4 @@ via: http://ubuntuhandbook.org/index.php/2015/12/install-light-table-0-8-ubuntu-
|
||||
|
||||
[a]:http://ubuntuhandbook.org/index.php/about/
|
||||
[1]:https://github.com/LightTable/LightTable/releases
|
||||
[2]:https://github.com/LightTable/LightTable/releases/download/0.8.0/lighttable-0.8.0-linux.tar.gz
|
||||
[2]:https://github.com/LightTable/LightTable/releases/download/0.8.0/lighttable-0.8.0-linux.tar.gz
|
||||
|
@ -1,3 +1,4 @@
|
||||
翻译中
|
||||
Linux / Unix Desktop Fun: Text Mode ASCII-art Box and Comment Drawing
|
||||
================================================================================
|
||||
Boxes command is a text filter and a little known tool that can draw any kind of ASCII art box around its input text or code for fun and profit. You can quickly create email signatures, or create regional comments in any programming language. This command was intended to be used with the vim text editor, but can be tied to any text editor which supports filters, as well as from the command line as a standalone tool.
|
||||
@ -190,7 +191,7 @@ See also
|
||||
via: http://www.cyberciti.biz/tips/unix-linux-draw-any-kind-of-boxes-around-text-editor.html
|
||||
|
||||
作者:Vivek Gite
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
@ -198,4 +199,4 @@ via: http://www.cyberciti.biz/tips/unix-linux-draw-any-kind-of-boxes-around-text
|
||||
[1]:http://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html
|
||||
[2]:http://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/
|
||||
[3]:http://www.cyberciti.biz/faq/fedora-sl-centos-redhat6-enable-epel-repo/
|
||||
[4]:http://www.cyberciti.biz/faq/vim-inserting-current-date-time-under-linux-unix-osx/
|
||||
[4]:http://www.cyberciti.biz/faq/vim-inserting-current-date-time-under-linux-unix-osx/
|
||||
|
@ -1,79 +0,0 @@
|
||||
zky001翻译中
|
||||
What are the best plugins to increase productivity on Emacs
|
||||
================================================================================
|
||||
Over a year ago now, I went looking for the best plugins to [turn Vim into a full-fledged IDE][1]. Interestingly, a lot of the comments on that post were about how Emacs already has most of these plugins built in, and was already a great IDE. Although I can only agree about Emacs' incredible versatility, it is still not the ultimate editor when it comes out of the box. Thankfully, its vast plugin library is here to fix that. But among the plethora of options available to you, it is sometimes hard to know where to start. So for now, let me try to assemble a short list of the indispensable plugins to increase your productivity while using Emacs. Although I am heavily geared towards programming related productivity, most of these plugins would be useful to anyone for any usage.
|
||||
|
||||
### 1. Ido-mode ###
|
||||
|
||||

|
||||
|
||||
Maybe one of the most useful plugin for beginners, Ido stands for interactively do. It replaces most of the dry prompts with a fancy character matching menu. For example, it will replace the normal prompt to open a file with a list of all the files in the current directory. Type any string, and Ido will try to match it with the most appropriate file. It makes it really easy to visualize your actions, and also to quickly get through a folder where all files are named with the same prefix.
|
||||
|
||||
### 2. Smex ###
|
||||
|
||||

|
||||
|
||||
Not the most famous one, but a good place to complete what Ido-mode started: Smex can be a fancy replacement to the normal 'M-x' prompt, with a heavy inspiration from Ido-mode. It brings the same interactive search for the commands you would normally have to type after calling 'M-x'. It is simple and efficient, and a great way to save those additional few fractions of a second you normally need.
|
||||
|
||||
### 3. Auto Complete ###
|
||||
|
||||

|
||||
|
||||
Before knowing the existence of this plugin, I spent half of my time on Emacs pressing ‘M-/’ to complete my words. Now, I have a fancy pop-up to do it for me. There is not much more to say about it, except that we all need it.
|
||||
|
||||
### 4. YASnippet ###
|
||||
|
||||

|
||||
|
||||
This one is really for the coders. There is always some piece of code that we feel we use all the time. For me, it's 'var_dump(...); exit;' to debug PHP. After a while of typing it over and over, it just occurred to me that I could have it pre-recorded and easily accessible as a snippet of code. With YASnippets, it's easy to import snippet files or make your own. After that, a simple press on the tabulation key will expand a small keyword into a chunk of pre-written code easy to navigate through and modify.
|
||||
|
||||
### 5. Org-mode ###
|
||||
|
||||

|
||||
|
||||
For disclaimer, I have only recently started using Org-mode. But it has already blown me away. From the hundreds of written pieces I have seen around, Org-mode can change your life. The idea behind it is simple: it is a mode that simplifies note taking while keeping a plain text format, making it easy to navigate through lists of tasks and various data, and perform operations such as filtering by priority or due date, or setting a recurrence. Yet, from this simple idea, you can accomplish a lot, and it is easy to get overwhelmed with all the options. Rather than a long explanation, I urge you to go through [available tutorials][2], watch a lot of videos, and see by yourself how powerful Org-mode is.
|
||||
|
||||
### 6. Helm ###
|
||||
|
||||

|
||||
|
||||
Some love it, but others are not such a big fan of it. I am part of the later. But with such a huge following, it is impossible to avoid it. Helm aims to transform your Emacs experience completely. Simply described, Helm is a framework that will help you find a file or a command quickly from within Emacs. Based on your input, it will try to use word completion to guide you to the action you have in mind. The feeling is a bit weird at first, but for some, Helm is a religion of its own. Although I am not its fan, I do appreciate helm-occur which a great tool to search for strings in a large document as it shows all occurrences in a separate buffer, making it easy to navigate through them. If you are looking for a quick demo to understand what Helm can do, I recommend [this post][3].
|
||||
|
||||
### 7. ace-jump-mode ###
|
||||
|
||||

|
||||
|
||||
Another plugin with a big following that I am trying to get on board with is ace-jump-mode. Master this plugin, and you will be promised to transcend the usage of a mouse. Simply described, by triggering ace-jump-mode with a shortcut of your choice, you will be prompted for a character. Enter one, and all words starting with that character will be highlighted with a unique letter. Enter one of the letters on screen, and your cursor will jump straight to the word it is highlighting. I have to admit that it is pretty hard to get the reflex to use it, but once you have it, it will increase your movement speed in a document by a lot.
|
||||
|
||||
### 8. find-file-in-project ###
|
||||
|
||||

|
||||
|
||||
If you like Sublime text and its very handy 'Ctrl-p' fuzzy search to open any file in a project, then you will love find-file-in-project (or ffip). After setting it up by declaring the root of your version control folder, you can summon easily a cool text bar that quickly scans and searches through your code base for a matching file based on the name you input. I like to have it bound to the F6 key on my keyboard. It is simple and very handy if you do not know the complicate directory structure from the top of your head.
|
||||
|
||||
### 9. Flymake ###
|
||||
|
||||

|
||||
|
||||
For IDE lovers, I think that syntax checker is one of the most powerful features. It is great for beginners and handy for tired programmers. And thanks to Flymake, Emacs users can enjoy it too. Since I work in PHP a lot, Flymake does not need any extra configuration. As I write my code, it will automatically check my code and highlight any line that contains a problem. For compiled languages, Flymake will look for a Makefile that it will use to check your code. Absolutely magical.
|
||||
|
||||
### 10. electric-pair ###
|
||||
|
||||
Last, but not least, electric-pair is one of the simplest yet most powerful plugin in my opinion. It just automatically closes whatever parenthesis or bracket you open. It doesn't look like much at first, but trust me. After struggling for the hundredth time to find that matching parenthesis, you will be glad to have a plugin to ensure that all your expressions are balanced.
|
||||
|
||||
To conclude, Emacs is a fantastic tool. Probably not a shocker. Try these plugins and watch as your productivity goes through the roof. This list is of course not exhaustive at all. If you want to bring your contribution, feel free to do so in the comments. I am myself always looking for new plugins to try and new ways to experience Emacs.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/best-plugins-to-increase-productivity-on-emacs.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://xmodulo.com/turn-vim-full-fledged-ide.html
|
||||
[2]:http://orgmode.org/worg/org-tutorials/
|
||||
[3]:http://tuhdo.github.io/helm-intro.html
|
@ -0,0 +1,150 @@
|
||||
How to Check Hardware Information on Linux Using Command Line
|
||||
================================================================================
|
||||

|
||||
|
||||
There are many commands available to check hardware information of your Linux system. Some commands report only specific hardware components like CPU or memory while the rest cover multiple hardware units.
|
||||
|
||||
This tutorial takes a quick look at some of the most commonly used commands to check information and configuration details about various hardware devices.
|
||||
|
||||
### lscpu ###
|
||||
|
||||
The `lscpu` command gives you information about the CPU and processing units. It does not have any other options or functionality.
|
||||
|
||||
lscpu
|
||||
|
||||
You will see the following output by running the above command.
|
||||
|
||||

|
||||
|
||||
### lspci ###
|
||||
|
||||
The lspci is another command line tool that lists all the PCI buses and details about the devices connected to them like VGA adapter, graphics card, network adapter, usb ports, SATA controller, etc.
|
||||
|
||||
lspci
|
||||
|
||||
You will see an output similar to the following image.
|
||||
|
||||

|
||||
|
||||
You can also filter out specific device information by running the following command:
|
||||
|
||||
lspci -v | grep "VGA" -A 12
|
||||
|
||||
You will see graphics card information similar to the following.
|
||||
|
||||

|
||||
|
||||
### lshw ###
|
||||
|
||||
The `lshw` is a general purpose utility that reports detailed and brief information about multiple hardware units like CPU, memory, usb controller, disk, etc. Lshw extracts the information from different “/proc” files.
|
||||
|
||||
lshw -short
|
||||
|
||||
You will see the following information by running the above command.
|
||||
|
||||

|
||||
|
||||
### lsscsi ###
|
||||
|
||||
You can list all scsi/sata devices like hard drives and optical drives by running the following command:
|
||||
|
||||
lsscsi
|
||||
|
||||
The output wI’ll look something like this image.
|
||||
|
||||

|
||||
|
||||
### lsusb ###
|
||||
|
||||
This command shows you the USB controllers and details about devices connected to them. By default, the lsusb command prints brief information. You can also use the verbose option -v to print detailed information about each usb port.
|
||||
|
||||
lsusb
|
||||
|
||||
You will see the following output.
|
||||
|
||||

|
||||
|
||||
### Inxi ###
|
||||
|
||||
`Inxi` is a bash script that fetches hardware information from multiple sources and commands on the system and gives you goodlooking reports that non-technical users can read easily.
|
||||
|
||||
By default, `inxi` is not installed in Ubuntu. You can install it by running the following command:
|
||||
|
||||
sudo apt-get install inxi
|
||||
|
||||
After installing inxi, you can get hardware information by running the following command:
|
||||
|
||||
inxi -Fx
|
||||
|
||||
You will see an output similar to the image below.
|
||||
|
||||

|
||||
|
||||
### df ###
|
||||
|
||||
This command gives you brief information about various partitions, their mount points and the used and available space on each.
|
||||
You can run the `df` command with the `-H` parameter.
|
||||
|
||||
df -H
|
||||
|
||||
You will see the following output.
|
||||
|
||||

|
||||
|
||||
### Free ###
|
||||
|
||||
You can check the amount of used, free and total amount of RAM on your system with the free command.
|
||||
|
||||
free -m
|
||||
|
||||
You will see the following output.
|
||||
|
||||

|
||||
|
||||
### Dmidecode ###
|
||||
|
||||
The `dmidecode` command is different from all other commands. It extracts hardware information by reading data from the DMI tables.
|
||||
|
||||
To display information about the processor, run:
|
||||
|
||||
sudo dmidecode -t processor
|
||||
|
||||

|
||||
|
||||
To display information about the memory, run:
|
||||
|
||||
sudo dmidecode -t memory
|
||||
|
||||

|
||||
|
||||
To display information about the bios, run:
|
||||
|
||||
sudo dmidecode -t bios
|
||||
|
||||

|
||||
|
||||
### Hdparm ###
|
||||
|
||||
The hdparm command gives you information about sata devices like hard disks.
|
||||
|
||||
sudo hdparm
|
||||
|
||||
You will see the following output.
|
||||
|
||||

|
||||
|
||||
### Conclusion ###
|
||||
|
||||
Each of the commands has a different method of extracting hardware information. You can try more than one of them while looking for specific hardware details. All of the above tools are available in most Linux distros, and can be easily installed from the default repository.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.maketecheasier.com/check-hardware-information-linux/
|
||||
|
||||
作者:[Hitesh Jethva][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.maketecheasier.com/author/hiteshjethva/
|
@ -0,0 +1,312 @@
|
||||
How to use KVM from the command line on Debian or Ubuntu
|
||||
================================================================================
|
||||
There are different ways to manage virtual machines (VMs) running on KVM hypervisor. For example, virt-manager is a popular GUI-based front-end for VM management. However, if you would like to use KVM on a headless server, GUI-based solutions will not be ideal. In fact, you can create and manage KVM VMs purely from the command line using kvm command-line wrapper script. Alternatively, you can use virsh which is an easier-to-use command-line user interface for managing guest VMs. Underneath virsh, it communicates wtih libvirtd service which can control several different hypervisors including KVM, Xen, QEMU, LXC and OpenVZ.
|
||||
|
||||
A command-line management interface such as virsh is also useful when you would like to "automate" the provisioning and management of VMs. Also, the fact that virsh supports multiple hypervisors means you can manage different hypervisors via the same virsh interface.
|
||||
|
||||
In this tutorial, I will demonstrate **how to run KVM from the command line by using virsh on Debian or Ubuntu**.
|
||||
|
||||
### Step One: Verify Hardware Virtualization Support ###
|
||||
|
||||
As a first step, verify that the host CPU is equipped with hardware virtualization extensions (e.g., Intel VT or AMD-V), which are required for KVM. The following command will do.
|
||||
|
||||
$ egrep '(vmx|svm)' --color /proc/cpuinfo
|
||||
|
||||

|
||||
|
||||
If the output does not contain vmx or svm flag, it means the host CPU does not have hardware virtualization support. Thus you cannot use KVM on the host. After verifying that the host CPU comes with vmx or svm, proceed to install KVM next.
|
||||
|
||||
For KVM, it is not required to run a 64-bit kernel on the KVM host, but generally it is recommended.
|
||||
|
||||
### Step Two: Install KVM ###
|
||||
|
||||
Using apt-get, install KVM and related user-space tools.
|
||||
|
||||
$ sudo apt-get install qemu-kvm libvirt-bin
|
||||
|
||||
During installation, libvirtd group (or libvirt-qemu on Debian) will be created, and your userID will be automatically added to the group. This will allows you to manage VMs as a non-root regular user. You can verify that by using id command, which will show your group IDs:
|
||||
|
||||
$ id <your-userID>
|
||||
|
||||

|
||||
|
||||
If for some reason, libvirtd (or libvirt-qemu) is not found in your groupID list, you can manually add yourself to the group as follows.
|
||||
|
||||
On Ubuntu:
|
||||
|
||||
$ sudo adduser [youruserID] libvirtd
|
||||
|
||||
On Debian:
|
||||
|
||||
$ sudo adduser [youruserID] libvirt-qemu
|
||||
|
||||
Reload updated group membership info as follows. Upon asked for a password, enter your login password.
|
||||
|
||||
$ exec su -l $USER
|
||||
|
||||
At this point, you should be able to run virsh as a regular user. As a test, try the command below, which will show a list of available VMs (currently none). If you do not encounter a permission error, it means everything is okay so far.
|
||||
|
||||
$ virsh list
|
||||
|
||||
----------
|
||||
|
||||
Id Name State
|
||||
----------------------------------------------------
|
||||
|
||||
### Step Three: Configure Bridged Networking ###
|
||||
|
||||
One way to enable KVM VMs to access external networks is via a Linux bridge created on a KVM host. The bridge interconnects the virtual interfaces of VMs with the physical interface of the host, so that the VMs can send or receive traffic via the physical interface. This is called bridged networking.
|
||||
|
||||
Here is how to create and configure a Linux bridge br0 for bridged networking with KVM.
|
||||
|
||||
First, install a necessary package, and create a Linux bridge from the command line.
|
||||
|
||||
$ sudo apt-get install bridge-utils
|
||||
$ sudo brctl addbr br0
|
||||
|
||||
The next step is to configure Linux bridge in /etc/network/interfaces, so that the bridge is configured automatically upon boot. To use /etc/network/interfaces, you need to disable Network Manager on your system (if you are using it). Follow the [this instruction][1] to disable Network Manager.
|
||||
|
||||
After disabling Network Manager, go ahead and configure Linux bridge br0 in /etc/network/interfaces as follows.
|
||||
|
||||
#auto eth0
|
||||
#iface eth0 inet dhcp
|
||||
|
||||
auto br0
|
||||
iface br0 inet dhcp
|
||||
bridge_ports eth0
|
||||
bridge_stp off
|
||||
bridge_fd 0
|
||||
bridge_maxwait 0
|
||||
|
||||
In the above I assume that eth0 is the primary network interface that is connected to external networks. Also, I assume that eth0 is getting its IP address via DHCP. Note that there is no configuration for eth0 in /etc/network/interface. The Linux bridge br0 takes up the configuration of eth0 as eth0 is enslaved to the bridge br0.
|
||||
|
||||
Restart network service, and verify that Linux bridge is configured successfully. If successful, br0 should be assigned the eth0's DHCP IP address, and eth0 should not have any IP address assigned.
|
||||
|
||||
$ sudo /etc/init.d/networking restart
|
||||
$ ifconfig
|
||||
|
||||
If for any reason eth0 still retains the IP address which is assigned to br0, you may have to explicitly remove the IP address from eth0.
|
||||
|
||||

|
||||
|
||||
### Step Four: Create a VM from the Command Line ###
|
||||
|
||||
With KVM, the configuration of a VM is stored in a domain XML file. Thus, the first step to create a VM is to prepare its domain XML file.
|
||||
|
||||
The following is a sample domain XML file of a VM. You can customize it as needed.
|
||||
|
||||
<domain type='kvm'>
|
||||
<name>alice</name>
|
||||
<uuid>f5b8c05b-9c7a-3211-49b9-2bd635f7e2aa</uuid>
|
||||
<memory>1048576</memory>
|
||||
<currentMemory>1048576</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<boot dev='cdrom'/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
</features>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/kvm</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="/home/dev/images/alice.img"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
|
||||
</disk>
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="/home/dev/iso/CentOS-6.5-x86_64-minimal.iso"/>
|
||||
<target dev="hdc" bus="ide"/>
|
||||
<readonly/>
|
||||
<address type="drive" controller="0" bus="1" target="0" unit="0"/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<source bridge='br0'/>
|
||||
<mac address="00:00:A3:B0:56:10"/>
|
||||
</interface>
|
||||
<controller type="ide" index="0">
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
|
||||
</controller>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport="yes" listen='0.0.0.0'/>
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
</devices>
|
||||
</domain>
|
||||
|
||||
The above domain XML file defines the following VM.
|
||||
|
||||
- 1GB memory, one vCPU and one hard drive.
|
||||
- Disk image: /home/dev/images/alice.img.
|
||||
- Boot from CD-ROM (/home/dev/iso/CentOS-6.5-x86_64-minimal.iso).
|
||||
- Networking: one network interface bridged to br0
|
||||
- Remote access via VNC.
|
||||
|
||||
The UUID string inside <uuid></uuid> can be randomly generated. To get a random UUID, you can use uuid command-line tool.
|
||||
|
||||
$ sudo apt-get install uuid
|
||||
$ uuid
|
||||
|
||||
Another way to create a domain XML file is to dump the domain information of an existing VM as follows.
|
||||
|
||||
$ virsh dumpxml alice > bob.xml
|
||||
|
||||

|
||||
|
||||
### Step Five: Start VM from the Command Line ###
|
||||
|
||||
Before starting a VM, you need to create its initial disk image. For that, you can use qemu-img command, which comes with qemu-kvm package you installed. The following command creates 10GB size empty disk image of qcow2 type:
|
||||
|
||||
$ qemu-img create -f qcow2 /home/dev/images/alice.img 10G
|
||||
|
||||
The advantage of using "qcow2" (as opposed to "raw") as a disk image format is that a "qcow2"-type disk image is not created as a full size (10GB) initially, but grows as the disk gets populated. So it is more space-efficient.
|
||||
|
||||
Now you are ready to start a VM using the domain XML file you created earlier. The following command will create a VM, and automatically start it.
|
||||
|
||||
$ virsh create alice.xml
|
||||
|
||||
----------
|
||||
|
||||
Domain alice created from alice.xml
|
||||
|
||||
**NOTE**: If you run the above command with an already created VM, it will wipe out the VM without warning. If you already created a VM, you can instead use the following command to just start the VM.
|
||||
|
||||
$ virsh start alice.xml
|
||||
|
||||
Verify that a new domain has been created and started successfully with:
|
||||
|
||||
$ virsh list
|
||||
|
||||
----------
|
||||
|
||||
Id Name State
|
||||
----------------------------------------------------
|
||||
3 alice running
|
||||
|
||||
Also, verify that the virtual interface for the VM (e.g., vnet0) is successfully added to the Linux bridge br0 that you created earlier.
|
||||
|
||||
$ sudo brctl show
|
||||
|
||||

|
||||
|
||||
### Step Six: Remote Access a VM ###
|
||||
|
||||
To access the console of a running VM remotely, you can use any VNC client.
|
||||
|
||||
First, find out the VNC port number for the VM as follows.
|
||||
|
||||
$ sudo netstat -nap | egrep '(kvm|qemu)'
|
||||
|
||||

|
||||
|
||||
In this example, the VNC port number for alice VM is 5900.
|
||||
|
||||
Then launch a VNC client, and connect to a VNC server running at <KVM-host-IP>:5900. In our example, the VM is supposed to boot into CentOS CD-ROM.
|
||||
|
||||

|
||||
|
||||
### Manage VMs with virsh ###
|
||||
|
||||
The following lists common usages of virsh command.
|
||||
|
||||
To create a new guest domain and start a VM:
|
||||
|
||||
$ virsh create alice.xml
|
||||
|
||||
To stop a VM and destroy a guest domain:
|
||||
|
||||
$ virsh destroy alice
|
||||
|
||||
To shutdown a VM (without destroying a domain):
|
||||
|
||||
$ virsh shutdown alice
|
||||
|
||||
To suspend a VM:
|
||||
|
||||
$ virsh suspend alice
|
||||
|
||||
To resume a suspended VM:
|
||||
|
||||
$ virsh resume alice
|
||||
|
||||
To access login console of a running VM:
|
||||
|
||||
$ virsh console alice
|
||||
|
||||
To autostart a VM upon host booting:
|
||||
|
||||
$ virsh autostart alice
|
||||
|
||||
To get domain information of a VM:
|
||||
|
||||
$ virsh dominfo alice
|
||||
|
||||
To edit domain XML of a VM:
|
||||
|
||||
$ virsh edit alice
|
||||
|
||||
The above will invoke the domain XML file of the VM with a default text editor. Any change in the XML will automatically be validated by libvirt for correctness.
|
||||
|
||||
You can also manage VMs from within a virsh session. To create and enter a new virsh session, simply run:
|
||||
|
||||
$ virsh
|
||||
|
||||
At the virsh prompt, you can use any virsh commands.
|
||||
|
||||

|
||||
|
||||
### Troubleshooting ###
|
||||
|
||||
1. I am getting the error while trying to create a VM:
|
||||
|
||||
error: internal error: no supported architecture for os type 'hvm'
|
||||
|
||||
You can get this error if your hardware does not have hardware virtualization support (e.g., Intel VT or AMD-V), which is required to run KVM. If you are getting this error even when your CPU comes with Intel VT or AMD-V, here are possible solutions:
|
||||
|
||||
First, check if kvm kernel module is missing.
|
||||
|
||||
$ lsmod | grep kvm
|
||||
|
||||
If kvm kernel module is not loaded, you must load it as follows.
|
||||
|
||||
$ sudo modprobe kvm_intel (for Intel processor)
|
||||
$ sudo modprobe kvm_amd (for AMD processor)
|
||||
|
||||
The second solution is adding "--connect qemu:///system" argument to virsh command as follows. This argument may be needed when you are using more than one hypervisor (e.g., VMware, VirtualBox) on the server hardware.
|
||||
|
||||
$ virsh --connect qemu:///system create alice.xml
|
||||
|
||||
2. I am getting the error while trying to access login console of my VM:
|
||||
|
||||
$ virsh console alice
|
||||
|
||||
----------
|
||||
|
||||
error: internal error: cannot find character device <null>
|
||||
|
||||
This error occurs because you did not define a console device in the VM's XML file. Add the following inside the "device" section of the XML file.
|
||||
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/use-kvm-command-line-debian-ubuntu.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/nanni
|
||||
[1]:http://xmodulo.com/disable-network-manager-linux.html
|
@ -0,0 +1,109 @@
|
||||
What is good stock portfolio management software on Linux
|
||||
================================================================================
|
||||
If you are investing in the stock market, you probably understand the importance of a sound portfolio management plan. The goal of portfolio management is to come up with the best investment plan tailored for you, considering your risk tolerance, time horizon and financial goals. Given its importance, no wonder there are no shortage of commercial portfolio management apps and stock market monitoring software, each touting various sophisticated portfolio performance tracking and reporting capabilities.
|
||||
|
||||
For those of you Linux aficionados who are looking for a **good open-source portfolio management tool** to manage and track your stock portfolio on Linux, I would highly recommend a Java-based portfolio manager called [JStock][1]. If you are not a big Java fan, you might be turned off by the fact that JStock runs on a heavyweight JVM. At the same time I am sure many people will appreciate the fact that JStock is instantly accessible on every Linux platform with JRE installed. No hoops to jump through to make it work on your Linux environment.
|
||||
|
||||
The day is gone when "open-source" means "cheap" or "subpar". Considering that JStock is just a one-man job, JStock is impressively packed with many useful features as a portfolio management tool, and all that credit goes to Yan Cheng Cheok! For example, JStock supports price monitoring via watchlists, multiple portfolios, custom/built-in stock indicators and scanners, support for 27 different stock markets and cross-platform cloud backup/restore. JStock is available on multiple platforms (Linux, OS X, Android and Windows), and you can save and restore your JStock portfolios seamlessly across different platforms via cloud backup/restore.
|
||||
|
||||
Sounds pretty neat, huh? Now I am going to show you how to install and use JStock in more detail.
|
||||
|
||||
### Install JStock on Linux ###
|
||||
|
||||
Since JStock is written in Java, you must [install JRE][2] to run it. Note that JStock requires JRE 1.7 or higher. If your JRE version does not meet this requirement, JStock will fail with the following error.
|
||||
|
||||
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/yccheok/jstock/gui/JStock : Unsupported major.minor version 51.0
|
||||
|
||||
Once you install JRE on your Linux, download the latest JStock release from the official website, and launch it as follows.
|
||||
|
||||
$ wget https://github.com/yccheok/jstock/releases/download/release_1-0-7-13/jstock-1.0.7.13-bin.zip
|
||||
$ unzip jstock-1.0.7.13-bin.zip
|
||||
$ cd jstock
|
||||
$ chmod +x jstock.sh
|
||||
$ ./jstock.sh
|
||||
|
||||
In the rest of the tutorial, let me demonstrate several useful features of JStock.
|
||||
|
||||
### Monitor Stock Price Movements via Watchlist ###
|
||||
|
||||
On JStock you can monitor stock price movement and automatically get notified by creating one or more watchlists. In each watchlist, you can add multiple stocks you are interested in. Then add your alert thresholds under "Fall Below" and "Rise Above" columns, which correspond to minimum and maximum stock prices you want to set, respectively.
|
||||
|
||||

|
||||
|
||||
For example, if you set minimum/maximum prices of AAPL stock to $102 and $115.50, you will be alerted via desktop notifications if the stock price goes below $102 or moves higher than $115.50 at any time.
|
||||
|
||||
You can also enable email alert option, so that you will instead receive email notifications for such price events. To enable email alerts, go to "Options" menu. Under "Alert" tab, turn on "Send message to email(s)" box, and enter your Gmail account. Once you go through Gmail authorization steps, JStock will start sending email alerts to that Gmail account (and optionally CC to any third-party email address).
|
||||
|
||||

|
||||
|
||||
### Manage Multiple Portfolios ###
|
||||
|
||||
JStock allows you to manage multiple portfolios. This feature is useful if you are using multiple stock brokers. You can create a separate portfolio for each broker and manage your buy/sell/dividend transactions on a per-broker basis. You can switch different portfolios by choosing a particular portfolio under "Portfolio" menu. The following screenshot shows a hypothetical portfolio.
|
||||
|
||||

|
||||
|
||||
Optionally you can enable broker fee option, so that you can enter any broker fees, stamp duty and clearing fees for each buy/sell transaction. If you are lazy, you can enable fee auto-calculation and enter fee schedules for each brokering firm from the option menu beforehand. Then JStock will automatically calculate and enter fees when you add transactions to your portfolio.
|
||||
|
||||

|
||||
|
||||
### Screen Stocks with Built-in/Custom Indicators ###
|
||||
|
||||
If you are doing any technical analysis on stocks, you may want to screen stocks based on various criteria (so-called "stock indicators"). For stock screening, JStock offers several [pre-built technical indicators][3] that capture upward/downward/reversal trends of individual stocks. The following is a list of available indicators.
|
||||
|
||||
- Moving Average Convergence Divergence (MACD)
|
||||
- Relative Strength Index (RSI)
|
||||
- Money Flow Index (MFI)
|
||||
- Commodity Channel Index (CCI)
|
||||
- Doji
|
||||
- Golden Cross, Death Cross
|
||||
- Top Gainers/Losers
|
||||
|
||||
To install any pre-built indicator, go to "Stock Indicator Editor" tab on JStock. Then click on "Install" button in the right-side panel. Choose "Install from JStock server" option, and then install any indicator(s) you want.
|
||||
|
||||

|
||||
|
||||
Once one or more indicators are installed, you can scan stocks using them. Go to "Stock Indicator Scanner" tab, click on "Scan" button at the bottom, and choose any indicator.
|
||||
|
||||

|
||||
|
||||
Once you select the stocks to scan (e.g., NYSE, NASDAQ), JStock will perform scan, and show a list of stocks captured by the indicator.
|
||||
|
||||

|
||||
|
||||
Besides pre-built indicators, you can also define custom indicator(s) on your own with a GUI-based indicator editor. The following example screens for stocks whose current price is less than or equal to its 60-day average price.
|
||||
|
||||

|
||||
|
||||
### Cloud Backup and Restore between Linux and Android JStock ###
|
||||
|
||||
Another nice feature of JStock is cloud backup and restore. JStock allows you to save and restore your portfolios/watchlists via Google Drive, and this features works seamlessly across different platforms (e.g., Linux and Android). For example, if you saved your JStock portfolios to Google Drive on Android, you can restore them on Linux version of JStock.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
If you don't see your portfolios/watchlists after restoring from Google Drive, make sure that your country is correctly set under "Country" menu.
|
||||
|
||||
JStock Android free version is available from [Google Play store][4]. You will need to upgrade to premium version for one-time payment if you want to use its full features (e.g., cloud backup, alerts, charts). I think the premium version is definitely worth it.
|
||||
|
||||

|
||||
|
||||
As a final note, I should mention that its creator, Yan Cheng Cheok, is pretty active in JStock development, and quite responsive in addressing any bugs. Kudos to him!
|
||||
|
||||
What do you think of JStock as portfolio tracking software?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/stock-portfolio-management-software-linux.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/nanni
|
||||
[1]:http://jstock.org/
|
||||
[2]:http://ask.xmodulo.com/install-java-runtime-linux.html
|
||||
[3]:http://jstock.org/ma_indicator.html
|
||||
[4]:https://play.google.com/store/apps/details?id=org.yccheok.jstock.gui
|
@ -1,3 +1,4 @@
|
||||
Being translated by hittlle......
|
||||
Part 10 - LFCS: Understanding & Learning Basic Shell Scripting and Linux Filesystem Troubleshooting
|
||||
================================================================================
|
||||
The Linux Foundation launched the LFCS certification (Linux Foundation Certified Sysadmin), a brand new initiative whose purpose is to allow individuals everywhere (and anywhere) to get certified in basic to intermediate operational support for Linux systems, which includes supporting running systems and services, along with overall monitoring and analysis, plus smart decision-making when it comes to raising issues to upper support teams.
|
||||
@ -312,4 +313,4 @@ via: http://www.tecmint.com/linux-basic-shell-scripting-and-linux-filesystem-tro
|
||||
[1]:http://www.tecmint.com/sed-command-to-create-edit-and-manipulate-files-in-linux/
|
||||
[2]:http://www.tecmint.com/vi-editor-usage/
|
||||
[3]:http://www.tecmint.com/learning-shell-scripting-language-a-guide-from-newbies-to-system-administrator/
|
||||
[4]:http://www.tecmint.com/basic-shell-programming-part-ii/
|
||||
[4]:http://www.tecmint.com/basic-shell-programming-part-ii/
|
||||
|
@ -1,234 +0,0 @@
|
||||
GHLandy Translating
|
||||
|
||||
Part 5 - LFCS: How to Mount/Unmount Local and Network (Samba & NFS) Filesystems in Linux
|
||||
================================================================================
|
||||
The Linux Foundation launched the LFCS certification (Linux Foundation Certified Sysadmin), a brand new program whose purpose is allowing individuals from all corners of the globe to get certified in basic to intermediate system administration tasks for Linux systems, which includes supporting running systems and services, along with overall monitoring and analysis, plus smart decision-making when it comes to raising issues to upper support teams.
|
||||
|
||||

|
||||
|
||||
Linux Foundation Certified Sysadmin – Part 5
|
||||
|
||||
The following video shows an introduction to The Linux Foundation Certification Program.
|
||||
|
||||
注:youtube 视频
|
||||
<iframe width="720" height="405" frameborder="0" allowfullscreen="allowfullscreen" src="//www.youtube.com/embed/Y29qZ71Kicg"></iframe>
|
||||
|
||||
This post is Part 5 of a 10-tutorial series, here in this part, we will explain How to mount/unmount local and network filesystems in linux, that are required for the LFCS certification exam.
|
||||
|
||||
### Mounting Filesystems ###
|
||||
|
||||
Once a disk has been partitioned, Linux needs some way to access the data on the partitions. Unlike DOS or Windows (where this is done by assigning a drive letter to each partition), Linux uses a unified directory tree where each partition is mounted at a mount point in that tree.
|
||||
|
||||
A mount point is a directory that is used as a way to access the filesystem on the partition, and mounting the filesystem is the process of associating a certain filesystem (a partition, for example) with a specific directory in the directory tree.
|
||||
|
||||
In other words, the first step in managing a storage device is attaching the device to the file system tree. This task can be accomplished on a one-time basis by using tools such as mount (and then unmounted with umount) or persistently across reboots by editing the /etc/fstab file.
|
||||
|
||||
The mount command (without any options or arguments) shows the currently mounted filesystems.
|
||||
|
||||
# mount
|
||||
|
||||

|
||||
|
||||
Check Mounted Filesystem
|
||||
|
||||
In addition, mount is used to mount filesystems into the filesystem tree. Its standard syntax is as follows.
|
||||
|
||||
# mount -t type device dir -o options
|
||||
|
||||
This command instructs the kernel to mount the filesystem found on device (a partition, for example, that has been formatted with a filesystem type) at the directory dir, using all options. In this form, mount does not look in /etc/fstab for instructions.
|
||||
|
||||
If only a directory or device is specified, for example.
|
||||
|
||||
# mount /dir -o options
|
||||
or
|
||||
# mount device -o options
|
||||
|
||||
mount tries to find a mount point and if it can’t find any, then searches for a device (both cases in the /etc/fstab file), and finally attempts to complete the mount operation (which usually succeeds, except for the case when either the directory or the device is already being used, or when the user invoking mount is not root).
|
||||
|
||||
You will notice that every line in the output of mount has the following format.
|
||||
|
||||
device on directory type (options)
|
||||
|
||||
For example,
|
||||
|
||||
/dev/mapper/debian-home on /home type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
|
||||
|
||||
Reads:
|
||||
|
||||
dev/mapper/debian-home is mounted on /home, which has been formatted as ext4, with the following options: rw,relatime,user_xattr,barrier=1,data=ordered
|
||||
|
||||
**Mount Options**
|
||||
|
||||
Most frequently used mount options include.
|
||||
|
||||
- async: allows asynchronous I/O operations on the file system being mounted.
|
||||
- auto: marks the file system as enabled to be mounted automatically using mount -a. It is the opposite of noauto.
|
||||
- defaults: this option is an alias for async,auto,dev,exec,nouser,rw,suid. Note that multiple options must be separated by a comma without any spaces. If by accident you type a space between options, mount will interpret the subsequent text string as another argument.
|
||||
- loop: Mounts an image (an .iso file, for example) as a loop device. This option can be used to simulate the presence of the disk’s contents in an optical media reader.
|
||||
- noexec: prevents the execution of executable files on the particular filesystem. It is the opposite of exec.
|
||||
- nouser: prevents any users (other than root) to mount and unmount the filesystem. It is the opposite of user.
|
||||
- remount: mounts the filesystem again in case it is already mounted.
|
||||
- ro: mounts the filesystem as read only.
|
||||
- rw: mounts the file system with read and write capabilities.
|
||||
- relatime: makes access time to files be updated only if atime is earlier than mtime.
|
||||
- user_xattr: allow users to set and remote extended filesystem attributes.
|
||||
|
||||
**Mounting a device with ro and noexec options**
|
||||
|
||||
# mount -t ext4 /dev/sdg1 /mnt -o ro,noexec
|
||||
|
||||
In this case we can see that attempts to write a file to or to run a binary file located inside our mounting point fail with corresponding error messages.
|
||||
|
||||
# touch /mnt/myfile
|
||||
# /mnt/bin/echo “Hi there”
|
||||
|
||||

|
||||
|
||||
Mount Device Read Write
|
||||
|
||||
**Mounting a device with default options**
|
||||
|
||||
In the following scenario, we will try to write a file to our newly mounted device and run an executable file located within its filesystem tree using the same commands as in the previous example.
|
||||
|
||||
# mount -t ext4 /dev/sdg1 /mnt -o defaults
|
||||
|
||||

|
||||
|
||||
Mount Device
|
||||
|
||||
In this last case, it works perfectly.
|
||||
|
||||
### Unmounting Devices ###
|
||||
|
||||
Unmounting a device (with the umount command) means finish writing all the remaining “on transit” data so that it can be safely removed. Note that if you try to remove a mounted device without properly unmounting it first, you run the risk of damaging the device itself or cause data loss.
|
||||
|
||||
That being said, in order to unmount a device, you must be “standing outside” its block device descriptor or mount point. In other words, your current working directory must be something else other than the mounting point. Otherwise, you will get a message saying that the device is busy.
|
||||
|
||||

|
||||
|
||||
Unmount Device
|
||||
|
||||
An easy way to “leave” the mounting point is typing the cd command which, in lack of arguments, will take us to our current user’s home directory, as shown above.
|
||||
|
||||
### Mounting Common Networked Filesystems ###
|
||||
|
||||
The two most frequently used network file systems are SMB (which stands for “Server Message Block”) and NFS (“Network File System”). Chances are you will use NFS if you need to set up a share for Unix-like clients only, and will opt for Samba if you need to share files with Windows-based clients and perhaps other Unix-like clients as well.
|
||||
|
||||
Read Also
|
||||
|
||||
- [Setup Samba Server in RHEL/CentOS and Fedora][1]
|
||||
- [Setting up NFS (Network File System) on RHEL/CentOS/Fedora and Debian/Ubuntu][2]
|
||||
|
||||
The following steps assume that Samba and NFS shares have already been set up in the server with IP 192.168.0.10 (please note that setting up a NFS share is one of the competencies required for the LFCE exam, which we will cover after the present series).
|
||||
|
||||
#### Mounting a Samba share on Linux ####
|
||||
|
||||
Step 1: Install the samba-client samba-common and cifs-utils packages on Red Hat and Debian based distributions.
|
||||
|
||||
# yum update && yum install samba-client samba-common cifs-utils
|
||||
# aptitude update && aptitude install samba-client samba-common cifs-utils
|
||||
|
||||
Then run the following command to look for available samba shares in the server.
|
||||
|
||||
# smbclient -L 192.168.0.10
|
||||
|
||||
And enter the password for the root account in the remote machine.
|
||||
|
||||

|
||||
|
||||
Mount Samba Share
|
||||
|
||||
In the above image we have highlighted the share that is ready for mounting on our local system. You will need a valid samba username and password on the remote server in order to access it.
|
||||
|
||||
Step 2: When mounting a password-protected network share, it is not a good idea to write your credentials in the /etc/fstab file. Instead, you can store them in a hidden file somewhere with permissions set to 600, like so.
|
||||
|
||||
# mkdir /media/samba
|
||||
# echo “username=samba_username” > /media/samba/.smbcredentials
|
||||
# echo “password=samba_password” >> /media/samba/.smbcredentials
|
||||
# chmod 600 /media/samba/.smbcredentials
|
||||
|
||||
Step 3: Then add the following line to /etc/fstab file.
|
||||
|
||||
# //192.168.0.10/gacanepa /media/samba cifs credentials=/media/samba/.smbcredentials,defaults 0 0
|
||||
|
||||
Step 4: You can now mount your samba share, either manually (mount //192.168.0.10/gacanepa) or by rebooting your machine so as to apply the changes made in /etc/fstab permanently.
|
||||
|
||||

|
||||
|
||||
Mount Password Protect Samba Share
|
||||
|
||||
#### Mounting a NFS share on Linux ####
|
||||
|
||||
Step 1: Install the nfs-common and portmap packages on Red Hat and Debian based distributions.
|
||||
|
||||
# yum update && yum install nfs-utils nfs-utils-lib
|
||||
# aptitude update && aptitude install nfs-common
|
||||
|
||||
Step 2: Create a mounting point for the NFS share.
|
||||
|
||||
# mkdir /media/nfs
|
||||
|
||||
Step 3: Add the following line to /etc/fstab file.
|
||||
|
||||
192.168.0.10:/NFS-SHARE /media/nfs nfs defaults 0 0
|
||||
|
||||
Step 4: You can now mount your nfs share, either manually (mount 192.168.0.10:/NFS-SHARE) or by rebooting your machine so as to apply the changes made in /etc/fstab permanently.
|
||||
|
||||

|
||||
|
||||
Mount NFS Share
|
||||
|
||||
### Mounting Filesystems Permanently ###
|
||||
|
||||
As shown in the previous two examples, the /etc/fstab file controls how Linux provides access to disk partitions and removable media devices and consists of a series of lines that contain six fields each; the fields are separated by one or more spaces or tabs. A line that begins with a hash mark (#) is a comment and is ignored.
|
||||
|
||||
Each line has the following format.
|
||||
|
||||
<file system> <mount point> <type> <options> <dump> <pass>
|
||||
|
||||
Where:
|
||||
|
||||
- <file system>: The first column specifies the mount device. Most distributions now specify partitions by their labels or UUIDs. This practice can help reduce problems if partition numbers change.
|
||||
- <mount point>: The second column specifies the mount point.
|
||||
- <type>: The file system type code is the same as the type code used to mount a filesystem with the mount command. A file system type code of auto lets the kernel auto-detect the filesystem type, which can be a convenient option for removable media devices. Note that this option may not be available for all filesystems out there.
|
||||
- <options>: One (or more) mount option(s).
|
||||
- <dump>: You will most likely leave this to 0 (otherwise set it to 1) to disable the dump utility to backup the filesystem upon boot (The dump program was once a common backup tool, but it is much less popular today.)
|
||||
- <pass>: This column specifies whether the integrity of the filesystem should be checked at boot time with fsck. A 0 means that fsck should not check a filesystem. The higher the number, the lowest the priority. Thus, the root partition will most likely have a value of 1, while all others that should be checked should have a value of 2.
|
||||
|
||||
**Mount Examples**
|
||||
|
||||
1. To mount a partition with label TECMINT at boot time with rw and noexec attributes, you should add the following line in /etc/fstab file.
|
||||
|
||||
LABEL=TECMINT /mnt ext4 rw,noexec 0 0
|
||||
|
||||
2. If you want the contents of a disk in your DVD drive be available at boot time.
|
||||
|
||||
/dev/sr0 /media/cdrom0 iso9660 ro,user,noauto 0 0
|
||||
|
||||
Where /dev/sr0 is your DVD drive.
|
||||
|
||||
### Summary ###
|
||||
|
||||
You can rest assured that mounting and unmounting local and network filesystems from the command line will be part of your day-to-day responsibilities as sysadmin. You will also need to master /etc/fstab. I hope that you have found this article useful to help you with those tasks. Feel free to add your comments (or ask questions) below and to share this article through your network social profiles.
|
||||
Reference Links
|
||||
|
||||
- [About the LFCS][3]
|
||||
- [Why get a Linux Foundation Certification?][4]
|
||||
- [Register for the LFCS exam][5]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/mount-filesystem-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
[1]:http://www.tecmint.com/setup-samba-server-using-tdbsam-backend-on-rhel-centos-6-3-5-8-and-fedora-17-12/
|
||||
[2]:http://www.tecmint.com/how-to-setup-nfs-server-in-linux/
|
||||
[3]:https://training.linuxfoundation.org/certification/LFCS
|
||||
[4]:https://training.linuxfoundation.org/certification/why-certify-with-us
|
||||
[5]:https://identity.linuxfoundation.org/user?destination=pid/1
|
@ -1,3 +1,4 @@
|
||||
[Translating by cposture 15-12-31]
|
||||
Part 6 - LFCS: Assembling Partitions as RAID Devices – Creating & Managing System Backups
|
||||
================================================================================
|
||||
Recently, the Linux Foundation launched the LFCS (Linux Foundation Certified Sysadmin) certification, a shiny chance for system administrators everywhere to demonstrate, through a performance-based exam, that they are capable of performing overall operational support on Linux systems: system support, first-level diagnosing and monitoring, plus issue escalation, when required, to other support teams.
|
||||
@ -273,4 +274,4 @@ via: http://www.tecmint.com/creating-and-managing-raid-backups-in-linux/
|
||||
[1]:http://www.tecmint.com/understanding-raid-setup-in-linux/
|
||||
[2]:http://www.tecmint.com/create-partitions-and-filesystems-in-linux/
|
||||
[3]:http://www.tecmint.com/compress-files-and-finding-files-in-linux/
|
||||
[4]:http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
|
||||
[4]:http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
|
||||
|
@ -1,3 +1,5 @@
|
||||
Translating by Flowsnow
|
||||
|
||||
Part 7 - LFCS: Managing System Startup Process and Services (SysVinit, Systemd and Upstart)
|
||||
================================================================================
|
||||
A couple of months ago, the Linux Foundation announced the LFCS (Linux Foundation Certified Sysadmin) certification, an exciting new program whose aim is allowing individuals from all ends of the world to get certified in performing basic to intermediate system administration tasks on Linux systems. This includes supporting already running systems and services, along with first-hand problem-finding and analysis, plus the ability to decide when to raise issues to engineering teams.
|
||||
@ -364,4 +366,4 @@ via: http://www.tecmint.com/linux-boot-process-and-manage-services/
|
||||
[3]:http://www.tecmint.com/chkconfig-command-examples/
|
||||
[4]:http://www.tecmint.com/remove-unwanted-services-from-linux/
|
||||
[5]:http://www.tecmint.com/chkconfig-command-examples/
|
||||
[6]:http://upstart.ubuntu.com/cookbook/
|
||||
[6]:http://upstart.ubuntu.com/cookbook/
|
||||
|
@ -1,330 +0,0 @@
|
||||
Part 8 - LFCS: Managing Users & Groups, File Permissions & Attributes and Enabling sudo Access on Accounts
|
||||
================================================================================
|
||||
Last August, the Linux Foundation started the LFCS certification (Linux Foundation Certified Sysadmin), a brand new program whose purpose is to allow individuals everywhere and anywhere take an exam in order to get certified in basic to intermediate operational support for Linux systems, which includes supporting running systems and services, along with overall monitoring and analysis, plus intelligent decision-making to be able to decide when it’s necessary to escalate issues to higher level support teams.
|
||||
|
||||

|
||||
|
||||
Linux Foundation Certified Sysadmin – Part 8
|
||||
|
||||
Please have a quick look at the following video that describes an introduction to the Linux Foundation Certification Program.
|
||||
|
||||
注:youtube视频
|
||||
<iframe width="720" height="405" frameborder="0" allowfullscreen="allowfullscreen" src="//www.youtube.com/embed/Y29qZ71Kicg"></iframe>
|
||||
|
||||
This article is Part 8 of a 10-tutorial long series, here in this section, we will guide you on how to manage users and groups permissions in Linux system, that are required for the LFCS certification exam.
|
||||
|
||||
Since Linux is a multi-user operating system (in that it allows multiple users on different computers or terminals to access a single system), you will need to know how to perform effective user management: how to add, edit, suspend, or delete user accounts, along with granting them the necessary permissions to do their assigned tasks.
|
||||
|
||||
### Adding User Accounts ###
|
||||
|
||||
To add a new user account, you can run either of the following two commands as root.
|
||||
|
||||
# adduser [new_account]
|
||||
# useradd [new_account]
|
||||
|
||||
When a new user account is added to the system, the following operations are performed.
|
||||
|
||||
1. His/her home directory is created (/home/username by default).
|
||||
|
||||
2. The following hidden files are copied into the user’s home directory, and will be used to provide environment variables for his/her user session.
|
||||
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
|
||||
3. A mail spool is created for the user at /var/spool/mail/username.
|
||||
|
||||
4. A group is created and given the same name as the new user account.
|
||||
|
||||
**Understanding /etc/passwd**
|
||||
|
||||
The full account information is stored in the /etc/passwd file. This file contains a record per system user account and has the following format (fields are delimited by a colon).
|
||||
|
||||
[username]:[x]:[UID]:[GID]:[Comment]:[Home directory]:[Default shell]
|
||||
|
||||
- Fields [username] and [Comment] are self explanatory.
|
||||
- The x in the second field indicates that the account is protected by a shadowed password (in /etc/shadow), which is needed to logon as [username].
|
||||
- The [UID] and [GID] fields are integers that represent the User IDentification and the primary Group IDentification to which [username] belongs, respectively.
|
||||
- The [Home directory] indicates the absolute path to [username]’s home directory, and
|
||||
- The [Default shell] is the shell that will be made available to this user when he or she logins the system.
|
||||
|
||||
**Understanding /etc/group**
|
||||
|
||||
Group information is stored in the /etc/group file. Each record has the following format.
|
||||
|
||||
[Group name]:[Group password]:[GID]:[Group members]
|
||||
|
||||
- [Group name] is the name of group.
|
||||
- An x in [Group password] indicates group passwords are not being used.
|
||||
- [GID]: same as in /etc/passwd.
|
||||
- [Group members]: a comma separated list of users who are members of [Group name].
|
||||
|
||||

|
||||
|
||||
Add User Accounts
|
||||
|
||||
After adding an account, you can edit the following information (to name a few fields) using the usermod command, whose basic syntax of usermod is as follows.
|
||||
|
||||
# usermod [options] [username]
|
||||
|
||||
**Setting the expiry date for an account**
|
||||
|
||||
Use the –expiredate flag followed by a date in YYYY-MM-DD format.
|
||||
|
||||
# usermod --expiredate 2014-10-30 tecmint
|
||||
|
||||
**Adding the user to supplementary groups**
|
||||
|
||||
Use the combined -aG, or –append –groups options, followed by a comma separated list of groups.
|
||||
|
||||
# usermod --append --groups root,users tecmint
|
||||
|
||||
**Changing the default location of the user’s home directory**
|
||||
|
||||
Use the -d, or –home options, followed by the absolute path to the new home directory.
|
||||
|
||||
# usermod --home /tmp tecmint
|
||||
|
||||
**Changing the shell the user will use by default**
|
||||
|
||||
Use –shell, followed by the path to the new shell.
|
||||
|
||||
# usermod --shell /bin/sh tecmint
|
||||
|
||||
**Displaying the groups an user is a member of**
|
||||
|
||||
# groups tecmint
|
||||
# id tecmint
|
||||
|
||||
Now let’s execute all the above commands in one go.
|
||||
|
||||
# usermod --expiredate 2014-10-30 --append --groups root,users --home /tmp --shell /bin/sh tecmint
|
||||
|
||||

|
||||
|
||||
usermod Command Examples
|
||||
|
||||
Read Also:
|
||||
|
||||
- [15 useradd Command Examples in Linux][1]
|
||||
- [15 usermod Command Examples in Linux][2]
|
||||
|
||||
For existing accounts, we can also do the following.
|
||||
|
||||
**Disabling account by locking password**
|
||||
|
||||
Use the -L (uppercase L) or the –lock option to lock a user’s password.
|
||||
|
||||
# usermod --lock tecmint
|
||||
|
||||
**Unlocking user password**
|
||||
|
||||
Use the –u or the –unlock option to unlock a user’s password that was previously blocked.
|
||||
|
||||
# usermod --unlock tecmint
|
||||
|
||||

|
||||
|
||||
Lock User Accounts
|
||||
|
||||
**Creating a new group for read and write access to files that need to be accessed by several users**
|
||||
|
||||
Run the following series of commands to achieve the goal.
|
||||
|
||||
# groupadd common_group # Add a new group
|
||||
# chown :common_group common.txt # Change the group owner of common.txt to common_group
|
||||
# usermod -aG common_group user1 # Add user1 to common_group
|
||||
# usermod -aG common_group user2 # Add user2 to common_group
|
||||
# usermod -aG common_group user3 # Add user3 to common_group
|
||||
|
||||
**Deleting a group**
|
||||
|
||||
You can delete a group with the following command.
|
||||
|
||||
# groupdel [group_name]
|
||||
|
||||
If there are files owned by group_name, they will not be deleted, but the group owner will be set to the GID of the group that was deleted.
|
||||
|
||||
### Linux File Permissions ###
|
||||
|
||||
Besides the basic read, write, and execute permissions that we discussed in [Setting File Attributes – Part 3][3] of this series, there are other less used (but not less important) permission settings, sometimes referred to as “special permissions”.
|
||||
|
||||
Like the basic permissions discussed earlier, they are set using an octal file or through a letter (symbolic notation) that indicates the type of permission.
|
||||
Deleting user accounts
|
||||
|
||||
You can delete an account (along with its home directory, if it’s owned by the user, and all the files residing therein, and also the mail spool) using the userdel command with the –remove option.
|
||||
|
||||
# userdel --remove [username]
|
||||
|
||||
#### Group Management ####
|
||||
|
||||
Every time a new user account is added to the system, a group with the same name is created with the username as its only member. Other users can be added to the group later. One of the purposes of groups is to implement a simple access control to files and other system resources by setting the right permissions on those resources.
|
||||
|
||||
For example, suppose you have the following users.
|
||||
|
||||
- user1 (primary group: user1)
|
||||
- user2 (primary group: user2)
|
||||
- user3 (primary group: user3)
|
||||
|
||||
All of them need read and write access to a file called common.txt located somewhere on your local system, or maybe on a network share that user1 has created. You may be tempted to do something like,
|
||||
|
||||
# chmod 660 common.txt
|
||||
OR
|
||||
# chmod u=rw,g=rw,o= common.txt [notice the space between the last equal sign and the file name]
|
||||
|
||||
However, this will only provide read and write access to the owner of the file and to those users who are members of the group owner of the file (user1 in this case). Again, you may be tempted to add user2 and user3 to group user1, but that will also give them access to the rest of the files owned by user user1 and group user1.
|
||||
|
||||
This is where groups come in handy, and here’s what you should do in a case like this.
|
||||
|
||||
**Understanding Setuid**
|
||||
|
||||
When the setuid permission is applied to an executable file, an user running the program inherits the effective privileges of the program’s owner. Since this approach can reasonably raise security concerns, the number of files with setuid permission must be kept to a minimum. You will likely find programs with this permission set when a system user needs to access a file owned by root.
|
||||
|
||||
Summing up, it isn’t just that the user can execute the binary file, but also that he can do so with root’s privileges. For example, let’s check the permissions of /bin/passwd. This binary is used to change the password of an account, and modifies the /etc/shadow file. The superuser can change anyone’s password, but all other users should only be able to change their own.
|
||||
|
||||

|
||||
|
||||
passwd Command Examples
|
||||
|
||||
Thus, any user should have permission to run /bin/passwd, but only root will be able to specify an account. Other users can only change their corresponding passwords.
|
||||
|
||||

|
||||
|
||||
Change User Password
|
||||
|
||||
**Understanding Setgid**
|
||||
|
||||
When the setgid bit is set, the effective GID of the real user becomes that of the group owner. Thus, any user can access a file under the privileges granted to the group owner of such file. In addition, when the setgid bit is set on a directory, newly created files inherit the same group as the directory, and newly created subdirectories will also inherit the setgid bit of the parent directory. You will most likely use this approach whenever members of a certain group need access to all the files in a directory, regardless of the file owner’s primary group.
|
||||
|
||||
# chmod g+s [filename]
|
||||
|
||||
To set the setgid in octal form, prepend the number 2 to the current (or desired) basic permissions.
|
||||
|
||||
# chmod 2755 [directory]
|
||||
|
||||
**Setting the SETGID in a directory**
|
||||
|
||||

|
||||
|
||||
Add Setgid to Directory
|
||||
|
||||
**Understanding Sticky Bit**
|
||||
|
||||
When the “sticky bit” is set on files, Linux just ignores it, whereas for directories it has the effect of preventing users from deleting or even renaming the files it contains unless the user owns the directory, the file, or is root.
|
||||
|
||||
# chmod o+t [directory]
|
||||
|
||||
To set the sticky bit in octal form, prepend the number 1 to the current (or desired) basic permissions.
|
||||
|
||||
# chmod 1755 [directory]
|
||||
|
||||
Without the sticky bit, anyone able to write to the directory can delete or rename files. For that reason, the sticky bit is commonly found on directories, such as /tmp, that are world-writable.
|
||||
|
||||

|
||||
|
||||
Add Stickybit to Directory
|
||||
|
||||
### Special Linux File Attributes ###
|
||||
|
||||
There are other attributes that enable further limits on the operations that are allowed on files. For example, prevent the file from being renamed, moved, deleted, or even modified. They are set with the [chattr command][4] and can be viewed using the lsattr tool, as follows.
|
||||
|
||||
# chattr +i file1
|
||||
# chattr +a file2
|
||||
|
||||
After executing those two commands, file1 will be immutable (which means it cannot be moved, renamed, modified or deleted) whereas file2 will enter append-only mode (can only be open in append mode for writing).
|
||||
|
||||

|
||||
|
||||
Chattr Command to Protect Files
|
||||
|
||||
### Accessing the root Account and Using sudo ###
|
||||
|
||||
One of the ways users can gain access to the root account is by typing.
|
||||
|
||||
$ su
|
||||
|
||||
and then entering root’s password.
|
||||
|
||||
If authentication succeeds, you will be logged on as root with the current working directory as the same as you were before. If you want to be placed in root’s home directory instead, run.
|
||||
|
||||
$ su -
|
||||
|
||||
and then enter root’s password.
|
||||
|
||||

|
||||
|
||||
Enable Sudo Access on Users
|
||||
|
||||
The above procedure requires that a normal user knows root’s password, which poses a serious security risk. For that reason, the sysadmin can configure the sudo command to allow an ordinary user to execute commands as a different user (usually the superuser) in a very controlled and limited way. Thus, restrictions can be set on a user so as to enable him to run one or more specific privileged commands and no others.
|
||||
|
||||
- Read Also: [Difference Between su and sudo User][5]
|
||||
|
||||
To authenticate using sudo, the user uses his/her own password. After entering the command, we will be prompted for our password (not the superuser’s) and if the authentication succeeds (and if the user has been granted privileges to run the command), the specified command is carried out.
|
||||
|
||||
To grant access to sudo, the system administrator must edit the /etc/sudoers file. It is recommended that this file is edited using the visudo command instead of opening it directly with a text editor.
|
||||
|
||||
# visudo
|
||||
|
||||
This opens the /etc/sudoers file using vim (you can follow the instructions given in [Install and Use vim as Editor – Part 2][6] of this series to edit the file).
|
||||
|
||||
These are the most relevant lines.
|
||||
|
||||
Defaults secure_path="/usr/sbin:/usr/bin:/sbin"
|
||||
root ALL=(ALL) ALL
|
||||
tecmint ALL=/bin/yum update
|
||||
gacanepa ALL=NOPASSWD:/bin/updatedb
|
||||
%admin ALL=(ALL) ALL
|
||||
|
||||
Let’s take a closer look at them.
|
||||
|
||||
Defaults secure_path="/usr/sbin:/usr/bin:/sbin:/usr/local/bin"
|
||||
|
||||
This line lets you specify the directories that will be used for sudo, and is used to prevent using user-specific directories, which can harm the system.
|
||||
|
||||
The next lines are used to specify permissions.
|
||||
|
||||
root ALL=(ALL) ALL
|
||||
|
||||
- The first ALL keyword indicates that this rule applies to all hosts.
|
||||
- The second ALL indicates that the user in the first column can run commands with the privileges of any user.
|
||||
- The third ALL means any command can be run.
|
||||
|
||||
tecmint ALL=/bin/yum update
|
||||
|
||||
If no user is specified after the = sign, sudo assumes the root user. In this case, user tecmint will be able to run yum update as root.
|
||||
|
||||
gacanepa ALL=NOPASSWD:/bin/updatedb
|
||||
|
||||
The NOPASSWD directive allows user gacanepa to run /bin/updatedb without needing to enter his password.
|
||||
|
||||
%admin ALL=(ALL) ALL
|
||||
|
||||
The % sign indicates that this line applies to a group called “admin”. The meaning of the rest of the line is identical to that of an regular user. This means that members of the group “admin” can run all commands as any user on all hosts.
|
||||
|
||||
To see what privileges are granted to you by sudo, use the “-l” option to list them.
|
||||
|
||||

|
||||
|
||||
Sudo Access Rules
|
||||
|
||||
### Summary ###
|
||||
|
||||
Effective user and file management skills are essential tools for any system administrator. In this article we have covered the basics and hope you can use it as a good starting to point to build upon. Feel free to leave your comments or questions below, and we’ll respond quickly.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/manage-users-and-groups-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
[1]:http://www.tecmint.com/add-users-in-linux/
|
||||
[2]:http://www.tecmint.com/usermod-command-examples/
|
||||
[3]:http://www.tecmint.com/compress-files-and-finding-files-in-linux/
|
||||
[4]:http://www.tecmint.com/chattr-command-examples/
|
||||
[5]:http://www.tecmint.com/su-vs-sudo-and-how-to-configure-sudo-in-linux/
|
||||
[6]:http://www.tecmint.com/vi-editor-usage/
|
@ -1,3 +1,4 @@
|
||||
translating by fw8899
|
||||
How to Setup SSH Login Without Password CentOS / RHEL
|
||||
================================================================================
|
||||

|
@ -0,0 +1,148 @@
|
||||
如何在 Fedora/CentOS/RHEL 或 Arch Linux 上安装 Cockpit
|
||||
================================================================================
|
||||
Cockpit 是一个免费开源的服务器管理软件,它使得我们可以通过它好看的 web 前端界面轻松地管理我们的 GNU/Linux 服务器。Cockpit 使得 linux 系统管理员、系统维护员和开发者能轻松地管理他们的服务器并执行一些简单的任务,例如管理存储、检测日志、启动或停止服务以及一些其它任务。它的报告界面添加了一些很好的功能使得可以轻松地在终端和 web 界面之间切换。另外,它不仅使得管理一台服务器变得简单,更重要的是只需要一个单击就可以在一个地方同时管理多个通过网络连接的服务器。它非常轻量级,web 界面也非常简单易用。在这篇博文中,我们会学习如何安装 Cockpit 并用它管理我们的运行着 Fedora、CentOS、Arch Linux 以及 RHEL 发行版操作系统的服务器。下面是 Cockpit 在我们的 GNU/Linux 服务器中一些非常棒的功能:
|
||||
|
||||
1. 它包含 systemd 服务管理器。
|
||||
2. 有一个用于故障排除和日志分析的 Journal 日志查看器。
|
||||
3. 包括 LVM 在内的存储配置比以前任何时候都要简单。
|
||||
4. 用 Cockpit 可以进行基本的网络配置。
|
||||
5. 可以轻松地添加和删除用户以及管理多台服务器。
|
||||
|
||||
### 1. 安装 Cockpit ###
|
||||
|
||||
首先,我们需要在我们基于 linux 的服务器上安装 Cockpit。大部分发行版的官方软件仓库中都有可用的 cockpit 安装包。这篇博文中,我们会在 Fedora 22、CentOS 7、Arch Linux 和 RHEL 7 中通过它们的官方软件仓库安装 Cockpit。
|
||||
|
||||
#### CentOS / RHEL ####
|
||||
|
||||
CentOS 和 RHEL 官方软件库中有可用的 Cockpit。我们只需要用 yum 管理器就可以安装。只需要以 sudo/root 权限运行下面的命令就可以安装它。
|
||||
|
||||
# yum install cockpit
|
||||
|
||||

|
||||
|
||||
#### Fedora 22/21 ####
|
||||
|
||||
和 CentOS 一样, Fedora 的官方软件库默认也有可用的 Cockpit。我们只需要用 dnf 软件包管理器就可以安装 Cockpit。
|
||||
|
||||
# dnf install cockpit
|
||||
|
||||

|
||||
|
||||
#### Arch Linux ####
|
||||
|
||||
现在 Arch Linux 官方软件库中还没有可用的 Cockpit,但 Arch 用户库(Arch User Repository,AUR)有。只需要运行下面的 yaourt 命令就可以安装。
|
||||
|
||||
# yaourt cockpit
|
||||
|
||||

|
||||
|
||||
### 2. 启动并启用 Cockpit ###
|
||||
|
||||
成功安装完 Cockpit,我们就要用服务/守护进程管理器启动 Cockpit 服务。到了 2015 年,尽管一些 linux 发行版仍然运行 SysVinit 管理守护进程,但大部分 linux 发行版都采用了 Systemd,Cockpit 使用 systemd 完成从运行守护进程到服务几乎所有的功能。因此,我们只能在运行着 Systemd 的最新的 linux 发行版中安装 Cockpit。要启动 Cockpit 并让它在每次系统重启时自动启动,我们需要在终端或控制台中运行下面的命令。
|
||||
# systemctl start cockpit
|
||||
|
||||
# systemctl enable cockpit.socket
|
||||
|
||||
创建从 /etc/systemd/system/sockets.target.wants/cockpit.socket 到 /usr/lib/systemd/system/cockpit.socket 的符号链接。
|
||||
|
||||
### 3. 允许通过防火墙 ###
|
||||
|
||||
启动 Cockpit 并使得它能在每次系统重启时自动启动后,我们现在要给它配置防火墙。由于我们的服务器上运行着防火墙程序,我们需要允许它通过某些端口使得从服务器外面可以访问 Cockpit。
|
||||
|
||||
#### Firewalld ####
|
||||
|
||||
# firewall-cmd --add-service=cockpit --permanent
|
||||
|
||||
success
|
||||
|
||||
# firewall-cmd --reload
|
||||
|
||||
success
|
||||
|
||||

|
||||
|
||||
#### Iptables ####
|
||||
|
||||
# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
||||
|
||||
# service iptables save
|
||||
|
||||
### 4. 访问 Cockpit Web 界面 ###
|
||||
|
||||
下面,我们终于要通过 web 浏览器访问 Cockpit web 界面了。根据配置,我们只需要用浏览器打开 https://ip-address:9090 或 https://server.domain.com:9090。在我们这篇博文中,我们用浏览器打开 https://128.199.114.17:9090,正如下图所示。
|
||||
|
||||

|
||||
|
||||
此时会出现一个 SSL 认证警告,因为我们正在使用一个自签名认证。我们只需要忽略这个警告并进入到登录页面,在 chrome/chromium 中,我们需要点击 Show Advanced 然后点击 **Proceed to 128.199.114.17 (unsafe)**。
|
||||
|
||||

|
||||
|
||||
现在,要进入仪表盘,我们需要输入详细的登录信息。这里,用户名和密码和用于登录我们的 linux 服务器的用户名和密码相同。当我们输入登录信息并点击 Log In 按钮后,我们就会进入到 Cockpit 仪表盘。
|
||||
|
||||

|
||||
|
||||
这里我们可以看到所有的菜单以及 CPU、磁盘、网络、存储使用情况的可视化结果。仪表盘正如上图所示。
|
||||
|
||||
#### 服务 ####
|
||||
|
||||
要管理服务,我们需要点击 web 页面右边菜单中的 Services 按钮。然后,我们会看到服务被分成了 5 个类别,目标、系统服务、套接字、计时器和路径。
|
||||
|
||||

|
||||
|
||||
#### Docker 容器 ####
|
||||
|
||||
我们甚至可以用 Cockpit 管理 docker 容器。用 Cockpit 监控和管理 Docker 容器非常简单。由于我们的服务器中没有安装运行 docker,我们需要点击 Start Docker。
|
||||
|
||||
|
||||

|
||||
|
||||
Cockpit 会自动在我们的服务器上安装和运行 docker。启动之后,我们就会看到下面的截图。然后我们就可以按照需求管理 docker 镜像、容器。
|
||||
|
||||

|
||||
|
||||
#### Journal 日志查看器 ####
|
||||
|
||||
Cockpit 有个日志查看器,它把错误、警告、注意分到不同的标签页。我们也有一个 All 标签页,在这里可以看到所有的日志信息。
|
||||
|
||||

|
||||
|
||||
#### 网络 ####
|
||||
|
||||
在网络部分,我们可以看到两个可视化发送和接收速度的图。我们可以看到这里有一个可用网卡的列表,还有 Add Bond、Bridge、VLAN 的选项。如果我们需要配置一个网卡,我们只需要点击网卡名称。在下面,我们可以看到网络的 Journal 日志信息。
|
||||
|
||||

|
||||
|
||||
#### 存储 ####
|
||||
|
||||
现在,用 Cockpit 可以方便地查看硬盘的读写速度。我们可以查看存储的 Journal 日志以便进行故障排除和修复。在页面中还有一个已用空间的可视化图。我们甚至可以卸载、格式化、删除一块硬盘的某个分区。它还有类似创建 RAID 设备、卷组等攻能。
|
||||
|
||||

|
||||
|
||||
#### 用户管理 ####
|
||||
|
||||
通过 Cockpit Web 界面我们可以方便地创建新用户。在这里创建的账户会应用到系统用户账户。我们可以用它更改密码、指定角色、以及删除用户账户。
|
||||
|
||||

|
||||
|
||||
#### 实时终端 ####
|
||||
|
||||
Cockpit 还有一个很棒的特性。是的,我们可以执行命令,用 Cockpit 界面提供的实时终端执行任务。这使得我们可以根据我们的需求在 web 界面和终端之间自由切换。
|
||||
|
||||

|
||||
|
||||
### 总结 ###
|
||||
|
||||
Cockpit 是由 [Red Hat][1] 开发的使得管理服务器变得轻松简单的免费开源软件。它非常适合于进行简单的系统管理任务和新手系统管理员。它仍然处于开发阶段,还没有稳定版发行。因此不适合于生产环境。它是针对最新的默认安装了 systemd 的 Fedora、CentOS、Arch Linux、RHEL 系统开发的。如果你想在 Ubuntu 上安装 Cockpit,你可以通过 PPA 访问,但现在已经过期了。如果你有任何疑问、建议,请在下面的评论框中反馈给我们,这样我们可以改进和更新我们的内容。非常感谢 !
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-how-to/install-cockpit-fedora-centos-rhel-arch-linux/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[ictlyh](http://mutouxiaogui.cn/blog/)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
||||
[1]:http://www.redhat.com/
|
@ -0,0 +1,91 @@
|
||||
提高emacs生产力的最好插件是什么
|
||||
================================================================================
|
||||
一年前的这个时候, 我想要寻找一个最好的插件 [将VIM打造成一个成熟的全功能的IDE][1]. 有趣的是, 很多评论那篇文章的是关于Emacs集成大部分这些插件,已经是一个伟大的IDE了. 尽管我对Emacs的难以置信的多样化表示赞成, 它依旧不是可以开箱即用(安装好不安插件即可用)的高级编辑器. 还好, 其庞大的插件库可以解决这个问题. 但在过多的选项中, 有时很难清楚该如何入手. 因此现在, 让我试着收集一个虽然简短但是不可或缺的插件列表来让你使用Emacs时提高工作效率. 虽然我主要侧重于与编程相关的生产力,但是这些插件将对任何人或对任何使用方法都是有用的.
|
||||
|
||||
### 1. Ido-模式 ###
|
||||
|
||||

|
||||
|
||||
Ido 或许是对新手最有用的一个插件, Ido 表示交互式的去做.它取代大部分的用花哨的匹配字符提示的枯燥菜单 . 好比说, 它将取代正常的提示来打开一个拥有当前目录中的所有文件列表的文件. 任何字符串类型,Ido 将尝试匹配最合适的文件。它很容易想象你的行为,并迅速通过一个文件夹的所有文件命名相同的前缀来查找.
|
||||
|
||||
### 2. Smex ###
|
||||
|
||||

|
||||
|
||||
不算最著名的一个,但却是一个好选择来完成那些由Ido-mode开始的工作:Smex可以优雅的替代正常的“M-x”提示,也有由Ido-mode带来的很大的启发。通常输入的命令调用“M-x”之后它带来同样的互动搜索。它既简单又有效,是一个很好的节省那些额外的你通常需要1秒的短时间方式
|
||||
|
||||
### 3. Auto Complete ###
|
||||
|
||||

|
||||
|
||||
知道这个插件的存在之前,我花了我一半的时间在使用Emacs敲击"M-/"来完成代码上。现在,我有一个漂亮的弹出为我去做自动补全。无须多说,只是我们都需要它。
|
||||
|
||||
### 4. YASnippet ###
|
||||
|
||||

|
||||
|
||||
这是真正的程序员所需利器。总有一些代码,我们觉得我们在它们上面用掉了所有的时间。对我来说,用"var_dump(…);exit;"来调试PHP。经过一段时间一遍又一遍的输入"var_dump(…);exit;",我就想到我可以预先把其作为录制好的,方便的代码片段。YASnippets,很容易导入片段文件或者自己制做。之后,一个简单的按制表键可以将一小关键词扩展成一块预先写好的代码易于使用者浏览和修改。
|
||||
|
||||
|
||||
### 5. Org-mode ###
|
||||
|
||||

|
||||
|
||||
免责声明,我最近才开始使用Org-mode。但它已经深深的吸引了我。从我看过数以百计的书面作品来说,Org-mode可以改变你的生活。它背后的想法很简单:它是一种模式,简化了笔记,同时保持一个纯文本格式,便于浏览列表的任务和各种数据,并执行操作,如按优先级过滤或到期日期,或设置一个复发日期 。然而,从这个简单的想法,你可以完成很多,但也容易被所有的选项弄的不堪重负。与其去看一个长长的解释,我敦促你去通过[可用教程][2],看很多视频,自己去看看Org-mode是多么强大。
|
||||
|
||||
|
||||
### 6. Helm ###
|
||||
|
||||

|
||||
|
||||
一些使用者喜欢它,但是其他人没有这么大的使用热情。我是后者的一部分。但在拥有这样一个庞大的追随者群体的情况下,是不可能避免提到它的。Helm旨在完全变换你的Emacs使用体验。简单描述,Helm是一个这样的框架,在Emacs下将帮助您快速找到一个文件或命令。根据您的输入,它将尝试使用词语自动完成指导你大脑的念头变为行动。起初感觉有点奇怪,但对一些人来说,Helm本身就是一个信仰。虽然我不是Helm的粉丝,我欣赏helm-occur这一个伟大的工具在一个大文档搜索字符串并且在一个单独的缓冲区显示所有,因此很容易导航。如果你正在寻找一个快速演示来了解Helm能做什么,我推荐这篇文章[3]。
|
||||
|
||||
|
||||
### 7. ace-jump-mode ###
|
||||
|
||||

|
||||
|
||||
另一个插件有一大群追随者,我试图加入ace-jump-mode的粉丝群。拥有这个插件,你会体验到胜于鼠标的使用。简单的描述,通过触发ace-jump-mode您选择的快捷方式,你将被提示字符。输入一个字符,所有单词将会出现,独特的字母字符将突出显示。输入一个字母在屏幕上,和你的光标会直接跳转到词高亮显示。我不得不承认,这是让反射很难使用它,但是,一旦你拥有它,它会增加你的在一个文档里光标的移动速度。
|
||||
|
||||
|
||||
|
||||
### 8. find-file-in-project ###
|
||||
|
||||

|
||||
|
||||
如果你喜欢Sublime text和它非常方便的“Ctrl-p”模糊搜索打开在一个项目中的任何文件,你将会喜欢上find-file-in-project(或ffip)。通过声明您的版本控制的根文件夹设置后,您可以轻松地收集一个快速扫描的很酷的标题文本并根据您输入的名称匹配的通过代码库搜索文件。我喜欢把它绑定到键盘上面F6键。如果你不知道从你的顶层目录到最基本文件的复杂结构,它很简单,很方便。
|
||||
|
||||
|
||||
### 9. Flymake ###
|
||||
|
||||

|
||||
|
||||
IDE的爱好者,我认为语法检查器是IDE最强大的特性之一。它非常适合初学者和方便码累了的程序员。感谢Flymake,Emacs用户也可以享受语法检查器 。因为我工作很多需要PHP,Flymake不需要任何额外的配置。当我写代码的时候,它会自动检查我的代码和高亮任何一个包含一个问题的行。对于编译语言,Flymake将寻找一个Makefile,它将用来检查代码。绝对不可思议。
|
||||
|
||||
|
||||
|
||||
### 10. electric-pair ###
|
||||
|
||||
最后,但并非最不重要,在我看来,electric-pair是最简单但最强大的插件之一。它就自动关闭括号或打开括号。它期初看起来不是很好,但相信我。第一百次挣扎后发现匹配的括号,你会很高兴有一个插件,确保你所有的表达式都是平衡的。
|
||||
|
||||
|
||||
|
||||
总结一下,Emacs是一个奇妙的工具。这可不是一个令人惊哑的说法。试试这些插件和看着你的效率直线飙升。这当然不是详尽的列表。如果你想带来你的贡献,请在评论中这样做。我自己一直在寻找新的插件来体验Emacs,也在找寻新方法来体验Emacs。
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/best-plugins-to-increase-productivity-on-emacs.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://xmodulo.com/turn-vim-full-fledged-ide.html
|
||||
[2]:http://orgmode.org/worg/org-tutorials/
|
||||
[3]:http://tuhdo.github.io/helm-intro.html
|
@ -1,49 +0,0 @@
|
||||
在Linux终端看星球大战
|
||||
================================================================================
|
||||

|
||||
星球大战席卷世界。最新一期的 [《星球大战》系列, 《星球大战7:原力觉醒》,打破了有史以来的记录][1].
|
||||
|
||||
虽然我不能帮你得到一张最新的《星球大战》电影的票,但我可以提供给你一种方式,看[星球大战第四集片段][2],它是非常早期的《星球大战》电影。
|
||||
|
||||
不,它不会是高清,也不是蓝光版。相反,它将是ASCII版的《星球大战》第四集片段,你可以在Linux终端看它,这才是真正的极客的方式 :)
|
||||
|
||||
### 在Linux终端看星球大战 ###
|
||||
|
||||
打开一个终端,使用以下命令:
|
||||
|
||||
telnet towel.blinkenlights.nl
|
||||
|
||||
等待几秒钟,你可以在终端看到类似于以下这样的动画ASCII艺术:
|
||||
|
||||

|
||||
|
||||
同时它将继续
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
要停止动画,按 ctrl +],在这之后输入quit来退出tenlnet程序
|
||||
|
||||
### 更多有趣的终端 ###
|
||||
事实上,看《星球大战》并不是你在Linux终端下唯一能做有趣的事情。您可以运行[终端里的列车][3]或[通过ASCII艺术得到Linux标志][4]。
|
||||
|
||||
我希望你可以在Linux下享受星球争霸
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/star-wars-linux/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.gamespot.com/articles/star-wars-7-breaks-thursday-night-movie-opening-re/1100-6433246/
|
||||
[2]:http://www.imdb.com/title/tt0076759/
|
||||
[3]:http://itsfoss.com/ubuntu-terminal-train/
|
||||
[4]:http://itsfoss.com/display-linux-logo-in-ascii/
|
@ -0,0 +1,246 @@
|
||||
GHLandy Translated
|
||||
|
||||
LFCS 系列第五讲:如何在 Linux 中挂载/卸载本地文件系统和网络文件系统(Samba 和 NFS)
|
||||
|
||||
================================================================================
|
||||
|
||||
Linux 基金会已经发起了一个全新的 LFCS(Linux Foundation Certified Sysadmin,Linux 基金会认证系统管理员)认证,旨在让来自世界各地的人有机会参加到 LFCS 测试,获得关于有能力在 Linux 系统中执行中间系统管理任务的认证。该认证包括:维护正在运行的系统和服务的能力、全面监控和分析的能力以及何时上游团队请求支持的决策能力。
|
||||
|
||||

|
||||
|
||||
LFCS 系列第五讲
|
||||
|
||||
请看以下视频,这里边介绍了 Linux 基金会认证程序。
|
||||
|
||||
注:youtube 视频
|
||||
<iframe width="720" height="405" frameborder="0" allowfullscreen="allowfullscreen" src="//www.youtube.com/embed/Y29qZ71Kicg"></iframe>
|
||||
|
||||
本讲是《十套教程》系列中的第三讲,在这一讲里边,我们会解释如何在 Linux 中挂载/卸载本地和网络文件系统。这些都是 LFCS 认证中的必备知识。
|
||||
|
||||
|
||||
### 挂载文件系统 ###
|
||||
|
||||
在个硬盘分好区之后,Linux 需要通过某些方式对硬盘分区上的数据进行访问。Linux 并不会像 DOS 或者 Windows 那样给每个硬盘分区分配一个字母来作为盘符,而是将硬盘分区挂载到统一的目录树上的挂载点。
|
||||
|
||||
挂载点是一个目录,挂载是一种访问分区上文件系统的方法,挂载文件系统实际上是将一个确切的文件系统(比如一个分区)和目录树中指定的目录联系起来的过程。
|
||||
|
||||
换句话说,管理存储设备的第一步就是把设备关联到文件系统树。要完成这一步,通常可以这样:用 mount 命令来进行临时挂载(用完的时候,使用 umount 命令来卸载),或者通过编辑 /etc/fstab 文件之后重启系统来永久性挂载,这样每次开机都会进行挂载。
|
||||
|
||||
|
||||
不带任何选项的 mount 命令,可以显示当前已挂载的文件系统。
|
||||
|
||||
# mount
|
||||
|
||||

|
||||
|
||||
检查已挂载的文件系统
|
||||
|
||||
另外,mount 命令通常用来挂载文件系统。其基本语法如下:
|
||||
|
||||
# mount -t type device dir -o options
|
||||
|
||||
该命令会指引内核在设备上找到的文件系统(如已格式化为指定类型的文件系统)挂载到指定目录。像这样的形式,mount 命令不会再到 /etc/fstab 文件中进行确认。
|
||||
|
||||
除非像下面,挂载指定的目录或者设备:
|
||||
|
||||
# mount /dir -o options
|
||||
或
|
||||
# mount device -o options
|
||||
|
||||
mount 命令会尝试寻找挂载点,如果找不到就会查找设备(上述两种情况下,mount 命令会在 /etc/fstab 查找相应的设备或挂载点),最后尝试完成挂载操作(这个通常可以成功执行,除非你的挂载点或者设备正在使用中,或者你调用 mount 命令的时候没有 root 权限)。
|
||||
|
||||
你可以看到,mount 命令的每行输出都是如下格式:
|
||||
|
||||
device on directory type (options)
|
||||
|
||||
例如:
|
||||
|
||||
/dev/mapper/debian-home on /home type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
|
||||
|
||||
读作:
|
||||
|
||||
设备 dev/mapper/debian-home 的格式为 ext4,挂载在 /home 下,并且有以下挂载选项: rw,relatime,user_xattr,barrier=1,data=ordered。
|
||||
|
||||
**mount 命令选项**
|
||||
|
||||
下面列出 mount 命令的常用选项
|
||||
|
||||
|
||||
- async:运许在将要挂载的文件系统上进行异步 I/O 操作
|
||||
- auto:标志文件系统通过 mount -a 命令挂载,与 noauto 相反。
|
||||
|
||||
- defaults:该选项为 async,auto,dev,exec,nouser,rw,suid 的一个别名。注意,多个选项必须由逗号隔开并且中间没有空格。倘若你不小心在两个选项中间输入了一个空格,mount 命令会把后边的字符解释为另一个参数。
|
||||
- loop:将镜像文件(如 .iso 文件)挂载为 loop 设备。该选项可以用来模拟显示光盘中的文件内容。
|
||||
- noexec:阻止该文件系统中可执行文件的执行。与 exec 选项相反。
|
||||
|
||||
- nouser:阻止任何用户(除 root 用户外) 挂载或卸载文件系统。与 user 选项相反。
|
||||
- remount:重新挂载文件系统。
|
||||
- ro:只读模式挂载。
|
||||
- rw:读写模式挂载。
|
||||
- relatime:只要访问时间早于修改时间,就更新文件的的访问时间。
|
||||
- user_xattr:允许用户设置和移除可扩展文件系统属性。
|
||||
|
||||
**以 ro 和 noexec 模式挂载设备**
|
||||
|
||||
# mount -t ext4 /dev/sdg1 /mnt -o ro,noexec
|
||||
|
||||
在本例中,我们可以看到,在挂载点 /mnt 中尝试写入文件或者运行可执行文件都会显示相应的错误信息。
|
||||
|
||||
# touch /mnt/myfile
|
||||
# /mnt/bin/echo “Hi there”
|
||||
|
||||

|
||||
|
||||
可读写模式挂载设备
|
||||
|
||||
**以默认模式挂载设备**
|
||||
|
||||
以下场景,我们在重新挂载设备的挂载点中,像上例一样尝试你写入文件和运行可执行文件。
|
||||
|
||||
|
||||
# mount -t ext4 /dev/sdg1 /mnt -o defaults
|
||||
|
||||

|
||||
|
||||
挂载设备
|
||||
|
||||
在这个例子中,我们发现写入文件和命令都完美执行了。
|
||||
|
||||
### 卸载设备 ###
|
||||
|
||||
使用 umount 命令卸载设备,意味着将所有的“在使用”数据全部写入到文件系统了,然后可以安全移除文件系统。请注意,倘若你移除一个没有事先正确卸载的文件系统,就会有造成设备损坏和数据丢失的风险。
|
||||
|
||||
也就是说,你必须设备的盘符或者挂载点中退出,才能卸载设备。换言之,当前工作目录不能是需要卸载设备的挂载点。否则,系统将返回设备繁忙的提示信息。
|
||||
|
||||

|
||||
|
||||
卸载设备
|
||||
|
||||
离开需卸载设备的挂载点最简单的方法就是,运行不带任何选项的 cd 命令,这样会回到当前用户的家目录。
|
||||
|
||||
|
||||
### 挂载常见的网络文件系统 ###
|
||||
最常用的两种网络文件系统是 SMB(Server Message Block,服务器消息块)和 NFS(Network File System,网络文件系统)。如果你只向类 Unix 客户端提供共享,用 NFS 就可以了,如果是向 Windows 和其他类 Unix客户端提供共享服务,就需要用到 Samba 了。
|
||||
|
||||
|
||||
扩展阅读
|
||||
|
||||
- [Setup Samba Server in RHEL/CentOS and Fedora][1]
|
||||
- [Setting up NFS (Network File System) on RHEL/CentOS/Fedora and Debian/Ubuntu][2]
|
||||
|
||||
下面的例子中,假设 Samba 和 NFS 已经在地址为 192.168.0.10 的服务器上架设好了(请注意,架设 NFS 服务器也是 LFCS 考试中需要考核的能力,我们会在后边中提到)。
|
||||
|
||||
|
||||
#### 在 Linux 中挂载 Samba 共享 ####
|
||||
|
||||
第一步:在 Red Hat 以 Debian 系发行版中安装 samba-client、samba-common 和 cifs-utils 软件包,如下:
|
||||
|
||||
# yum update && yum install samba-client samba-common cifs-utils
|
||||
# aptitude update && aptitude install samba-client samba-common cifs-utils
|
||||
然后运行下列命令,查看服务器上可用的 Samba 共享。
|
||||
|
||||
# smbclient -L 192.168.0.10
|
||||
|
||||
并输入远程机器上 root 账户的密码。
|
||||
|
||||

|
||||
|
||||
挂载 Samba 共享
|
||||
|
||||
上图中,已经对可以挂载到我们本地系统上的共享进行高亮显示。你只需要与一个远程服务器上的合法用户名及密码就可以访问共享了。
|
||||
|
||||
第二步:当挂载有密码保护的网络文件系统时候,将你的访问凭证写入到 /etc/fstab 文件中并非明智的选择。你需要将这些信息写入到具有 600 权限的隐藏文件中,像这样:
|
||||
|
||||
# mkdir /media/samba
|
||||
# echo “username=samba_username” > /media/samba/.smbcredentials
|
||||
# echo “password=samba_password” >> /media/samba/.smbcredentials
|
||||
# chmod 600 /media/samba/.smbcredentials
|
||||
|
||||
第三步:然后将下面的内容添加到 /etc/fstab 文件中。
|
||||
|
||||
# //192.168.0.10/gacanepa /media/samba cifs credentials=/media/samba/.smbcredentials,defaults 0 0
|
||||
|
||||
第四步:现在可以挂载你的 Samba 共享了。手动挂载(mount //192.168.0.10/gacanepa)或者重启系统并应用 /etc/fstab 中相应行来用就挂载都可以。
|
||||
|
||||

|
||||
|
||||
挂载有密码保护的 Samba 共享
|
||||
|
||||
#### 在 Linux 系统中挂载 NFS 共享 ####
|
||||
|
||||
第一步:在 Red Hat 以 Debian 系发行版中安装 nfs-common 和 portmap 软件包。如下:
|
||||
|
||||
# yum update && yum install nfs-utils nfs-utils-lib
|
||||
# aptitude update && aptitude install nfs-common
|
||||
|
||||
第二步:为 NFS 共享创建挂载点。
|
||||
|
||||
# mkdir /media/nfs
|
||||
|
||||
第三步:将下面的内容添加到 /etc/fstab 文件中。
|
||||
|
||||
192.168.0.10:/NFS-SHARE /media/nfs nfs defaults 0 0
|
||||
|
||||
第四步:现在可以挂载你的 Samba 共享了。手动挂载(mount 192.168.0.10:/NFS-SHARE)或者重启系统并应用 /etc/fstab 中相应行来用就挂载都可以。
|
||||
|
||||

|
||||
|
||||
挂载 NFS 共享
|
||||
|
||||
### 永久性挂载文件系统 ###
|
||||
|
||||
像前面两个例子那样,/etc/fstab 控制着Linux如何访问硬盘分区及可移动设备。/etc/fstab 由六个字段的内容组成,各个字段之间通过一个空格符或者制表符来分开。井号(#)开始的行只是会被忽略的注释。
|
||||
|
||||
每一行都按照这个格式来写入:
|
||||
|
||||
<file system> <mount point> <type> <options> <dump> <pass>
|
||||
|
||||
其中:
|
||||
|
||||
- <file system>: 第一个字段指定挂载的设备。大多数发行版本都通过分区的标卷(label)或者 UUID 来指定。这样做可以避免分区号改变是带来的错误。
|
||||
- <mount point>: 第二字段指定挂载点。
|
||||
- <type> :文件系统的类型代码与 mount 命令挂载文件系统时使用的类型代码是一样的。通过 auto 类型代码可以让内核自动检测文件系统,这对于可移动设备来说非常方便。注意,该选项可能不是对所有文件系统可用。
|
||||
- <options>: 一个(或多个)挂载选项。
|
||||
- <dump>: 你可能把这个字段设置为 0(否则设置为 1),使得系统启动时禁用 dump 工具(dump 程序曾经是一个常用的备份工具,但现在越来越少用了)对文件系统进行备份。
|
||||
|
||||
- <pass>: 这个字段指定启动系统是是否通过 fsck 来检查文件系统的完整性。0 表示 fsck 不对文件系统进行检查。数字越大,优先级越低。因此,根分区(/)最可能使用数字 1,其他所有需要检查的分区则是以数字 2.
|
||||
|
||||
**Mount 命令例示**
|
||||
|
||||
1. 在系统启动时,通过 TECMINT 标卷来挂载文件系统,并具备 rw 和 noexec 属性,你应该将以下语句添加到 /etc/fstab 文件中。
|
||||
|
||||
LABEL=TECMINT /mnt ext4 rw,noexec 0 0
|
||||
|
||||
2. 若你想在系统启动时挂载 DVD 光驱中的内容,添加已下语句。
|
||||
|
||||
/dev/sr0 /media/cdrom0 iso9660 ro,user,noauto 0 0
|
||||
|
||||
其中 /dev/sr0 为你的 DVD 光驱。
|
||||
|
||||
### 总结 ###
|
||||
|
||||
可以放心,在命令行中挂载/卸载本地和网络文件系统将是你作为系统管理员的日常责任的一部分。同时,你需要掌握 /etc/fstab 文件的编写。希望本文对你有帮助。随时在下边发表评论(或者提问),并分享本文到你的朋友圈。
|
||||
|
||||
|
||||
参考链接
|
||||
|
||||
- [About the LFCS][3]
|
||||
- [Why get a Linux Foundation Certification?][4]
|
||||
- [Register for the LFCS exam][5]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/mount-filesystem-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
[1]:http://www.tecmint.com/setup-samba-server-using-tdbsam-backend-on-rhel-centos-6-3-5-8-and-fedora-17-12/
|
||||
[2]:http://www.tecmint.com/how-to-setup-nfs-server-in-linux/
|
||||
[3]:https://training.linuxfoundation.org/certification/LFCS
|
||||
[4]:https://training.linuxfoundation.org/certification/why-certify-with-us
|
||||
[5]:https://identity.linuxfoundation.org/user?destination=pid/1
|
@ -0,0 +1,333 @@
|
||||
GHLandy Translated
|
||||
|
||||
LFCS 系列第八讲:管理用户和用户组、文件权限和属性以及启用账户 sudo 访问权限
|
||||
|
||||
================================================================================
|
||||
|
||||
去年八月份,Linux 基金会发起了全新的 LFCS(Linux Foundation Certified Sysadmin,Linux 基金会认证系统管理员)认证,旨在让世界各地的人能够参与到关于 Linux 系统中间层的基本管理操作的认证考试中去,这项认证包括:维护正在运行的系统和服务的能力、全面监控和分析的能力以及何时向上游团队请求支持的决策能力。
|
||||
|
||||

|
||||
|
||||
LFCS 系列第八讲
|
||||
|
||||
请看以下视频,里边将描述 LFCS 认证程序。
|
||||
|
||||
注:youtube视频
|
||||
<iframe width="720" height="405" frameborder="0" allowfullscreen="allowfullscreen" src="//www.youtube.com/embed/Y29qZ71Kicg"></iframe>
|
||||
|
||||
本讲是《十套教程》系列的第八讲,在这一讲中,我们将引导你学习如何在 Linux 管理用户和用户组权限的设置,这些内容是 LFCS 认证开始中的必备知识。
|
||||
|
||||
由于 Linux 是一个多用户的操作系统(允许多个用户通过不同主机或者终端访问一个独立系统),因此你需要知道如何才能有效地管理用户:如何添加、编辑、禁用和删除用户账户,并赋予他们足以完成自身任务的必要权限。
|
||||
|
||||
### 添加用户账户 ###
|
||||
|
||||
添加新用户账户,你需要以 root 运行一下两条命令中的任意一条:
|
||||
|
||||
# adduser [new_account]
|
||||
# useradd [new_account]
|
||||
|
||||
当新用户账户添加到系统时,会自动执行以下操作:
|
||||
|
||||
1. 自动创建用户家目录(默认是 /home/username)。
|
||||
|
||||
2. 自动拷贝下列隐藏文件到新建用户的家目录,用来设置新用户会话的环境变量。
|
||||
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
|
||||
3. 自动创建邮件缓存目录 /var/spool/mail/username。
|
||||
|
||||
4. 自动创建于用户名相同的用户组。
|
||||
|
||||
**理解 /etc/passwd 中的内容**
|
||||
|
||||
/etc/passwd 文件中存储了所有用户账户的信息,每个用户在里边都有一条对应的记录,其格式(每个字段用冒号隔开)如下:
|
||||
|
||||
[username]:[x]:[UID]:[GID]:[Comment]:[Home directory]:[Default shell]
|
||||
|
||||
- 字段 [username] 和 [Comment] 是自解释的关系。
|
||||
- 第二个字段中 x 表明通过用户名 username 登录系统是有密码保护的, 密码保存在 /etc/shadow 文件中。
|
||||
- [UID] 和 [GID] 字段用整数表示,代表该用户的用户标识符和对应所在组的组标志符。
|
||||
- 字段 [Home directory] 为 username 用户家目录的绝对路径。
|
||||
- 字段 [Default shell] 指定用户登录系统时默认使用的 shell。
|
||||
|
||||
**理解 /etc/group 中的内容**
|
||||
|
||||
/etc/group 文件存储所有用户组的信息。每行记录的格式如下:
|
||||
|
||||
[Group name]:[Group password]:[GID]:[Group members]
|
||||
|
||||
- [Group name] 为用户组名称。
|
||||
- 字段 [Group password] 为 x 的话,则说明不适用用户组密码。
|
||||
- [GID] 与 /etc/passwd 中保存的 GID 相同。
|
||||
- [Group members] 用户组中的用户使用逗号隔开。
|
||||
|
||||

|
||||
|
||||
添加用户账户
|
||||
|
||||
添加用户账户之后,你可以使用 usermod 命令来修改用户信息中的部分字段,该命令基本语法如下:
|
||||
|
||||
# usermod [options] [username]
|
||||
|
||||
**设置账户的过期时间**
|
||||
|
||||
通过 –expiredate 标记后边接 年-月-日 格式的日期,如下:
|
||||
|
||||
# usermod --expiredate 2014-10-30 tecmint
|
||||
|
||||
**将用户添加到其他组**
|
||||
|
||||
使用 -aG 或者 –append –groups 选项,后边跟着用户组,如果有多个用户组,每个用户组之间使用逗号隔开。
|
||||
|
||||
# usermod --append --groups root,users tecmint
|
||||
|
||||
**改变用户家目录的默认位置**
|
||||
|
||||
使用 -d 或者 –home 选项,后边跟着新的家目录的绝对路径。
|
||||
|
||||
# usermod --home /tmp tecmint
|
||||
|
||||
**改变用户的默认 shell**
|
||||
|
||||
使用 –shell 选项,后边跟着新 shell 的路径。
|
||||
|
||||
# usermod --shell /bin/sh tecmint
|
||||
|
||||
**显示用户所属的用户组**
|
||||
|
||||
# groups tecmint
|
||||
# id tecmint
|
||||
|
||||
下面,我们一次运行上述命令:
|
||||
|
||||
# usermod --expiredate 2014-10-30 --append --groups root,users --home /tmp --shell /bin/sh tecmint
|
||||
|
||||

|
||||
|
||||
usermod 命令例示
|
||||
|
||||
扩展阅读
|
||||
|
||||
- [15 useradd Command Examples in Linux][1]
|
||||
- [15 usermod Command Examples in Linux][2]
|
||||
|
||||
对于已有用户账户,我们还可以:
|
||||
|
||||
**通过锁定密码来禁用账户**
|
||||
|
||||
使用 -L (大写 l)或者 –lock 选项来锁定用户密码。
|
||||
|
||||
# usermod --lock tecmint
|
||||
|
||||
**解锁用户密码**
|
||||
|
||||
使用 –u 或者 –unlock 选项来解锁我们之前锁定的账户。
|
||||
|
||||
# usermod --unlock tecmint
|
||||
|
||||

|
||||
|
||||
锁定用户账户
|
||||
|
||||
**为需要对指定文件进行读写的多个用户建立用户组**
|
||||
|
||||
运行下列几条命令来完成:
|
||||
|
||||
# groupadd common_group # 添加新用户组
|
||||
# chown :common_group common.txt # 将 common.txt 的用户组修改为 common_group
|
||||
# usermod -aG common_group user1 # 添加用户 user1 到 common_group 用户组
|
||||
# usermod -aG common_group user2 # 添加用户 user2 到 common_group 用户组
|
||||
# usermod -aG common_group user3 # 添加用户 user3 到 common_group 用户组
|
||||
|
||||
**删除用户组**
|
||||
|
||||
通过以下命令删除用户组:
|
||||
|
||||
# groupdel [group_name]
|
||||
|
||||
属于这个 group_name 用户组的文件是不会被删除的,而仅仅是删除了用户组。
|
||||
|
||||
### Linux 文件权限 ###
|
||||
|
||||
除了我们在 [Setting File Attributes – Part 3][3] 中说到的基本的读取、写入和执行权限外,文件还有一些不常用却很重要的的权限设置,有时候把它当做“特殊权限”。
|
||||
|
||||
就像之前我们讨论的基本权限,这里同样使用八进制数字或者一个字母(象征性符号)好表示该权限类型。
|
||||
|
||||
**删除用户账户**
|
||||
|
||||
你可以通过 userdel --remove 命令来删除用户账户。这样会删除用户拥有的家目录和家目录下的所有文件,以及邮件缓存目录。
|
||||
|
||||
# userdel --remove [username]
|
||||
|
||||
#### 用户组管理 ####
|
||||
|
||||
每次添加新用户,系统会为该用户创建同名的用户组,此时用户组里边只有新建的用户,其他用户可以随后添加进去。建立用户组的目的之一,就是为了通过对指定资源设置权限来完成对这些资源和文件进行访问控制。
|
||||
|
||||
比如,你有下列用户:
|
||||
|
||||
- user1 (primary group: user1)
|
||||
- user2 (primary group: user2)
|
||||
- user3 (primary group: user3)
|
||||
|
||||
他们都需要对你系统里边某个位置的 common.txt 文件,或者 user1 用户刚刚创建的共享进行读写。你可能会运行下列命令:
|
||||
|
||||
# chmod 660 common.txt
|
||||
或
|
||||
# chmod u=rw,g=rw,o= common.txt [注意最后那个 = 号和文件名之间的空格]
|
||||
|
||||
然而,这样仅仅给文件所属的用户和用户组(本例为 user1)成员的提供了读写权限。你还需要将 user2 和 user3 添加到 user1 组,打这样做也将 user1 用户和用户组的其他文件的权限开放给了 user2 和 user3。
|
||||
|
||||
这时候,用户组就派上用场了,下面将演示怎么做。
|
||||
|
||||
**理解 Setuid 位**
|
||||
|
||||
当为可执行文件设置 setuid 位之后,用户运行程序是会继承该程序属主的有效特权。由于这样做会引起安全风险,因此设置 setuid 权限的文件及程序必须尽量少。你会发现,当系统中有用户需要执行 root 用户所管辖的程序时就是设置了 setuid 权限。
|
||||
|
||||
也就是说,用户不仅仅可以运行这个可执行文件,而且能以 root 权限来运行。比如,先检查 /bin/passwd 的权限,这个可执行文件用于改变账户的密码,并修改 /etc/shadow 文件。超级用户可以改变任意账户的密码,但是其他用户只能改变自己账户的密码。
|
||||
|
||||

|
||||
|
||||
passwd 命令例示
|
||||
|
||||
因此,所有用户都有权限运行 /bin/passwd,但只有 root 用户可以指定改变指定用户账户的密码。其他用户只能改变其自身的密码。
|
||||
|
||||

|
||||
|
||||
修改用户密码
|
||||
|
||||
**理解 Setgid 位**
|
||||
|
||||
设置 setgid 位之后,真实用户的有效 GID 变为属组的 GID。因此,任何用户都能以赋予属组用户的权限来访问文件。另外,当目录置了 setgid 位之后,新建的文件将继承其所属目录的 GID,并且新建的子目录会继承父目录的 setgid 位。通过这个方法,你能够以一个指定用户组的身份来访问该目录里边的文件,而不必管文件属主的主属组。
|
||||
|
||||
# chmod g+s [filename]
|
||||
|
||||
以八进制形式来设置 setgid 位,在当前基本权限(或者想要设置的权限)前加上数字 2 就行了。
|
||||
|
||||
# chmod 2755 [directory]
|
||||
|
||||
**给目录设置 SETGID 位**
|
||||
|
||||

|
||||
|
||||
给命令设置 setgid 位
|
||||
|
||||
**理解 Sticky 位**
|
||||
|
||||
文件设置了 Sticky 为之后,Linux 会将文件忽略,对于该文件影响到的目录,除了属主或者 root 用户外,其他用户无法删除,甚至重命名目录中其他文件也不行。
|
||||
|
||||
# chmod o+t [directory]
|
||||
|
||||
以八进制形式来设置 sticky 位,在当前基本权限(或者想要设置的权限)前加上数字 1 就行了。
|
||||
|
||||
# chmod 1755 [directory]
|
||||
|
||||
若没有 sticky 位,任何有权限读写目录的用户都可删除和重命名文件。因此,sticky 为通常出现在像 /tmp 之类的目录,这些目录是所有人都具有写权限的。
|
||||
|
||||

|
||||
|
||||
给目录设置 sticky 位
|
||||
|
||||
### Linux 特殊文件属性 ###
|
||||
|
||||
文件还有其他一些属性,用来做进一步的操作限制。比如,阻止对文件的重命名、移动、删除甚至是修改。可以通过使用 [chattr 命令][4] 来设置,并可以使用 lsattr 工具来查看这些属性。设置如下:
|
||||
|
||||
# chattr +i file1
|
||||
# chattr +a file2
|
||||
|
||||
运行这些命令之后,file1 成为不可变状态(即不可移动、重命名、修改或删除),而 file2 进入“仅追加”模式(仅在追加内容模式中打开)。
|
||||
|
||||

|
||||
|
||||
通过 Chattr 命令来包含文件
|
||||
|
||||
### 访问 root 账户并启用 sudo ###
|
||||
|
||||
访问 root 账户的方法之一,就是通过输入:
|
||||
|
||||
$ su
|
||||
|
||||
然后输入 root 账户密码。
|
||||
|
||||
倘若授权成功,你将以 root 身份登录,工作目录则是登录前所在的位置。如果是想要一登录就自动进入 root 用户的家目录,请运行:
|
||||
$ su -
|
||||
|
||||
然后输入 root 账户密码。
|
||||
|
||||

|
||||
|
||||
为用户启用 sudo 访问权限
|
||||
|
||||
执行上个步骤需要普通用户知道 root 账户的密码,这样会引起非常严重的安全问题。于是,系统管理员通常会配置 sudo 命令来让普通用户在严格控制的环境中以其他用户身份(通常是 root)来执行命令。所有,可以在严格控制用户的情况下,又允许他运行一条或多条特权命令。
|
||||
|
||||
- 扩展阅读:[Difference Between su and sudo User][5]
|
||||
|
||||
普通用户通过他自己的用户密码来完成 sudo 授权。输入命令之后会出现输入密码(并不是超级用户密码)的提示,授权成功(只要赋予了用户运行该命令的权限)的话,指定的命令就会运行。
|
||||
|
||||
系统管理员必须编辑 /etc/sudoers 文件,才能为 sudo 赋予相应权限。通常建议使用 visudo 命令来编辑这个文件,而不是使用文本编辑器来打开它。
|
||||
|
||||
# visudo
|
||||
|
||||
这样会使用 vim(如果你按照 [Install and Use vim as Editor – Part 2][6] 里边说的来编辑文件)来打开 /etc/sudoers 文件。
|
||||
|
||||
以下是需要设置的相关的行:
|
||||
|
||||
Defaults secure_path="/usr/sbin:/usr/bin:/sbin"
|
||||
root ALL=(ALL) ALL
|
||||
tecmint ALL=/bin/yum update
|
||||
gacanepa ALL=NOPASSWD:/bin/updatedb
|
||||
%admin ALL=(ALL) ALL
|
||||
|
||||
来更加深入了解这些项:
|
||||
|
||||
Defaults secure_path="/usr/sbin:/usr/bin:/sbin:/usr/local/bin"
|
||||
|
||||
这一行指定 sudo 将要使用的目录,这样可以阻止使用用户指定的目录,那样的话可能会危及系统。
|
||||
|
||||
下一行是用来指定权限的:
|
||||
|
||||
root ALL=(ALL) ALL
|
||||
|
||||
- 第一个 ALL 关键词表明这条规则适用于所有主机。
|
||||
- 第二个 ALL 关键词表明第一个字段中指定的用户能以任何用户身份所具有的权限来运行相应命令。
|
||||
- 第三个 ALL 关键词表明可以运行任何命令。
|
||||
|
||||
tecmint ALL=/bin/yum update
|
||||
|
||||
如果 = 号后边没有指定用户,sudo 则默认为 root 用户。本例中,tecmint 用户能以 root身份运行 yum update 命令。
|
||||
|
||||
gacanepa ALL=NOPASSWD:/bin/updatedb
|
||||
|
||||
NOPASSWD 关键词表明 gacanepa 用户不需要密码,可以直接运行 /bin/updatedb 命令。
|
||||
|
||||
%admin ALL=(ALL) ALL
|
||||
|
||||
% 符号表示该行应用 admin 用户组。其他部分的含义与对于用户的含义是一样的。本例表示 admin 用户组的成员可以通过任何主机的链接来运行任何命令。
|
||||
|
||||
通过 sudo -l 命令可以查看,你的账户拥有什么样的权限。
|
||||
|
||||

|
||||
|
||||
Sudo 访问规则
|
||||
|
||||
### 总结 ###
|
||||
对于系统管理员来说,高效能的用户和文件管理技能是非常必要的。本文已经涵盖了这些内容,我们希望你将这些作为一个开始,,然后慢慢进步。随时在下边发表评论或提问,我们会尽快回应的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/manage-users-and-groups-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
[1]:http://www.tecmint.com/add-users-in-linux/
|
||||
[2]:http://www.tecmint.com/usermod-command-examples/
|
||||
[3]:http://www.tecmint.com/compress-files-and-finding-files-in-linux/
|
||||
[4]:http://www.tecmint.com/chattr-command-examples/
|
||||
[5]:http://www.tecmint.com/su-vs-sudo-and-how-to-configure-sudo-in-linux/
|
||||
[6]:http://www.tecmint.com/vi-editor-usage/
|
Loading…
Reference in New Issue
Block a user