Xfce 不是最华丽的 Linux 桌面环境,但却是相当节省系统资源的 Linux 桌面环境。就我个人的使用习惯而言,在 Linux 上,特别是 Linux 虚拟机中使用 Xfce 桌面是一个极佳的选择,因为这样可以把有限的系统资源更多地用于处理生产性作业。
Xfce 最新的版本是 “4.12”.
Kali Linux 2019.1 以及该版本之前的一些版本使用的都是 Gnome 桌面环境而不是 Xfce, 因此,本文就从降低系统资源占用的角度出发,介绍一下将 Kali 的桌面环境从 Gnome 更换到 Xfce 4 的过程。
在安装的过程中(可能)会要求我们选择提供图形化系统登录界面的图形管理程序(A display manage is a program that provides graphical login for the X Windows System.),只有一个显示管理器可以管理给定的 X server (X server 是用于管理图形化界面的服务器端程序),但是如果当前系统中安装了多个显示管理器包,就需要选择一个默认的显示管理器(Only one display manage can manage a given X server, but multiple display manager packages are installed. Please select which display manager should run by default.),这里我选择的默认显示管理器是 “gdm3”, 如图 1:
切换桌面:
update-alternatives --config x-session-manager
回显如下:
root@kali:~# update-alternatives --config x-session-manager
There are 3 choices for the alternative x-session-manager (providing /usr/bin/x-session-manager).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gnome-session 50 auto mode
1 /usr/bin/gnome-session 50 manual mode
2 /usr/bin/startxfce4 50 manual mode
3 /usr/bin/xfce4-session 40 manual mode
Press <enter> to keep the current choice[*], or type selection number:
输入 3 以启动 Xfce4,回显如下:
root@kali:~# update-alternatives --config x-session-manager
There are 3 choices for the alternative x-session-manager (providing /usr/bin/x-session-manager).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gnome-session 50 auto mode
1 /usr/bin/gnome-session 50 manual mode
2 /usr/bin/startxfce4 50 manual mode
3 /usr/bin/xfce4-session 40 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/xfce4-session to provide /usr/bin/x-session-manager (x-session-manager) in manual mode
卸载 Gnome 桌面环境:
apt remove gnome-core
apt remove gnome-shell
重启系统:
reboot
重新登录系统之后可以看到已经成功地将 Kali Linux 的桌面环境更换为 Xfce 4,如图 2:
/*
* Number of clock ticks per second. A clock tick is the unit by which
* processor time is measured and is returned by 'clock'.
*/
#define CLOCKS_PER_SEC ((clock_t)1000)
#define CLK_TCK CLOCKS_PER_SEC
Linux 下对于 CLOCKS_PER_SEC 这个常量的定义一般和 Windows 下是不同的.
Linux 下的 C 语言头文件通常都是放在 /usr/include 这个目录下.
(下面, 我将使用”Kali Linux 2019.1″进行本部分接下来的操作.)
在 /usr/include 目录下找到并打开 time.h, 在其中可以看到如下内容:
/* This defines CLOCKS_PER_SEC, which is the number of processor clock
ticks per second, and possibly a number of other constants. */
#include <bits/time.h>
/* ISO/IEC 9899:1999 7.23.1: Components of time
The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
the number per second of the value returned by the `clock' function. */
/* CAE XSH, Issue 4, Version 2: <time.h>
The value of CLOCKS_PER_SEC is required to be 1 million on all
XSI-conformant systems. */
#define CLOCKS_PER_SEC ((__clock_t) 1000000)
由此我们知道, 在该 C 语言编译环境下, CLOCKS_PER_SEC 的值被定义成 1000000.
同样地, 在 Linux 下运行如下程序也可以看到当前编译环境下 CLOCKS_PER_SEC 的数值是多少:
对于记录 IP 地址这个功能, 我们可以使用第三方的网站统计服务来实现. 我们可以申请一个统计代码, 而且只将这个统计代码放在登录页面, 这样就可以记录到所有访问过登录界面的 IP 地址, 根据这些 IP 地址和登陆时间就可以大致判断网站的登录界面是否已经被攻击者掌握. 但是, 使用第三方服务也就意味着我们的后台登录地址将上传到第三方平台的服务器, 从而增大了后台登录地址可能受到攻击的攻击面, 在这里我们通过一段 PHP 代码实现对访问了登录页面的 IP 地址进行记录的功能.
I use ownCloud in Ubuntu and I add one account to it. But whenever I reboot Ubuntu, ownCloud will tell me: “No keychain service available” and I’ll be asked to enter the password once, as show in the figure 1:
Once I enter the password, ownCloud will work properly. But once I restart Ubuntu Linux, that happens again and again. Passwords should be stored, but it didn’t.
Solve the Problem
I found a solution on Github through Bing and that link is HERE. It seems that I am not the only one who has encountered this problem.
The solution is very simple, installing:
sudo apt install libgnome-keyring0
Then, reboot Ubuntu Linux, after you log in to the system, you will be asked to enter a password once, only once, whether you restart Ubuntu or not, you will not be asked to enter ownCloud’s password again unless you exit ownCloud account.
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int sum=0;
int sum2=0;
for(int i=1;i<=100;i++){
sum=sum+i;
sum2=sum2+sum;
}
cout<<sum2<<endl;
return 0;
}