Merge pull request #32 from LCTT/master

Update my repo
This commit is contained in:
joeren
2015-07-31 08:09:30 +08:00
5 changed files with 548 additions and 17 deletions

View File

@@ -1,13 +1,14 @@
在Linux中使用Systemctl管理Systemd服务和单元
systemctl 完全指南
================================================================================
Systemctl是一个systemd工具主要负责控制systemd系统和服务管理器。
Systemd是一个系统管理守护进程、工具和库的集合用于取代System V初始进程。Systemd的功能是用于集中管理和配置类UNIX系统。
在Linux生态系统中Systemd被部署到了大多数的标准Linux发行版中只有数不多的几个尚未部署。Systemd通常是所有其它守护进程的父进程但并非总是如此。
在Linux生态系统中Systemd被部署到了大多数的标准Linux发行版中只有数不多的几个发行版尚未部署。Systemd通常是所有其它守护进程的父进程但并非总是如此。
![Manage Linux Services Using Systemctl](http://www.tecmint.com/wp-content/uploads/2015/04/Manage-Linux-Services-Using-Systemctl.jpg)
使用Systemctl管理Linux服务
*使用Systemctl管理Linux服务*
本文旨在阐明在运行systemd的系统上“如何控制系统和服务”。
@@ -41,11 +42,9 @@ Systemd是一个系统管理守护进程、工具和库的集合用于取代S
root 555 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-logind
dbus 556 1 0 16:27 ? 00:00:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
**注意**systemd是作为父进程PID=1运行的。在上面带-e参数的ps命令输出中选择所有进程-
**注意**systemd是作为父进程PID=1运行的。在上面带-e参数的ps命令输出中选择所有进程-a选择除会话前导外的所有进程并使用-f参数输出完整格式列表即 -eaf
a选择除会话前导外的所有进程并使用-f参数输出完整格式列表如 -eaf
也请注意上例中后随的方括号和样例剩余部分。方括号表达式是grep的字符类表达式的一部分。
也请注意上例中后随的方括号和例子中剩余部分。方括号表达式是grep的字符类表达式的一部分
#### 4. 分析systemd启动进程 ####
@@ -147,7 +146,7 @@ a选择除会话前导外的所有进程并使用-f参数输出完
1 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
#### 10. 检查某个单元cron.service是否启用 ####
#### 10. 检查某个单元(cron.service是否启用 ####
# systemctl is-enabled crond.service
@@ -187,7 +186,7 @@ a选择除会话前导外的所有进程并使用-f参数输出完
dbus-org.fedoraproject.FirewallD1.service enabled
....
#### 13. Linux中如何启动、重启、停止、重载服务以及检查服务httpd.service状态 ####
#### 13. Linux中如何启动、重启、停止、重载服务以及检查服务httpd.service状态 ####
# systemctl start httpd.service
# systemctl restart httpd.service
@@ -214,15 +213,15 @@ a选择除会话前导外的所有进程并使用-f参数输出完
Apr 28 17:21:30 tecmint systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
**注意**当我们使用systemctl的startrestartstop和reload命令时我们不会不会从终端获取到任何输出内容只有status命令可以打印输出。
**注意**当我们使用systemctl的startrestartstop和reload命令时我们不会从终端获取到任何输出内容只有status命令可以打印输出。
#### 14. 如何激活服务并在启动时启用或禁用服务(系统启动时自动启动服务) ####
#### 14. 如何激活服务并在启动时启用或禁用服务(系统启动时自动启动服务) ####
# systemctl is-active httpd.service
# systemctl enable httpd.service
# systemctl disable httpd.service
#### 15. 如何屏蔽让它不能启动或显示服务httpd.service ####
#### 15. 如何屏蔽(让它不能启动)或显示服务(httpd.service ####
# systemctl mask httpd.service
ln -s '/dev/null' '/etc/systemd/system/httpd.service'
@@ -297,7 +296,7 @@ a选择除会话前导外的所有进程并使用-f参数输出完
# systemctl enable tmp.mount
# systemctl disable tmp.mount
#### 20. 在Linux中屏蔽让它不能启)或显示挂载点 ####
#### 20. 在Linux中屏蔽让它不能启)或可见挂载点 ####
# systemctl mask tmp.mount
@@ -375,7 +374,7 @@ a选择除会话前导外的所有进程并使用-f参数输出完
CPUShares=2000
**注意**当你为某个服务设置CPUShares会自动创建一个以服务名命名的目录httpd.service里面包含了一个名为90-CPUShares.conf的文件该文件含有CPUShare限制信息你可以通过以下方式查看该文件
**注意**当你为某个服务设置CPUShares会自动创建一个以服务名命名的目录httpd.service里面包含了一个名为90-CPUShares.conf的文件该文件含有CPUShare限制信息你可以通过以下方式查看该文件
# vi /etc/systemd/system/httpd.service.d/90-CPUShares.conf
@@ -528,13 +527,13 @@ a选择除会话前导外的所有进程并使用-f参数输出完
#### 35. 启动运行等级5即图形模式 ####
# systemctl isolate runlevel5.target
OR
# systemctl isolate graphical.target
#### 36. 启动运行等级3即多用户模式命令行 ####
# systemctl isolate runlevel3.target
OR
# systemctl isolate multiuser.target
#### 36. 设置多用户模式或图形模式为默认运行等级 ####
@@ -572,7 +571,7 @@ via: http://www.tecmint.com/manage-services-using-systemd-and-systemctl-in-linux
作者:[Avishek Kumar][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@@ -0,0 +1,47 @@
Compare PDF Files on Ubuntu
================================================================================
If you want to compare PDF files you can use one of the following utility
### Comparepdf ###
comparepdf is a command line application used to compare two PDF files.The default comparison mode is text mode where the text of each corresponding pair of pages is compared. As soon as a difference is detected the program terminates with a message (unless -v0 is set) and an indicative return code.
The OPTIONS are -ct or --compare=text (the default) for text mode comparisons or -ca or --compare=appearance for visual comparisons (useful if diagrams or other images have changed), and -v=1 or --verbose=1 for reporting differences (and saying nothing for matching files): use -v=0 for no reporting or -v=2 for reporting both different and matching files.
### Install Comparepdf on ubuntu ###
Open the terminal and run the following command
sudo apt-get install comparepdf
**Comparepdf syntax**
comparepdf [OPTIONS] file1.pdf file2.pdf
**Diffpdf**
DiffPDF is a GUI application used to compare two PDF files.By default the comparison is of the text on each pair of pages, but comparing the visual appearance of pages is also supported (for example, if a diagram is changed or if a paragraph is reformatted). It is also possible to compare pticular pages or page ranges. For example, if there are two versions of a PDF file, one with pages 1-12 and the other with pages 1-13 because of an extra page having been added as page 4, they can be compared by specifying two page ranges, 1-12 for the first and 1-3, 5-13 for the second. This will make DiffPDF compare pages in the pairs (1, 1), (2, 2), (3, 3), (4, 5), (5, 6), and so on, to (12, 13).
### Install diffpdf on ubuntu ###
Open the terminal and run the following command
sudo apt-get install diffpdf
### Screenshots ###
![](http://www.ubuntugeek.com/wp-content/uploads/2015/07/14.png)
![](http://www.ubuntugeek.com/wp-content/uploads/2015/07/23.png)
--------------------------------------------------------------------------------
via: http://www.ubuntugeek.com/compare-pdf-files-on-ubuntu.html
作者:[ruchi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.ubuntugeek.com/author/ubuntufix

View File

@@ -0,0 +1,174 @@
How to Setup iTOP (IT Operational Portal) on CentOS 7
================================================================================
iTOP is a simple, Open source web based IT Service Management tool. It has all of ITIL functionality that includes with Service desk, Configuration Management, Incident Management, Problem Management, Change Management and Service Management. iTop relays on Apache/IIS, MySQL and PHP, so it can run on any operating system supporting these applications. Since iTop is a web based application you dont need to deploy any client software on each users PC. A simple web browser is enough to perform day to day operations of an IT environment with iTOP.
To install and configure iTOP we will be using CentOS 7 as base operating with basic LAMP Stack environment installed on it that will cover its almost all prerequisites.
### Downloading iTOP ###
iTop download package is present on SourceForge, we can get its link from their official website [link][1].
![itop download](http://blog.linoxide.com/wp-content/uploads/2015/07/1-itop-download.png)
We will the download link from here and get this zipped file on server with wget command as below.
[root@centos-007 ~]# wget http://downloads.sourceforge.net/project/itop/itop/2.1.0/iTop-2.1.0-2127.zip
### iTop Extensions and Web Setup ###
By using unzip command we will extract the downloaded packages in the document root directory of our apache web server in a new directory with name itop.
[root@centos-7 ~]# ls
iTop-2.1.0-2127.zip
[root@centos-7 ~]# unzip iTop-2.1.0-2127.zip -d /var/www/html/itop/
List the folder to view installation packages in it.
[root@centos-7 ~]# ls -lh /var/www/html/itop/
total 68K
-rw-r--r--. 1 root root 1.4K Dec 17 2014 INSTALL
-rw-r--r--. 1 root root 35K Dec 17 2014 LICENSE
-rw-r--r--. 1 root root 23K Dec 17 2014 README
drwxr-xr-x. 19 root root 4.0K Jul 14 13:10 web
Here is all the extensions that we can install.
[root@centos-7 2.x]# ls
authent-external itop-backup itop-config-mgmt itop-problem-mgmt itop-service-mgmt-provider itop-welcome-itil
authent-ldap itop-bridge-virtualization-storage itop-datacenter-mgmt itop-profiles-itil itop-sla-computation version.xml
authent-local itop-change-mgmt itop-endusers-devices itop-request-mgmt itop-storage-mgmt wizard-icons
installation.xml itop-change-mgmt-itil itop-incident-mgmt-itil itop-request-mgmt-itil itop-tickets
itop-attachments itop-config itop-knownerror-mgmt itop-service-mgmt itop-virtualization-mgmt
Now from the extracted web directory, moving through different data models we will migrate the required extensions from the datamodels into the web extensions directory of web document root directory with copy command.
[root@centos-7 2.x]# pwd
/var/www/html/itop/web/datamodels/2.x
[root@centos-7 2.x]# cp -r itop-request-mgmt itop-service-mgmt itop-service-mgmt itop-config itop-change-mgmt /var/www/html/itop/web/extensions/
### Installing iTop Web Interface ###
Most of our server side settings and configurations are done.Finally we need to complete its web interface installation process to finalize the setup.
Open your favorite web browser and access the WordPress web directory in your web browser using your server IP or FQDN like.
http://servers_ip_address/itop/web/
You will be redirected towards the web installation process for iTop. Lets configure it as per your requirements like we did here in this tutorial.
#### Prerequisites Validation ####
At the stage you will be prompted for welcome screen with prerequisites validation ok. If you get some warning then you have to make resolve it by installing its prerequisites.
![mcrypt missing](http://blog.linoxide.com/wp-content/uploads/2015/07/2-itop-web-install.png)
At this stage one optional package named php mcrypt will be missing. Download the following rpm package then try to install php mcrypt package.
[root@centos-7 ~]#yum localinstall php-mcrypt-5.3.3-1.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm.
After successful installation of php-mcrypt library we need to restart apache web service, then reload the web page and this time its prerequisites validation should be OK.
#### Install or Upgrade iTop ####
Here we will choose the fresh installation as we have not installed iTop previously on our server.
![Install New iTop](http://blog.linoxide.com/wp-content/uploads/2015/07/3.png)
#### iTop License Agreement ####
Chose the option to accept the terms of the licenses of all the components of iTop and click "NEXT".
![License Agreement](http://blog.linoxide.com/wp-content/uploads/2015/07/4.png)
#### Database Configuration ####
Here we the do Configuration of the database connection by giving our database servers credentials and then choose from the option to create new database as shown.
![DB Connection](http://blog.linoxide.com/wp-content/uploads/2015/07/5.png)
#### Administrator Account ####
In this step we will configure an Admin account by filling out its login details as.
![Admin Account](http://blog.linoxide.com/wp-content/uploads/2015/07/6.png)
#### Miscellaneous Parameters ####
Let's choose the additional parameters whether you want to install with demo contents or with fresh database and proceed forward.
![Misc Parameters](http://blog.linoxide.com/wp-content/uploads/2015/07/7.png)
### iTop Configurations Management ###
The options below allow you to configure the type of elements that are to be managed inside iTop like all the base objects that are mandatory in the iTop CMDB, Manage Data Center devices, storage device and virtualization.
![Conf Management](http://blog.linoxide.com/wp-content/uploads/2015/07/8.png)
#### Service Management ####
Select from the choices that best describes the relationships between the services and the IT infrastructure in your IT environment. So we are choosing Service Management for Service Providers here.
![Service Management](http://blog.linoxide.com/wp-content/uploads/2015/07/9.png)
#### iTop Tickets Management ####
From the different available options we will Select the ITIL Compliant Tickets Management option to have different types of ticket for managing user requests and incidents.
![Ticket Management](http://blog.linoxide.com/wp-content/uploads/2015/07/10.png)
#### Change Management Options ####
Select the type of tickets you want to use in order to manage changes to the IT infrastructure from the available options. We are going to choose ITIL change management option here.
![ITIL Change](http://blog.linoxide.com/wp-content/uploads/2015/07/11.png)
#### iTop Extensions ####
In this section we can select the additional extensions to install or we can unchecked the ones that you want to skip.
![iTop Extensions](http://blog.linoxide.com/wp-content/uploads/2015/07/13.png)
### Ready to Start Web Installation ###
Now we are ready to start installing the components that we choose in previous steps. We can also drop down these installation parameters to view our configuration from the drop down.
Once you are confirmed with the installation parameters click on the install button.
![Installation Parameters](http://blog.linoxide.com/wp-content/uploads/2015/07/16.png)
Let's wait for the progress bar to complete the installation process. It might takes few minutes to complete its installation process.
![iTop Installation Process](http://blog.linoxide.com/wp-content/uploads/2015/07/17.png)
### iTop Installation Done ###
Our iTop installation setup is complete, just need to do a simple manual operation as shown and then click to enter iTop.
![iTop Done](http://blog.linoxide.com/wp-content/uploads/2015/07/18.png)
### Welcome to iTop (IT Operational Portal) ###
![itop welcome note](http://blog.linoxide.com/wp-content/uploads/2015/07/20.png)
### iTop Dashboard ###
You can manage configuration of everything from here Servers, computers, Contacts, Locations, Contracts, Network devices…. You can create your own. Just the fact, that the installed CMDB module is great which is an essential part of every bigger IT.
![iTop Dashboard](http://blog.linoxide.com/wp-content/uploads/2015/07/19.png)
### Conclusion ###
ITOP is one of the best Open Source Service Desk solutions. We have successfully installed and configured it on our CentOS 7 cloud host. So, the most powerful aspect of iTop is the ease with which it can be customized via its “extensions”. Feel free to comment if you face any trouble during its setup.
--------------------------------------------------------------------------------
via: http://linoxide.com/tools/setup-itop-centos-7/
作者:[Kashif Siddique][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/kashifs/
[1]:http://www.combodo.com/spip.php?page=rubrique&id_rubrique=8

View File

@@ -0,0 +1,126 @@
Howto Configure Nginx as Rreverse Proxy / Load Balancer with Weave and Docker
================================================================================
Hi everyone today we'll learnHowto configure Nginx as Rreverse Proxy / Load balancer with Weave and Docker Weave creates a virtual network that connects Docker containers with each other, deploys across multiple hosts and enables their automatic discovery. It allows us to focus on developing our application, rather than our infrastructure. It provides such an awesome environment that the applications uses the network as if its containers were all plugged into the same network without need to configure ports, mappings, link, etc. The services of the application containers on the network can be easily accessible to the external world with no matter where its running. Here, in this tutorial we'll be using weave to quickly and easily deploy nginx web server as a load balancer for a simple php application running in docker containers on multiple nodes in Amazon Web Services. Here, we will be introduced to WeaveDNS, which provides a simple way for containers to find each other using hostname with no changes in codes and tells other containers to connect to those names.
Here, in this tutorial, we will use Nginx to load balance requests to a set of containers running Apache. Here are the simple and easy to do steps on using Weave to configure nginx as a load balancer running in ubuntu docker container.
### 1. Settting up AWS Instances ###
First of all, we'll need to setup Amazon Web Service Instances so that we can run docker containers with Weave and Ubuntu as Operating System. We will use the [AWS CLI][1] to setup and configure two AWS EC2 instances. Here, in this tutorial, we'll use the smallest available instances, t1.micro. We will need to have a valid **Amazon Web Services account** with AWS CLI setup and configured. We'll first gonna clone the repository of weave from the github by running the following command in AWS CLI.
$ git clone http://github.com/fintanr/weave-gs
$ cd weave-gs/aws-nginx-ubuntu-simple
After cloning the repository, we wanna run the script that will deploy two instances of t1.micro instance running Weave and Docker in Ubuntu Operating System.
$ sudo ./demo-aws-setup.sh
Here, for this tutorial we'll need the IP addresses of these instances further in future. These are stored in an environment file weavedemo.env which is created during the execution of the demo-aws-setup.sh. To get those ip addresses, we need to run the following command which will give the output similar to the output below.
$ cat weavedemo.env
export WEAVE_AWS_DEMO_HOST1=52.26.175.175
export WEAVE_AWS_DEMO_HOST2=52.26.83.141
export WEAVE_AWS_DEMO_HOSTCOUNT=2
export WEAVE_AWS_DEMO_HOSTS=(52.26.175.175 52.26.83.141)
Please note these are not the IP addresses for our tutorial, AWS dynamically allocate IP addresses to our instances.
As were are using a bash, we will just source this file and execute it using the command below.
. ./weavedemo.env
### 2. Launching Weave and WeaveDNS ###
After deploying the instances, we'll want to launch weave and weavedns on each hosts. Weave and weavedns allows us to easily deploy our containers to a new infrastructure and configuration without the need of changing the codes and without the need to understand concepts such as ambassador containers and links. Here are the commands to launch them in the first host.
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST1
$ sudo weave launch
$ sudo weave launch-dns 10.2.1.1/24
Next, we'll also wanna launch them in our second host.
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST2
$ sudo weave launch $WEAVE_AWS_DEMO_HOST1
$ sudo weave launch-dns 10.2.1.2/24
### 3. Launching Application Containers ###
Now, we wanna launch six containers across our two hosts running an Apache2 Web Server instance with our simple php site. So, we'll be running the following commands which will run 3 containers running Apache2 Web Server on our 1st instance.
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST1
$ sudo weave run --with-dns 10.3.1.1/24 -h ws1.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.2/24 -h ws2.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.3/24 -h ws3.weave.local fintanr/weave-gs-nginx-apache
After that, we'll again launch 3 containers running apache2 web server in our 2nd instance as shown below.
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST2
$ sudo weave run --with-dns 10.3.1.4/24 -h ws4.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.5/24 -h ws5.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.6/24 -h ws6.weave.local fintanr/weave-gs-nginx-apache
Note: Here, --with-dns option tells the container to use weavedns to resolve names and -h x.weave.local allows the host to be resolvable with WeaveDNS.
### 4. Launching Nginx Container ###
After our application containers are running well as expected, we'll wanna launch an nginx container which contains the nginx configuration which will round-robin across the severs for the reverse proxy or load balancing. To run the nginx container, we'll need to run the following command.
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST1
$ sudo weave run --with-dns 10.3.1.7/24 -ti -h nginx.weave.local -d -p 80:80 fintanr/weave-gs-nginx-simple
Hence, our Nginx container is publicly exposed as a http server on $WEAVE_AWS_DEMO_HOST1.
### 5. Testing the Load Balancer ###
To test our load balancer is working or not, we'll run a script that will make http requests to our nginx container. We'll make six requests so that we can see nginx moving through each of the webservers in round-robin turn.
$ ./access-aws-hosts.sh
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws1.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws2.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws3.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws4.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws5.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws6.weave.local",
"date" : "2015-06-26 12:24:23"
}
### Conclusion ###
Finally, we've successfully configured nginx as a reverse proxy or load balancer with weave and docker running ubuntu server in AWS (Amazon Web Service) EC2 . From the above output in above step, it is clear that we have configured it correctly. We can see that the request is being sent to 6 application containers in round-robin turn which is running a PHP app hosted in apache web server. Here, weave and weavedns did great work to deploy a containerised PHP application using nginx across multiple hosts on AWS EC2 without need to change in codes and connected the containers to eachother with the hostname using weavedns. 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 ! Enjoy :-)
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-how-to/nginx-load-balancer-weave-docker/
作者:[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://console.aws.amazon.com/

View File

@@ -0,0 +1,185 @@
Must-Know Linux Commands For New Users
================================================================================
![Manage system updates via the command line with dnf on Fedora.](http://www.linux.com/images/stories/41373/fedora-cli.png)
Manage system updates via the command line with dnf on Fedora.
One of the beauties of Linux-based systems is that you can manage your entire system right from the terminal using the command line. The advantage of using the command line is that you can use the same knowledge and skills to manage any Linux distribution.
This is not possible through the graphical user interface (GUI) as each distro, and desktop environment (DE), offers its own user interfaces. To be clear, there are cases in which you will need different commands to perform certain tasks on different distributions, but more or less the concept and ideas remain the same.
In this article, we are going to talk about some of the basic commands that a new Linux user should know. I will show you how to update your system, manage software, manipulate files and switch to root using the command line on three major distributions: Ubuntu (which also includes its flavors and derivatives, and Debian), openSUSE and Fedora.
*Let's get started!*
### Keep your system safe and up-to-date ###
Linux is secure by design, but the fact is that all software has bugs and there could be security holes. So it's very important to keep your system updated. Think of it this way: Running an out-of-date operating system is like being in an armored tank with the doors unlocked. Will the armor protect you? Anyone can enter through the open doors and cause harm. Similarly there can be un-patched holes in your OS which can compromise your systems. Open source communities, unlike the proprietary world, are extremely quick at patching holes, so if you keep your system updated you'll stay safe.
Keep an eye on news sites to be aware of security vulnerabilities. If there is a hole discovered, read about it and update your system as soon as a patch is out. Either way you must make it a practice to run the update commands at least once a week on production machines. If you are running a complicated server then be extra careful and go through the changelog to ensure updates won't break your customization.
**Ubuntu**: Bear one thing in mind: you must always refresh repositories (aka repos) before upgrading the system or installing any software. On Ubuntu, you can update your system with the following commands. The first command refreshes repositories:
sudo apt-get update
Once the repos are updated you can now run the system update command:
sudo apt-get upgrade
However this command doesn't update the kernel and some other packages, so you must also run this command:
sudo apt-get dist-upgrade
**openSUSE**: If you are on openSUSE, you can update the system using these commands (as usual, the first command is meant to update repos)
sudo zypper refresh
sudo zypper up
**Fedora**: If you are on Fedora, you can use the 'dnf' command which is 'kind' of equivalent to zypper and apt-get:
sudo dnf update
sudo dnf upgrade
### Software installation and removal ###
You can install only those packages which are available in the repositories enabled on your system. Every distro comes with some official or third-party repos enabled by default.
**Ubuntu**: To install any package on Ubuntu, first update the repo and then use this syntax:
sudo apt-get install [package_name]
Example:
sudo apt-get install gimp
**openSUSE**: The commands would be:
sudo zypper install [package_name]
**Fedora**: Fedora has dropped 'yum' and now uses 'dnf' so the command would be:
sudo dnf install [package_name]
The procedure to remove the software is the same, just exchange 'install' with 'remove'.
**Ubuntu**:
sudo apt-get remove [package_name]
**openSUSE**:
sudo zypper remove [package_name]
**Fedora**:
sudo dnf remove [package_name]
### How to manage third party software? ###
There is a huge community of developers who offer their software to users. Different distributions use different mechanisms to make third party software available to their users. It also depends on how a developer offers their software to users; some offer binaries and others offer it through repositories.
Ubuntu heavily relies on PPAs (personal package archives) but, unfortunately, there is no built-in tool which can assist a user in searching PPAs. You will need to Google the PPA and then add the repository manually before installing the software. This is how you would add any PPA to your system:
sudo add-apt-repository ppa:<repository-name>
Example: Let's say I want to add LibreOffice PPA to my system. I would Google the PPA and then acquire the repo name from Launchpad, which in this case is "libreoffice/ppa". Then add the ppa using the following command:
sudo add-apt-repository ppa:libreoffice/ppa
It will ask you to hit the Enter key in order to import the keys. Once it's done, refresh the repos with the 'update' command and then install the package.
openSUSE has an elegant solution for third-party apps. You can visit software.opensuse.org, search for the package and install it with one click. It will automatically add the repo to your system. If you want to add any repo manually, use this command:.
sudo zypper ar -f url_of_the_repo name_of_repo
sudo zypper ar -f http://download.opensuse.org/repositories/LibreOffice:Factory/openSUSE_13.2/LibreOffice:Factory.repo LOF
Then refresh the repo and install software:
sudo zypper refresh
sudo zypper install libreoffice
Fedora users can simply add RPMFusion (both free and non-free repos) which contain a majority of applications. In case you do need to add a repo, this is the command:
dnf config-manager --add-repo http://www.example.com/example.repo
### Some basic commands ###
I have written a few [articles][1] on how to manage files on your system using the CLI, here are some of the basic commands which are common across all distributions.
Copy files or directories to a new location:
cp path_of_file_1 path_of_the_directory_where_you_want_to_copy/
Copy all files from a directory to a new location (notice the slash and asterisk, which implies all files within that directory):
cp path_of_files/* path_of_the_directory_where_you_want_to_copy/
Move a file from one location to another (the trailing slash means inside that directory):
mv path_of_file_1 path_of_the_directory_where_you_want_to_move/
Move all file from one location to another:
mv path_of_directory_where_files_are/* path_of_the_directory_where_you_want_to_move/
Delete a file:
rm path_of_file
Delete a directory:
rm -r path_of_directory
Remove all content from the directory, leaving the directory folder intact:
rm -r path_of_directory/*
### Create new directory ###
To create a new directory, first enter the location where you want to create a directory. Let's say you want to create a 'foundation' folder inside your Documents directory. Let's change the directory using the cd (aka change directory) command:
cd /home/swapnil/Documents
(exchange 'swapnil with the user on your system)
Then create the directory with mkdir command:
mkdir foundation
You can also create a directory from anywhere, by giving the path of the directory. For example:
mdkir /home/swapnil/Documents/foundation
If you want to create parent-child directories, which means directories within other directories then use the -p option. It will create all directories in the given path:
mdkir -p /home/swapnil/Documents/linux/foundation
### Become root ###
You either need to be root or the user should have sudo powers to perform some administrative tasks such as managing packages or making changes to the root directories or files. An example would be to edit the 'fstab' file which keeps a record of mounted hard drives. It's inside the 'etc' directory which is within the root directory. You can make changes to this file only as a super user. In most distros you can become root by 'switching user'. Let's say on openSUSE I want to become root as I am going to work inside the root directory. You can use either command:
sudo su -
Or
su -
That will ask for the password and then you will have root privileges. Keep one point in mind: never run your system as root user unless you know what you are doing. Another important point to note is that the files or directories you modify as root also change ownership of those files from that user or specific service to root. You may have to revert the ownership of those files otherwise the services or users won't be able to to access or write to those files. To change users, this is the command:
sudo chown -R user:user /path_of_file_or_directory
You may often need this when you have partitions from other distros mounted on the system. When you try to access files on such partitions, you may come across a permission denied error. You can simply change the ownership of such partitions to access them. Just be extra careful, don't change permissions or ownership of root directories.
These are the basic commands any new Linux user needs. If you have any questions or if you want us to cover a specific topic, please mention them in the comments below.
--------------------------------------------------------------------------------
via: http://www.linux.com/learn/tutorials/842251-must-know-linux-commands-for-new-users
作者:[Swapnil Bhartiya][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.linux.com/community/forums/person/61003
[1]:http://www.linux.com/learn/tutorials/828027-how-to-manage-your-files-from-the-command-line