Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-04-07 09:50:17 +08:00
commit 73bd2d20c3
10 changed files with 583 additions and 470 deletions

View File

@ -1,23 +1,25 @@
[#]: collector: (lujun9972)
[#]: translator: (MjSeven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12079-1.html)
[#]: subject: (Linux firewall basics with ufw)
[#]: via: (https://www.networkworld.com/article/3533551/linux-firewall-basics-with-ufw.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
Linux 防火墙 ufw 简介
======
我们来研究下 ufw - linux 上一个简单的防火墙,它为防火墙更改提供了一些见解和命令。
> 我们来研究下 Linux 上的 ufw简单防火墙为你更改防火墙提供一些见解和命令。
![][0]
**ufw** (简易防火墙)可以说是 [iptables][1] 的简化版,最近几年,它已经成为 Ubuntu 和 Debian 等系统上的默认防火墙。而且 **ufw** 出乎意料的简单,这对新管理员来说是一个福音,否则他们可能不得不投入大量时间来加快防火墙管理的速度
`ufw`<ruby>简单防火墙<rt>Uncomplicated FireWall</rt></ruby>)真正地简化了 [iptables][1],它从出现的这几年,已经成为 Ubuntu 和 Debian 等系统上的默认防火墙。而且 `ufw` 出乎意料的简单,这对新管理员来说是一个福音,否则他们可能需要投入大量时间来学习防火墙管理
**ufw** 也有 GUI 客户端(例如 **gufw**),但是 **ufw** 命令通常在命令行上发出。本文介绍了一些使用 **ufw** 的命令,并研究了它的工作方式。
`ufw` 也有 GUI 客户端(例如 `gufw`),但是 `ufw` 命令通常在命令行上执行的。本文介绍了一些使用 `ufw` 的命令,并研究了它的工作方式。
首先,查看 **ufw** 如何配置的一个快速方法是查看其配置文件 -- **/etc/default/ufw**。使用下面的命令可以查看其配置,使用 **grep** 来禁止显示空白行和注释(以 # 开头的行)。
首先,快速查看 `ufw` 配置的方法是查看其配置文件 —— `/etc/default/ufw`。使用下面的命令可以查看其配置,使用 `grep` 来抑制了空行和注释(以 # 开头的行)的显示。
```
$ grep -v '^#\|^$' /etc/default/ufw
IPV6=yes
@ -30,16 +32,18 @@ IPT_SYSCTL=/etc/ufw/sysctl.conf
IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_netbios_ns"
```
正如你所看到的,默认策略是丢弃输入但允许输出。如果你想接受专有连接,你需要单独配置。
正如你所看到的,默认策略是丢弃输入但允许输出。允许你接受特定的连接的其它规则是需要单独配置的。
`ufw` 命令的基本语法如下所示,但是这个概要并不意味着你只需要输入 `ufw` 就行,而是一个告诉你需要哪些参数的快速提示。
ufw 命令的基本语法如下所示,但是这个概要并不意味着你只需要输入 "ufw" 就能熟悉它,而是通过一个个错误提示来告诉你需要哪些参数。
```
ufw [--dry-run] [options] [rule syntax]
```
**\--dry-run** 选项意味着 **ufw** 不会运行你指定的命令,但你会看到它是否执行了的结果。如果进行了更改,它将显示整个规则集,因此你要做好多行输出的准备。
`--dry-run` 选项意味着 `ufw` 不会运行你指定的命令,但会显示给你如果执行后的结果。但是它会显示假如更改后的整个规则集,因此你要做有好多行输出的准备。
要检查 `ufw` 的状态,请运行以下命令。注意,即使是这个命令也需要使用 `sudo` 或 root 账户。
运行以下命令来检查 **ufw** 的状态。注意,即使此命令也需要使用 **sudo** 或 root 账户。
```
$ sudo ufw status
Status: active
@ -52,12 +56,14 @@ To Action From
```
否则,你会看到以下内容:
```
$ ufw status
ERROR: You need to be root to run this script
```
"verbose" 选项将提供一些其它细节:
加上 `verbose` 选项会提供一些其它细节:
```
$ sudo ufw status verbose
Status: active
@ -73,12 +79,14 @@ To Action From
```
你可以使用以下命令轻松地通过端口号允许和拒绝连接:
```
$ sudo ufw allow 80 <== 允许 http 访问
$ sudo ufw deny 25 <== 拒绝 smtp 访问
```
你可以查看 **/etc/services** 文件来找到端口号和服务名称之间的联系。
你可以查看 `/etc/services` 文件来找到端口号和服务名称之间的联系。
```
$ grep 80/ /etc/services
http 80/tcp www # WorldWideWeb HTTP
@ -119,7 +127,7 @@ To Action From
443/tcp (v6) ALLOW Anywhere (v6) <==
```
**ufw** 遵循的规则存储在 **/etc/ufw** 目录中,注意,你需要 root 用户访问权限才能查看这些文件,每个文件都包含大量规则。
`ufw` 遵循的规则存储在 `/etc/ufw` 目录中。注意,你需要 root 用户访问权限才能查看这些文件,每个文件都包含大量规则。
```
$ ls -ltr /etc/ufw
@ -137,7 +145,8 @@ drwxr-xr-x 3 root root 4096 Nov 12 08:21 applications.d
-rw-r----- 1 root root 1530 Mar 19 10:42 user6.rules
```
本文前面所作的更改,为 **http** 访问添加了端口 **80** 和为 **https** 访问添加了端口 **443**,在 **user.rules****user6.rules** 文件中看起来像这样:
本文前面所作的更改,为 `http` 访问添加了端口 `80` 和为 `https` 访问添加了端口 `443`,在 `user.rules``user6.rules` 文件中看起来像这样:
```
# grep " 80 " user*.rules
user6.rules:### tuple ### allow tcp 80 ::/0 any ::/0 in
@ -152,13 +161,15 @@ user.rules:### tuple ### allow tcp 443 0.0.0.0/0 any 0.0.0.0/0 in
user.rules:-A ufw-user-input -p tcp --dport 443 -j ACCEPT
```
使用 **ufw**,你还可以使用以下命令轻松地阻止来自一个系统的连接:
使用 `ufw`,你还可以使用以下命令轻松地阻止来自一个 IP 地址的连接:
```
$ sudo ufw deny from 208.176.0.50
Rule added
```
status 命令将显示更改:
`status` 命令将显示更改:
```
$ sudo ufw status verbose
Status: active
@ -178,9 +189,7 @@ Anywhere DENY IN 208.176.0.50 <== new
443/tcp (v6) ALLOW IN Anywhere (v6)
```
总而言之,**ufw** 不仅容易配置,而且且容易理解。
加入 [Facebook][4] 和 [LinkedIn][5] 上的网络世界社区,评论最火的主题。
总而言之,`ufw` 不仅容易配置,而且且容易理解。
--------------------------------------------------------------------------------
@ -189,7 +198,7 @@ via: https://www.networkworld.com/article/3533551/linux-firewall-basics-with-ufw
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (name1e5s)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,183 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (messon007)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (The Keyring Concept in Ubuntu: What is It and How to Use it?)
[#]: via: (https://itsfoss.com/ubuntu-keyring/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
The Keyring Concept in Ubuntu: What is It and How to Use it?
======
If you use [automatic login in Ubuntu][1] or other Linux distributions, you might have come across a pop-up message of this sort:
**Enter password to unlock your login keyring
The login keyring did not get unlocked when you logged into your computer.**
![Enter Password To Unlock Your Login Keyring Ubuntu][2]
It keeps on popping up several times before disappearing if you keep on clicking cancel. You may wonder why do you keep seeing this keyring message all the time?
Let me tell you something. Its not an error. Its a security feature.
Surprised? Let me explain the keyring concept in Linux.
### What is keyring in Linux and why is it used?
![][3]
Why do you use a keyring (also called [keychain][4]) in the real life? You use it to keep one or more keys grouped together so that they are easy to find and carry.
Its the same concept in Linux. The keyring feature allows your system to group various passwords together and keep it one place.
Most desktop environments like GNOME, KDE, Xfce etc use an implementation of [gnome-keyring][5] to provide this keyring feature in Linux.
This keyring keeps your ssh keys, GPG keys and keys from applications that use this feature, like Chromium browser. By default, the **keyring is locked with a master password** which is often the login password of the account.
Every user on your system has its own keyring with (usually) the same password as that of the user account itself. When you login to your system with your password, your keyring is unlocked automatically with your accounts password.
The problem comes when you [switch to auto-login in Ubuntu][1]. This means that you login to the system without entering the password. In such case, your keyring is not unlocked automatically.
#### Keyring is a security feature
Remember I told you that the keyring was a security feature? Now imagine that on your Linux desktop, you are using auto-login. Anyone with access to your desktop can enter the system without password but you have no issues with that perhaps because you use it to browse internet only.
But if you use a browser like Chromium or [Google Chrome in Ubuntu][6], and use it to save your login-password for various websites, you have an issue on your hand. Anyone can use the browser and login to the websites for which you have saved password in your browser. Thats risky, isnt it?
This is why when you try to use Chrome, it will ask you to unlock the keyring repeatedly. This ensures that only the person who knows the keyrings password (i.e. the account password) can use the saved password in browser for logging in to their respective websites.
If you keep on cancelling the prompt for keyring unlock, it will eventually go away and let you use the browser. However, the saved password wont be unlocked and youll see sync paused in Chromium/Chrome browsers.
![Sync paused in Google Chrome][7]
#### If this keyring always exited, why you never saw it?
Thats a valid question if you have never seen this keyring thing in your Linux system.
If you never used automatic login (or changed your accounts password), you might not even have realized that this feature exists.
This is because when you login to your system with your password, your keyring is unlocked automatically with your accounts password.
Ubuntu (and other distributions) asks for password for common admin tasks like modifying users, installing new software etc irrespective of whether you auto login or not. But for regular tasks like using a browser, it doesnt ask for password because keyring is already unlocked.
When you switch to automatic login, you dont enter the password for login anymore. This means that the keyring is not unlocked and hence when you try to use a browser which uses the keyring feature, it will ask to unlock the keyring.
#### You can easily manage the keyring and passwords
Where is this keyring located? At the core, its a daemon (a program that runs automatically in the background).
Dont worry. You dont have to fight the daemon in the terminal. Most desktop environments come with a graphical application that interacts with this daemon. On KDE, there is KDE Wallet, on GNOME and others, its called Password and Keys (originally known as [Seahorse][8]).
![Password And Keys App in Ubuntu][9]
You can use this GUI application to see what application use the keyring to manage/lock passwords.
As you can see, my system has the login keyring which is automatically created. There is also a keyrings for storing GPG and SSH keys. The [Certificates][10] is for keeping the certificates (like HTTPS certificates) issued by a certificate authority.
![Password and Keys application in Ubuntu][11]
You can also use this application to manually store passwords for website. For example, I created a new password-protected keyring called Test and stored a password in this keyring manually.
This is slightly better than keeping a list of passwords in a text file. At least in this case your passwords can be viewed only when you unlock the keyring with password.
![Saving New Password Seahorse][12]
One potential problem here is that if you format your system, the manually saved passwords are definitely lost. Normally, you make backup of personal files, not of all the user specific data such as keyring files.
There is way to handle that. The keyring data is usually stored in ~/.local/share/keyrings directory. You can see all the keyrings here but you cannot see its content directly. If you remove the password of the keyring (Ill show the steps in later section of this article), you can read the content of the keyring like a regular text file. You can copy this unlocked keyring file entirely and import it in the Password and Keys application on some other Linux computer (running this application).
So, let me summarize what you have learned so far:
* Most Linux has this keyring feature installed and activated by default
* Each user on a system has its own keyring
* The keyring is normally locked with the accounts password
* Keyring is unlocked automatically when you login with your password
* For auto-login, the keyring is not unlocked and hence you are asked to unlock it when you try to use an application that uses keyring
* Not all browsers or application use the keyring feature
* There is a GUI application installed to interact with keyring
* You can use the keyring to manually store passwords in encrypted format
* You can change the keyring password on your own
* You can export (by unlocking the keyring first) and import it on some other computer to get your manually saved passwords
### Change keyring password
Suppose you changed your account password. Now when you login, your system tries to unlock the keyring automatically using the new login password. But the keyring still uses the old login password.
In such a case, you can change the keyring password to the new login password so that the keyring gets unlocked automatically as soon as you login to your system.
Open the Password and Keys application from the menu:
![Look for Password and Keys app in the menu][9]
Now, right click on the Login keyring and click on Change Password:
![Change Keyring Password][13]
What if you dont remember the old login password?
You probably know that it is [easy to reset forgotten password in Ubuntu][14]. The problem comes with the keyring in such cases. You changed the account password but you dont remember the old account password that is still used by the keyring.
Now you cannot change it because you dont know the old password. What to do now?
In such a case, youll have to remove the entire keyring itself. You can do that from the Passwords and Keys application:
![Delete Keyring Ubuntu][15]
It will ask for your confirmation:
![Delete Keyring][16]
Alternatively, you may also manually delete the keyring files in ~/.local/share/keyrings directory.
When the old keyring is removed and you try to use Chrome/Chromium, it will ask you to create new keyring.
![New Keyring Password][17]
You can use the new login password so that the keyring gets unlocked automatically.
### Disable keyring password
In cases where you want to use automatic login but dont want to unlockk keyring manually, you may choose to disable the keyring with a workaround. Keep in mind that you are disabling a security feature so think twice before doing so.
The process is similar to changing keyring password. Open Password and Keys application and go on to change the keyring password.
The trick is that when it asks to change the password, dont enter a new password and hit Continue instead. This will remove any password from the keyring.
![Disable Keyring password by not setting any password at all][18]
This way, the keyring will have no password and it remains unlocked all the time.
--------------------------------------------------------------------------------
via: https://itsfoss.com/ubuntu-keyring/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-automatic-logon/
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/enter-password-to-unlock-your-login-keyring-ubuntu.jpg?ssl=1
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/keyring-concept-ubuntu-1.png?ssl=1
[4]: https://en.wikipedia.org/wiki/Keychain
[5]: https://wiki.archlinux.org/index.php/GNOME/Keyring
[6]: https://itsfoss.com/install-chrome-ubuntu/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/sync-paused-keyring-ubuntu.jpg?ssl=1
[8]: https://wiki.debian.org/Seahorse
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/password-and-keys-app-ubuntu.jpg?ssl=1
[10]: https://help.ubuntu.com/lts/serverguide/certificates-and-security.html
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/keyring-pasword-ubuntu.png?ssl=1
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/saving-new-password-seahorse.png?ssl=1
[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/change-keyring-password.png?ssl=1
[14]: https://itsfoss.com/how-to-hack-ubuntu-password/
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/delete-keyring-ubuntu.jpg?ssl=1
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/delete-keyring.jpg?ssl=1
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/new-keyring-password.jpg?ssl=1
[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/disable-keyring-password-ubuntu.png?ssl=1

View File

@ -1,102 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Find Which Graphics Card do You Have in Linux?)
[#]: via: (https://itsfoss.com/check-graphics-card-linux/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
How to Find Which Graphics Card do You Have in Linux?
======
Be it [Nvidia][1] or [Radeon][2] or Intel, they all may have some issues with Linux. When you are on your way to troubleshoot the graphics problem, the first thing you want to know is which graphics card do you have in your system.
Linux has several commands to check hardware information. You can use them to check what graphics card (also refer to as video card) do you have. Let me show you a couple of commands to get GPU information in Linux.
### Check graphics card details in Linux command line
![][3]
#### Use lspci command to find graphics card
The lspci command displays the information about devices connected through [PCI][4] (peripheral Component Interconnect) buses. Basically, this command gives you the detail about all the peripheral devices to your system from keyboard and mouse to sound, network and graphics cards.
By default, youll have a huge list of such peripheral devices. This is why you need to filter the output for graphics card with grep command in this manner:
```
lspci | grep VGA
```
This should show a one line information about your graphics card:
```
[email protected]:~$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02)
```
As you can see, my system has Intel HD 620 video card.
#### Get detailed graphics card information with lshw command in Linux
The lspci command is good enough to see what graphics card you have but it doesnt tell you a lot. You can use lshw command to get more information on it.
This command requires you to have root access. You need to specify that you are looking for video card (graphics card) information in this fashion:
```
sudo lshw -C video
```
And as you can see in the output below, this command gives more information on the graphics card such as clock rate, width, driver etc.
```
[email protected]:~$ sudo lshw -C video
[sudo] password for abhishek:
*-display
description: VGA compatible controller
product: HD Graphics 620
vendor: Intel Corporation
physical id: 2
bus info: [email protected]:00:02.0
version: 02
width: 64 bits
clock: 33MHz
capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
configuration: driver=i915 latency=0
resources: irq:139 memory:db000000-dbffffff memory:90000000-9fffffff ioport:f000(size=64) memory:c0000-dffff
```
#### Bonus Tip: Check graphics card details graphically
Its not that you must use the command line to find graphics card details in Linux. Most Linux distributions (or should I say desktop environments) provide essential details in the settings application.
For example, if you are using [GNOME desktop environment][5], you can check the details by going to About section of Settings. Heres what it looks like in [Ubuntu 20.04][6]:
![Graphics card information check graphically][7]
I hope you find this quick tip helpful. You can also use the same commands to [find your network adapter][8] and [CPU information in Linux][9].
If you have questions or suggestions, dont hesitate to write a comment.
--------------------------------------------------------------------------------
via: https://itsfoss.com/check-graphics-card-linux/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://www.nvidia.com/en-us/
[2]: https://www.amd.com/en/graphics/radeon-rx-graphics
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/check-gpu-info-linux.jpg?ssl=1
[4]: https://en.wikipedia.org/wiki/Conventional_PCI
[5]: https://www.gnome.org/
[6]: https://itsfoss.com/ubuntu-20-04-release-features/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/ubuntu-gpu-check.jpg?ssl=1
[8]: https://itsfoss.com/find-network-adapter-ubuntu-linux/
[9]: https://linuxhandbook.com/check-cpu-info-linux/

View File

@ -1,162 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (MjSeven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Scheduling tasks on Linux using the at command)
[#]: via: (https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
Scheduling tasks on Linux using the at command
======
The at command makes it easy to schedule Linux tasks to be run at any time or date you choose. Check out what it can do for you.
romkaz / Getty Images
When you want commands or scripts to run at some particular time, you dont have to sit with your fingers hovering over the keyboard waiting to press the enter key or even be at your desk at the right time. Instead, you can set your task to be run through the **at** command. In this post, well look at how tasks are scheduled using **at**, how you can precisely select the time you want your process to run and how to view whats been scheduled to run using **at**.
### at vs cron
For those whove been scheduling tasks on Linux systems using **cron**, the **at** command is something like **cron** in that you can schedule tasks to run at a selected time, but **cron** is used for jobs that are run periodically even if that means only once a year. Most **cron** jobs are set up to be run daily, weekly or monthly, though you control how often and when.
The **at** command, on the other hand, is used for tasks which are run only once. Want to reboot your system at midnight tonight? No problem, **at** can do that for you assuming you have the proper permissions. If you want the system rebooted every Saturday night at 2 a.m., use **cron** instead.
### Using at
The **at** command is easy to use ,and there are only a few things to remember. A simple use of **at** might look like this:
```
$ at 5:00PM
at> date >> thisfile
at> <EOT>
```
After typing “at” and the time the command should be run, **at** prompts you for the command to be run (in this case, the **date** command). Type **^D** to complete your request.
Assuming we set up this **at** command earlier than 5 p.m., the date and time will be added to the end of a file named “thisfile” later the same day. Otherwise, the command will run at 5 p.m. the following day.
You can enter more than one command when interacting with the **at** command. If you want more than one command to be run at the same time, simply specify more than one command line:
[][1]
```
$ at 6:22
warning: commands will be executed using /bin/sh
at> echo first >> thisfile
at> echo second >> thisfile
at> <EOT>
```
In the commands above, were using a regular user account and adding some simple text to a file in that users home directory. If its after 6:22 a.m. when this command is run, the command will run the following day because 6:22 is taken to mean 6:22 a.m. If you want it to run at 6:22 p.m., either use 6:22 PM or 18:22. “6:22 PM” also works.
You can use **at** to schedule commands to run on specific dates either by specifying the dates or specifying dates and times like “10:00AM April 15 2021” or “noon + 5 days” (run at noon five days from today). Here are some examples:
```
at 6PM tomorrow
at noon April 15 2021
at noon + 5 days
at 9:15 + 1000 days
```
After you specify the command to run and press **^D**, you will notice that the **at** command has assigned a job number to each request. This number will show up in the **at** command's job queue.
```
$ at noon + 1000 days
warning: commands will be executed using /bin/sh
at> date >> thisfile
at> <EOT>
job 36 at Tue Dec 27 12:00:00 2022 <== job # is 36
```
### Checking the queue
You can look at the queue of **at** jobs with the **atq** (at queue) command:
```
$ atq
32 Thu Apr 2 03:06:00 2020 a shs
35 Mon Apr 6 12:00:00 2020 a shs
36 Tue Dec 27 12:00:00 2022 a shs
34 Thu Apr 2 18:00:00 2020 a shs
```
If you need to cancel one of the jobs in the queue, use the **atrm** (at remove) command along with the job number.
```
$ atrm 32
$ atq
35 Mon Apr 6 12:00:00 2020 a shs
36 Tue Dec 27 12:00:00 2022 a shs
34 Thu Apr 2 18:00:00 2020 a shs
```
You can look into the details of a scheduled task using the **at -c** command. Additional details (the active search path, etc.) are also available, but the bottom lines of the output will show you what command has been scheduled to run.
```
$ at -c 36 | tail -6
cd /home/shs || {
echo 'Execution directory inaccessible' >&2
exit 1
}
date >> thisfile
```
Notice that the command shown begins with testing whether the users directory can be entered with a **cd** command. The job will exit with an error if this is not the case. Otherwise the command specified when the **at** command was issued will be run. Read the command as "move into /home/shs OR exit with the error shown".
### Running jobs as root
To run **at** jobs as root, simply use **sudo** with your **at** command like this:
```
$ sudo at 8PM
[sudo] password for shs:
warning: commands will be executed using /bin/sh
at> reboot now
at> <EOT>
job 37 at Wed Apr 1 16:00:00 2020
```
Notice that the root task shows up in the queue with **root** as the one to execute it.
```
35 Mon Apr 6 12:00:00 2020 a shs
36 Tue Dec 27 12:00:00 2022 a shs
37 Wed Apr 1 20:00:00 2020 a root <==
```
### Running scripts
You can also use the **at** command to run scripts. Here's an example:
```
$ at 4:30PM
warning: commands will be executed using /bin/sh
at> bin/tryme
at> <EOT>
```
### Denying use of the at command
The **/etc/at.deny** file provides a way to disallow users from being able to make use of the **at** command. By default, it will probably include a list of disallowed accounts like **ftp** and **nobody**. An **/etc/at.allow** file could be used to do the opposite but, generally, only the **at.deny** file is configured.
**Wrap-Up**
The **at** command is very versatile and easy to use when you want to schedule a one-time task even if you want it to run this afternoon or years in the future.
Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy)
[2]: https://www.facebook.com/NetworkWorld/
[3]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,114 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Bitwarden: A Free & Open Source Password Manager)
[#]: via: (https://itsfoss.com/bitwarden/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
Bitwarden: A Free & Open Source Password Manager
======
_**Brief:** Bitwarden is a popular open-source password manager. Here, we take a look at what it has to offer._
![][1]
[Bitwarden][2] is a free and open-source password manager. You might remember that earlier we listed it as one of the [best password managers available for Linux][3].
Personally, Ive been using Bitwarden as my password manager across multiple devices for several months now. So, in this article, Ill be mentioning the features it offers along with my experience with it.
**Note:** _In case you have questions about how secure the service is, check out their official security [FAQ page][4] to explore about it._
### Features of Bitwarden password manager
![][5]
[Bitwarden][2] is an impressive alternative to a lot of other convenient password managers out there.
Heres a breakdown of the features:
* Free &amp; Paid options available
* Available for Teams (Enterprise) and Individuals
* Open source
* Self-hosting support
* Ability to use it as an authenticator app (like Google Authenticator)
* Cross-platform support (Android, iOS, Linux, Windows, &amp; macOS)
* Browser extensions available (Firefox, Chrome, Opera, Edge, Safari)
* Offers command-line tools
* Offers a Web Vault
* Ability to Import/Export Passwords
* [Password Generator][6]
* Auto-fill password
* Two-step authentication
Technically, Bitwarden is completely free to use however, it also offers some paid plans (Personal pricing plans &amp; Business plans).
With the premium plans, you get the ability to share the passwords with more users, get API access (business use), and more such premium perks.
Heres how the pricing looks like (at the time of writing this article):
![][7]
For most individuals, the premium personal plan of **$10/year** shouldnt be an issue considering the fact that you will be supporting an open-source project. Of course, you can also choose to use it for free with no essential restrictions.
### Installing Bitwarden on Linux
![][8]
Its quite easy to get Bitwarden installed on your Linux system because it offers an .**AppImage** file. You can refer to our guide on [how to use AppImage][9] files, if you didnt know it already.
If you dont prefer using AppImage you can opt for the [snap package][10] or simply download the **.deb** or **.rpm** file available on their [official download page][11]. You can also check out their [GitHub page][12] for more information.
[Download Bitwarden][2]
You can also utilize the browser extensions if youre not interested in using the desktop app.
### My experience with Bitwarden
Before Bitwarden, I was using [LastPass][13] as my password manager. Even though thats not a bad option its not an open-source software.
So, I decided to switch to Bitwarden as soon as I found out about it.
To start with, I simply exported my data from LastPass and imported it to Bitwarden without any hiccups. I didnt lose any data in the process.
In addition to the desktop app, Ive been using Bitwarden the Firefox add-on, and the Android app. I havent had any issues with it after over six months of usage. So, Id definitely give it thumbs up from my side if youre willing to try it out!
### Wrapping Up
Id say that Bitwarden is a complete solution for Linux users who want a password manager that works everywhere and syncs easily across multiple devices.
You can get started for free but if you can, please go for the premium plan of **$10/year** to support this open-source project.
You may also check our list of [top 5 password managers for Linux][3] should come in handy if youre looking for more options.
Have you tried Bitwarden yet? If not, give it a try! Also, what is your favorite password manager? Let me know in the comments below!
--------------------------------------------------------------------------------
via: https://itsfoss.com/bitwarden/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-screenshot.jpg?ssl=1
[2]: https://bitwarden.com/
[3]: https://itsfoss.com/password-managers-linux/
[4]: https://help.bitwarden.com/security/
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-dark-mode.jpg?ssl=1
[6]: https://itsfoss.com/password-generators-linux/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-pricing.jpg?ssl=1
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-settings.png?ssl=1
[9]: https://itsfoss.com/use-appimage-linux/
[10]: https://snapcraft.io/bitwarden
[11]: https://bitwarden.com/#download
[12]: https://github.com/bitwarden
[13]: https://www.lastpass.com/

View File

@ -0,0 +1,182 @@
[#]: collector: (lujun9972)
[#]: translator: (messon007)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (The Keyring Concept in Ubuntu: What is It and How to Use it?)
[#]: via: (https://itsfoss.com/ubuntu-keyring/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
解读Ubuntu里的密钥环概念
======
如果您用过[ubuntu里的自动登录功能][1]或者其他的Linux发行版, 您可能遇到过这种弹出消息:
**请输入密码以解锁您的登录密钥环
登录密钥环在您登录系统时未解锁**
![Enter Password To Unlock Your Login Keyring Ubuntu][2]
你需要点击多次取消才能让它消失。你可能想知道为什么系统会多次反复提示这个密钥环消息?
让我来告诉你答案。它其实并没有出错,它只是一个安全特性。
奇怪吗下面就让我来解释下Linux里的密钥环概念。
### Linux里的密钥环是什么以及为什么需要它?
![][3]
在现实生活中您为什么要用钥匙环(也叫[钥匙链][4])? 您用它把一把或多把钥匙串到一起, 以便于携带和查找。
Linux里也是类似的。密钥环特性使您的系统可以将各种密码放在一起并将其保存在一个地方。
大多数Linux桌面环境像GNOME, KDE, Xfce等采用[gnome的密钥环][5]实现来提供这个功能。
该密钥环保存了ssh密钥GPG密钥以及使用此功能的应用程序例如Chromium浏览器的密钥。 默认情况下,**“密钥环”通过主密码来保护**,该密码通常是帐户的登录密码。
系统上的每个用户都有自己的密钥环,(通常)密码与用户帐户本身的密码相同。 当您使用密码登录系统时,您的密匙环将使用您帐户的密码自动解锁。
当您[启用Ubuntu中的自动登录功能时][1]时,就有问题了。这意味着您无需输入密码即可登录系统。 在这种情况下,您的密钥环不会自动解锁。
#### 密钥环是一个安全特性
记得我说过密钥环是一个安全特性吗现在想象一下您在您的Linux电脑上开启了自动登录功能。有权访问您电脑的任何人无需密码就能进入您的系统。但是您可能不会在意因为您只是用它来访问互联网。
但是如果您使用Chromium或[Ubuntu中的Google Chrome][6]之类的浏览器,并使用它来保存各种网站的登录密码,那么您将遇到麻烦。任何人都可以使用浏览器并利用您在浏览器中保存的密码登录网站。那不就是风险吗?
这就是为什么当您使用Chrome时它将反复地提示您先解锁密钥环。这确保了只有知道密钥环密码的人才能使用在浏览器中保存的密码来登录它们相关的网站。
如果您反复取消解锁密钥环的提示它最终将消失并允许您使用浏览器。但是保存的密码将不会被解锁您在Chromium/Chome浏览器上将会看到'同步暂停'的提示。
![Sync paused in Google Chrome][7]
#### 如果密钥环总是存在的,为什么您从来没有见过它呢?
如果您在您的Linux系统上从没见过它的话这就是一个有效的问题。
如果您从没有用过自动登录功能(或者修改您的账户密码),您可能都没有意识到这个特性的存在。
这是因为当您通过您的密码登录系统时,您的密钥环被您的账户密码自动解锁了。
Ubuntu(和其他发行版)对于通用的管理任务像修改用户, 安装新软件等需要输入密码,无论您是否是自动登录的。但是对于日常任务像使用浏览器,它不需要输入密码因为密钥环已经被解锁了。
当您切换到自动登录时,您不再需要输入登录密码。这意味着密钥环没有被自动解锁,因此当您使用利用了密钥环特性的浏览器时,它将提示您来解锁密钥环。
#### 您可以容易地管理密钥环和密码
这个密钥环放在哪里?它的核心是一个守护任务(一个后台自动运行的程序)。
别担心。您不必通过终端来操作守护任务。大多数桌面环境都自带有图形化的应用程序可以和守护进程进行交互。KDE上有KDE钱包GNOME和其他桌面上叫做密码和密钥(原来叫[海马][8])。
![Password And Keys App in Ubuntu][9]
您可以用这个GUI程序来查看什么应用程序在用密钥环来管理/保护密码。
您可以看到我的系统有自动创建的登录密钥环。也有一个存储GPG和SSH密钥的密钥环。那个[证书][10]是用来保存证书机构颁发的证书(像HTTPS证书)的。
![Password and Keys application in Ubuntu][11]
您也可以使用这个应用程序来手动保存网站的密码。例如,我创建了一个新的叫做'Test'的被密码保护的密钥环,并手动存储了一个密码。
这比保存一批密码在一个文本文件中要好一些。至少在这种情况下,您的密码只有在您通过密码解锁了密钥环时才允许被看到。
![Saving New Password Seahorse][12]
一个潜在的问题是如果您格式化您的系统,手动保存的密码必然会丢失。通常,您会备份您的个人文件,但并不是所有的用户特定数据如密钥环文件。
有一种办法能解决它。密钥环数据通常保存在~/.local/share/keyrings目录。在这里您可以看到所有的密钥环但是您不能直接看到它们的内容。如果您移除密钥环的密码(我会在这篇文章的后面描述操作步骤)您可以像一个普通的文本文件一样读取密钥环的内容。您可以完整地拷贝这个解锁后的密钥环文件并在其他的Linux机器(安装了密码和密钥应用)上导入到密码和密钥应用程序。
总结一下目前为止所学的内容:
* 大多数Linux缺省已经安装并激活了密钥环特性
* 系统上的每个用户都拥有他自己的密钥环
* 密钥环通常被账户密码锁定(保护)
* 当您通过密码登录时密钥环会被自动解锁
* 对于自动登录,密钥环不会自动解锁,因此当您试图使用依赖密钥环的应用程序时会被提示先解锁它
* 并不是所有的浏览器或应用程序利用了密钥环特性
* (Linux上)安装了一个GUI程序可以和密钥环交互
* 您可以用密钥环来手动以加密格式来存储密码
* 您可以自己修改密钥环密码
* 您可以通过导出(需要先解锁密钥环)并导入(到其他计算机上)的方式来获取手工保存的密码。
### 修改密钥环密码
假设您修改了您的账户密码。当您登录时,您的系统试图通过新的登录密码来自动解锁密钥环。但是密钥环还在使用老的登录密码。
这种情况下,您可以修改密钥环密码为新的登录密码,这样密码环才能在您登录系统时自动解锁。
从菜单中打开密码和密钥应用程序:
![Look for Password and Keys app in the menu][9]
在登录密钥环上右击并点击修改密码:
![Change Keyring Password][13]
如果您不记得老的登录密码怎么办?
您可能知道[Ubuntu上复位忘记的密码是很容易的][14]。但是密钥环在这种场景下还是有问题。您修改了账户密码但是您不记得仍然被密钥环使用的老的账户密码。
您不能修改它因为您不知道老的密码。怎么办?
这种情况下,您将不得不移除整个密钥环。您可以通过密码和密钥应用程序来操作:
![Delete Keyring Ubuntu][15]
它会提示您进行确认:
![Delete Keyring][16]
另外,您也可以手动删除~/.local/share/keyrings目录下的密钥环文件。
老的密钥环文件被移除后您再打开Chrome/Chromium时它会提示您创建一个新的密钥环。
![New Keyring Password][17]
您可以用新的登录密码,密钥环就会被自动解锁了。
### 禁用密钥环密码
在您想用自动登录但又不想手动解锁密钥环时,您可以把禁用密钥环密码作为一个规避方法。记住您正在禁用一个安全特性,因此请三思。
操作步骤和修改密钥环相似。打开密码和密钥应用程序,然后修改密钥环密码。
技巧在于当它提示修改密码时,不要输入新密码,而是点击继续按钮。这将移除密钥环的密码。
![Disable Keyring password by not setting any password at all][18]
这种方法,密钥环没有密码保护并将一直处于解锁状态。
--------------------------------------------------------------------------------
via: https://itsfoss.com/ubuntu-keyring/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[messon007](https://github.com/messon007)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-automatic-logon/
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/enter-password-to-unlock-your-login-keyring-ubuntu.jpg?ssl=1
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/keyring-concept-ubuntu-1.png?ssl=1
[4]: https://en.wikipedia.org/wiki/Keychain
[5]: https://wiki.archlinux.org/index.php/GNOME/Keyring
[6]: https://itsfoss.com/install-chrome-ubuntu/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/sync-paused-keyring-ubuntu.jpg?ssl=1
[8]: https://wiki.debian.org/Seahorse
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/password-and-keys-app-ubuntu.jpg?ssl=1
[10]: https://help.ubuntu.com/lts/serverguide/certificates-and-security.html
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/keyring-pasword-ubuntu.png?ssl=1
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/saving-new-password-seahorse.png?ssl=1
[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/change-keyring-password.png?ssl=1
[14]: https://itsfoss.com/how-to-hack-ubuntu-password/
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/delete-keyring-ubuntu.jpg?ssl=1
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/delete-keyring.jpg?ssl=1
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/new-keyring-password.jpg?ssl=1
[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/disable-keyring-password-ubuntu.png?ssl=1

View File

@ -0,0 +1,102 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Find Which Graphics Card do You Have in Linux?)
[#]: via: (https://itsfoss.com/check-graphics-card-linux/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何找出 Linux 中的显卡?
======
无论是 [Nvidia][1] 还是 [Radeon][2] 或者 Intel它们都可能在 Linux 中有问题。当你要对图形问题进行故障排除时,首先要了解系统中装有哪种显卡。
Linux 有几个命令可以检查硬件信息。你可以使用它们来检查你有哪些显卡(也称为视频卡)。让我向你展示一些命令来获取 Linux 中的 GPU 信息。
### 在 Linux 命令行中检查显卡详细信息
![][3]
#### 使用 lspci 命令查找显卡
lspci 命令显示通过 [PCI][4](外设组件互连)总线连接的设备的信息。基本上,此命令提供有关系统所有外设的详细信息,从键盘和鼠标到声卡、网卡和显卡。
默认情况下,你会有大量的此类外设列表。这就是为什么你需要用 grep 命令过滤显卡的原因:
```
lspci | grep VGA
```
这应该会显示一行有关你显卡的信息:
```
[email protected]:~$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02)
```
如你所见,我的系统中有 Intel HD 620 显卡。
#### 在 Linux 中使用 lshw 命令获取显卡详细信息
lspci 命令足以查看你的显卡,但是并不能告诉你很多信息。你可以使用 lshw 命令获取有关它的更多信息。
此命令要求你有 root 用户权限。你需要以这种方式查找视频卡(显卡)信息:
```
sudo lshw -C video
```
正如你在下面的输出中看到的那样,此命令提供了有关显卡的更多信息,例如时钟频率、位宽、驱动等。
```
[email protected]:~$ sudo lshw -C video
[sudo] password for abhishek:
*-display
description: VGA compatible controller
product: HD Graphics 620
vendor: Intel Corporation
physical id: 2
bus info: [email protected]:00:02.0
version: 02
width: 64 bits
clock: 33MHz
capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
configuration: driver=i915 latency=0
resources: irq:139 memory:db000000-dbffffff memory:90000000-9fffffff ioport:f000(size=64) memory:c0000-dffff
```
#### 额外的技巧:以图形方式检查显卡详细信息
并非必须使用命令行在 Linux 中查找显卡详细信息。大多数 Linux 发行版(或者应该说是桌面环境)在设置中提供了必要的详细信息。
例如,如果你使用的是 [GNOME 桌面环境][5],那么可以进入“设置”的“关于”部分来检查详细信息。[Ubuntu 20.04][6] 中看上去像这样:
![Graphics card information check graphically][7]
我希望这个快速技巧对你有所帮助。你也可以使用相同的命令来[查找网卡][8]和 [Linux 中的 CPU 信息][9]。
如果你有任何疑问或建议,请随时发表评论。
--------------------------------------------------------------------------------
via: https://itsfoss.com/check-graphics-card-linux/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://www.nvidia.com/en-us/
[2]: https://www.amd.com/en/graphics/radeon-rx-graphics
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/check-gpu-info-linux.jpg?ssl=1
[4]: https://en.wikipedia.org/wiki/Conventional_PCI
[5]: https://www.gnome.org/
[6]: https://itsfoss.com/ubuntu-20-04-release-features/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/ubuntu-gpu-check.jpg?ssl=1
[8]: https://itsfoss.com/find-network-adapter-ubuntu-linux/
[9]: https://linuxhandbook.com/check-cpu-info-linux/

View File

@ -0,0 +1,153 @@
[#]: collector: (lujun9972)
[#]: translator: (MjSeven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Scheduling tasks on Linux using the at command)
[#]: via: (https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
使用 at 命令在 Linu 上安排任务
======
at 命令可以很容易地安排 Linux 任务在你选择的任何时间或日期运行,让我们来看看它能为你做什么。
![][0]
romkaz / Getty Images
当你希望命令或脚本在某个特定时间运行时,你不需要将手指放在键盘上盘旋等待按下回车键,或者是在特定时间坐在办公桌前。相反,你可以通过 **at** 命令来设置任务。在本文中,我们将研究如何使用 **at** 来安排任务,如何精确地选择任务希望运行的时间以及如何使用 **at** 来查看安排运行的任务。
### at vs cron
对于那些使用 **cron** 在 Linux 系统上安排任务的人来说,**at** 命令类似于 **cron**,因为你可以在选定的时间调度任务,但是 **cron** 用于定期运行的作业 - 甚至是每年仅一次。大多数 **cron** 作业的频率都设置为每天、每周或每月运行一次,不过你可以控制运行的频率和时间。
另一方面,**at** 命令用于仅运行一次的任务。想在午夜重启系统?没问题,假设你有适当的权限,**at** 可以为你完成此操作。如果你希望系统在每个星期六凌晨 2 点重启,那么改用 **cron**
### 使用 at
**at** 命令很容易使用,只需记住几件事。一个简单使用 **at** 的例子类似于这样:
```
$ at 5:00PM
at> date >> thisfile
at> <EOT>
```
在输入 "at" 和应该运行命令的时间,**at** 会提示你在设定时间会运行该命令(此例中是 **`date`** 命令)。输入 **^D**(Ctrl + d) 来完成请求。
假设我们在下午 5 点之前设置这个 **at** 命令,那么日期和时间将在当天下午 5 点添加到名为 "thisfile" 文件的末尾。否则,该命令将在第二天下午 5 点运行。
**at** 命令进行交互时,可以输入多个命令。如果你要同时运行多个命令,只需输入多个命令行即可:
[][1]
```
$ at 6:22
warning: commands will be executed using /bin/sh
at> echo first >> thisfile
at> echo second >> thisfile
at> <EOT>
```
在上面的命令中,我们使用了一个普通的用户账户,将一些简单的文本添加到该用户主目录的文件中。如果在上午 6:22 之后运行这些命令,那么命令会在第二天运行,因为 6:22 表示上午 6:22。如果你想在下午 6:22 运行,使用 6:22 PM 或者 18:22"6:22 PM" 也可以。
你也可以通过使用 **at** 来安排命令在指定的日期或时间运行,例如 "10:00AM April 15 2021" 或 "noon + 5 days"(从今天起 5 天内的中午运行),以下是一些例子:
```
at 6PM tomorrow
at noon April 15 2021
at noon + 5 days
at 9:15 + 1000 days
```
在指定要运行的命令并按下 **^D** 后,你会注意到 **at** 命令为每个请求分配了一个作业编号,这个数字将显示在 **at** 命令的作业队列中。
```
$ at noon + 1000 days
warning: commands will be executed using /bin/sh
at> date >> thisfile
at> <EOT>
job 36 at Tue Dec 27 12:00:00 2022 <== job # is 36
```
### 检查队列
你可以使用 **atq**(at queue) 命令来查看 **at** 作业队列:
```
$ atq
32 Thu Apr 2 03:06:00 2020 a shs
35 Mon Apr 6 12:00:00 2020 a shs
36 Tue Dec 27 12:00:00 2022 a shs
34 Thu Apr 2 18:00:00 2020 a shs
```
如果你需要取消队列中的一个作业,使用 **atrm**(at remote) 命令和作业编号:
```
$ atrm 32
$ atq
35 Mon Apr 6 12:00:00 2020 a shs
36 Tue Dec 27 12:00:00 2022 a shs
34 Thu Apr 2 18:00:00 2020 a shs
```
你可以使用 **at -c** 命令来查看安排任务的详细信息,其它详细信息(活动的搜索路径等)也可以,但是输出的最后一行将显示计划运行的命令。
```
$ at -c 36 | tail -6
cd /home/shs || {
echo 'Execution directory inaccessible' >&2
exit 1
}
date >> thisfile
```
注意,命令首先会测试是否可以通过 **cd** 命令进入用户目录。如果不可以,作业将退出并显示错误。如果可以,则运行在 **at** 中指定的命令。它将命令视为 “进入 /home/shs 或退出并显示错误”。
### 以 root 身份运行作业
要以 root 身份运行 **at** 作业,只需将 **sudo** 与你的 **at** 命令一起使用,如下所示:
```
$ sudo at 8PM
[sudo] password for shs:
warning: commands will be executed using /bin/sh
at> reboot now
at> <EOT>
job 37 at Wed Apr 1 16:00:00 2020
```
注意root 的任务以 **root** 作为执行者显示在队列中。
```
35 Mon Apr 6 12:00:00 2020 a shs
36 Tue Dec 27 12:00:00 2022 a shs
37 Wed Apr 1 20:00:00 2020 a root <==
```
### 运行脚本
你还可以使用 **at** 命令来运行脚本,这里有一个例子:
```
$ at 4:30PM
warning: commands will be executed using /bin/sh
at> bin/tryme
at> <EOT>
```
### 禁止使用 at 命令
**/etc/at.deny** 文件提供了一种禁止用户使用 **at** 命令的方法。默认情况下,它可能会包含一个不允许的账户列表,例如 **ftp****nobody**。可以使用 **/etc/at.allow** 文件执行相反的操作,但是通常只配置 **at.deny** 文件。
**总结**
当你要安排一项一次性任务时,无论你是希望在今天下午或几年后运行,**at** 命令都是通用且易于使用的。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[0]: https://images.idgesg.net/images/article/2019/08/gettyimages-140389307-100808283-large.jpg
[1]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy)
[2]: https://www.facebook.com/NetworkWorld/
[3]: https://www.linkedin.com/company/network-world