C语言实现计算双基回文数详解

作者:荒原之梦

双基回文数的定义:

如果一个正整数n至少在两个不同的进位制(二进制<=进制=<十进制)b1和b2下都是回文数,则称n是双基回文数。
根据定义,简单的说就是在二进制到十进制之间(包括十进制和二进制),如果n在这其中任意两个进制上是回文数,则n就是双基回文数。

程序功能:

输入正整数S<10^6,输出比S大的最小双基回文数

源代码及注释:

#include<stdio.h>

//把主函数放前面比较好看
int main()
{
int n;
//定义n作为sjHuiWen函数中形式参数s的实际参数
int count=0; //count用于计数,初始值为0
printf("Enter a number:");

scanf("%d",&n);
//读取要处理的数字 ,如2200,该数字不一定为回文数,因为我们想要求的只是比该数字大的最小回文数
int a=n;//使用a先把n的值保存一下

bool sjHuiWen(int m,int base); //定义base代表进制
//下面会调用sjHuiWen函数,调用之前要先声明一下

while(count!=2)
{
n++;
count=0;
for(int base=2;base<=10;base++)
{
if(sjHuiWen(n,base))
//if判断只会在括号内为true时才会执行下一步操作,如果sjHuiWen函数返回true,则表示n是回文数
{
count++; //n是回文数则+1
}
if(count==2) break;
//调用sjHuiWen函数判断n是不是回文数,如果在两个进制下都是回文数,则跳出循环

}
}
printf("比%d大的最小双基回文数为:%d\n",a,n);

return 0;
}

//定义sjHuiWen函数 ,功能是判断数字n在进制base下是不是回文数
bool sjHuiWen(int m,int base)//m是形式参数,n是实际参数
//定义一个函数sjHuiWen,函数类型为布尔类型(由于return返回的值flag是布尔类型,所以函数就是布尔类型)
{
int str[10],i = 0; //定义一个数组str,长度为40
bool flag = true; //定义一个布尔类型的变量flag,赋初值为true
while(m) //m是一个整型变量,当m还是一个整型变量时就继续循环,直到m不是一个整型变量
{
str[i++] = m%base;//取余,从m的个位开始将每一位上的数字变成base位进制并依次存入数组
m /= base; //每取一次余数,就把最后一位的数字去掉
}

for(int j = 0;j <= i/2;j++)
{
if(str[j] != str[i-j-1]){
flag = false;
}else
return true;
}
return flag;
}

运行截图:

图 1

天使的圣光

作者:荒原之梦

你是一道天使的圣光
是柔软的晨雾
飘洒在我眼中的北方

在无限的时光中
拥抱唯一的你
当爱成为信仰
天使便降临了人间

阳光带来了你的气息
你的一次回眸
犹如纸上轻盈的一撇
沉醉了笔墨纸砚的洋溢

人生是一步又一步的前行
我们手挽着手
在同一个时钟频率中漫步
每一缕霞光
都宣誓着
一份庄严的承诺

你说冬天很冷
草地都盖上了厚厚的树叶
我说北风很大
可是有陪伴就不会孤单

下一个春天
在柳叶微拂的湖边
你静静的站在桥头
湖水的波光在你的脸庞荡漾
那时
整个世界
都在为你盛开

Windows Server 2008取消登录前的Ctrl+Alt+Delete组合键操作

作者:荒原之梦

前言:

在Windows Server 2008服务器中,为了防止人们登录服务器时错误的将账户和密码输入其他地方导致信息泄漏,所以在我们登录Windows Server 2008服务器操作系统时会要求我们按“Ctrl+Alt+Delete”组合键才能打开登录界面。这样确实能减少人为失误造成信息泄漏的可能性,但是我在使用网页版远程登录连接我的Windows服务器时发现,一旦我按下了“Ctrl+Alt+Delete”组合键,就会被我的本地计算捕获这一操作指令,而远程服务器却没有反应。综上,同时也为了方便登陆(我的这台Windows服务器纯属个人使用,服务器中没有重要信息,因此可以为了方便使用牺牲一些安全性,如果是公司服务器等对安全性要求比较高的服务器还是要以确保安全为主。)

 

具体操作步骤:

1. Win+R组合键输入gpedit.msc,回车运行,打开“本地组策略编辑器”。

2 .依次打开“计算机配置->Windows设置->安全设置->本地策略->安全选项”

3 .点击“安全选项”,选中右侧窗口中的“交互式登录:无须按Ctrl+Alt+Del”,右键点击“属性”,将“已禁用”改为“已启用”。

4 .点击“应用”和“确定”,之后重启服务器。

5 .重启完成后再次使用Web方式登录服务器就直接进入到了登陆界面,不再需要按Ctrl+Alt+Delete组合键进入登陆界面。

 

注:

更改本地组策略后一定要记得重启服务器。经实际测试,一般情况下,不重启不会更新上述更改,因此更改也不会生效。

Kali Linux远程连接Windows服务器

作者:荒原之梦

前言:

为了在Kali上远程连接Windows系统的服务器我们需要安装两个工具,rdesktop和tsclient。另外,我们从主机服务商那里购买的Windows操作系统的服务器都是默认开启了远程连接的,如果我们要在局域网里连接桌面版的Windows系统一般还需要开启并配置好远程桌面。

操作步骤:

安装rdesktop,输入命令:

apt-get install rdesktop

安装tsclient,输入命令:

apt-get install tsclient

输入:

rdesktop ip:端口号

或者输入:

rdesktop ip

即可打开Windows服务器的登录页面,默认的登录用户名是“root”,可以根据实际情况修改。

命令“rdesktop”后面可以跟的几个常用参数及功能如下:

-f //全屏显示(想退出全屏则使用组合键“Ctrl+Alt+Enter”)。
-a [x] //指定显示的颜色深度。 
/*注:一般可以在网速不够好的情况下可以指定为“-a 8”(此时显示效果基本为黑白蓝),网速较好时指定为“-a 16”(此时的显示效果是彩色的),默认的颜色深度是24(“默认的颜色深度是24”属于推测,因为,我在不指定颜色深度的情况下,即不使用“-a [x]”参数时连接Windows Server 2003服务器时会产生警示:“WARNING: Remote desktop does not support colour depth 24; falling back to 16”)*/
-g [x*x] //指定远程桌面在本地显示窗口的大小,如“-g 600*800”.
-u name //登录用户的用户名。
-p password //登录密码。
-r sound:local //将远程主机的声音重定向到本地。

注:
1.rdesktop是一个基于命令行的工具,而tsclient则可以提供图形化界面。(在终端输入tsclient会显示“bash: tsclient: command not found”,因此推测tsclient应该只是作为rdesktop的一个扩展插件存在)。
2.上述工具也可以在其他Linux平台上使用,如CentOS和Ubuntu.

附:rdesktop的帮助信息(终端输入“rdesktop”可以查看)

rdesktop: A Remote Desktop Protocol client.
Version 1.8.3. Copyright (C) 1999-2011 Matthew Chapman et al.
See http://www.rdesktop.org/ for more information.

Usage: rdesktop [options] server[:port]
-u: user name
-d: domain
-s: shell / seamless application to start remotly
-c: working directory
-p: password (- to prompt)
-n: client hostname
-k: keyboard layout on server (en-us, de, sv, etc.)
-g: desktop geometry (WxH)
-i: enables smartcard authentication, password is used as pin
-f: full-screen mode
-b: force bitmap updates
-L: local codepage
-A: path to SeamlessRDP shell, this enables SeamlessRDP mode
-B: use BackingStore of X-server (if available)
-e: disable encryption (French TS)
-E: disable encryption from client to server
-m: do not send motion events
-C: use private colour map
-D: hide window manager decorations
-K: keep window manager key bindings
-S: caption button size (single application mode)
-T: window title
-t: disable use of remote ctrl
-N: enable numlock syncronization
-X: embed into another window with a given id.
-a: connection colour depth
-z: enable rdp compression
-x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)
-P: use persistent bitmap caching
-r: enable specified device redirection (this flag can be repeated)
'-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1
or COM1=/dev/ttyS0,COM2=/dev/ttyS1
'-r disk:floppy=/mnt/floppy': enable redirection of /mnt/floppy to 'floppy' share
or 'floppy=/mnt/floppy,cdrom=/mnt/cdrom'
'-r clientname=': Set the client name displayed
for redirected disks
'-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1
or LPT1=/dev/lp0,LPT2=/dev/lp1
'-r printer:mydeskjet': enable printer redirection
or mydeskjet="HP LaserJet IIIP" to enter server driver as well
'-r sound:[local[:driver[:device]]|off|remote]': enable sound redirection
remote would leave sound on server
available drivers for 'local':
alsa: ALSA output driver, default device: default
'-r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]': enable clipboard
redirection.
'PRIMARYCLIPBOARD' looks at both PRIMARY and CLIPBOARD
when sending data to server.
'CLIPBOARD' looks at only CLIPBOARD.
'-r scard[:"Scard Name"="Alias Name[;Vendor Name]"[,...]]
example: -r scard:"eToken PRO 00 00"="AKS ifdh 0"
"eToken PRO 00 00" -> Device in Linux/Unix enviroment
"AKS ifdh 0" -> Device shown in Windows enviroment
example: -r scard:"eToken PRO 00 00"="AKS ifdh 0;AKS"
"eToken PRO 00 00" -> Device in Linux/Unix enviroment
"AKS ifdh 0" -> Device shown in Windows enviroment
"AKS" -> Device vendor name
-0: attach to console
-4: use RDP version 4
-5: use RDP version 5 (default)
-o: name=value: Adds an additional option to rdesktop.
sc-csp-name Specifies the Crypto Service Provider name which
is used to authenticate the user by smartcard
sc-container-name Specifies the container name, this is usally the username
sc-reader-name Smartcard reader name to use
sc-card-name Specifies the card name of the smartcard to use

Kali Linux虚拟机安装完整安装过程及简单配置(视频)

附:视频中出现的两个txt文本,包含了大致的安装与配置过程:

文本1:KaliLinux虚拟机安装和初步配置

Kali Linux虚拟机安装和初步配置

大家好,今天给大家演示一下在VMware Workstation 14 pro里安装
Kali Linux的完整步骤和安装完成后的简单配置,包括添加更新源、配置DNS服务器
和安装中文输入法等

下面是详细步骤:

1.下载VMware
官网下载需要注册并登录才能下载,也可以使用
百度软件中心等站点提供的下载资源

双击安装,使用默认设置就可以了

2.下载qBittorrent(这是一个下载torrent种子的软件)

双击安装,使用默认设置就可以了

3.下载Kali种子
为了尽可能减少下载过程中出错的可能性,我们不
直接在浏览器里下载Kali,我们先下载一个torrent种子
,之后在上面下载安装好的qBittorrent里下载Kali

注意:Kali使用64位的在安装过程中可能出现提示说CPU不支持64位
如果出错我们可以改成使用32位的Kali,也就是i386

Kali主要是用于做渗透测试,为了保护我们的物理机真实IP不被暴露,
虚拟机Kali要使用桥接模式上网。

4.安装Kali

5.安装VMware Tools
安装好Tool后我们就可以在物理机和虚拟机Kali之间复制文件了

硬盘改大一点,太小的话可能安装不成功

这个硬盘的大小只是Kali可以使用的存储空间的最大值,不会把这些空间立即分配给Kali

6.添加国内更新源

7.Kali配置DNS服务器

8.Kali安装中文输入法

 

文本2:临时记录

我已经提前下载好了,这里就不再演示下载了

和安装其他软件一样,双击打开
之后使用默认设置安装就可以了

安装好之后就是这个样子了
在“我的计算机”这一栏里是我们安装好的虚拟机

现在给大家介绍一个bt种子下载软件,免费的

这是他的官网,百度搜一下就找到了

我已经下载好了,这里就不再演示下载了
下载好后双击打开,使用默认设置安装就可以啦
安装好之后就是这个样子的
点击绿色的+号可以添加bt种子
待会我们去Kali的官网下载一个Kali的BT种子
之后就可以用它下载了。

认准kali的官网是:
kali.org

这就是Kali的下载界面,前两个分别是64位
和32位的,一般我们先选择使用64位的,如果
64位的安装出错,那么在换32位的,在我是用VMware12的时候出现过在64位的CPU上安装64的Kali出错的情况,不过现在VMware已经更新到14了,没有出现过以前的情况了。

这里我们选择下载kali的bt种子的方式下载Kali

bt种子下载好了,下载可以下载kali了

稍等一会就下载好了,速度会越来越快
我已经下载好kali的系统映像了
这里就不再演示下载了

现在开始在VMware上安装Kali。

我们先在非系统盘里创建一个文件夹,将待会Kali的安装文件都放到这个文件夹里

这一步需要指定我问刚才下载的KALI系统映像文件的路径,该文件是以.iso结尾的。

Kali是Debian的发行版,我们这里选择系统的版本为Debian

把安装位置改成我们刚才新建的文件夹,这样方便管理

把鼠标放到Kali的屏幕上点击一下鼠标就进到虚拟机里了,使用Ctrl+Alt组合键可以再把鼠标返回到物理机

使用倒数第3个选项就可以图形化安装Kali

这里设置root用户的密码
kali是一个单用户操作系统,只有一个管理员(root)账户

这里需要安装一会时间
我先暂停一下

好了,欢迎回来!

安装即将结束

再等一会………………
再等一会………………

开机啦!!!

待会输入用户名:root
密码就是刚才设置的root密码:*****
现在Kali和物理机是相互隔离的
没法互相复制文件
我们试试看

真的拖不进来

现在我们安装VMware Tools
安装好之后就可以互相复制文件了

全部使用回车,使用默认设置

待会我们要给系统做一个快照,这样一旦我们今后做什么事把系统弄坏了,还可以回到现在这个初始状态

VMware现在安装好了
可以复制文件了,我们试试看吧

没复制上…………

我们重启看看…………

我先暂停一下………………

欢迎回来
刚才我重启启动了Kali
现在真的可以复制了
我们试一下吧

好了
下一步我们要添加Kali的国内更新源,这样以后下载工具时会快一点

对了,先拍个快照

我的博客上记录有最新的国内镜像网站,我们打开看一下

更新源添加好了,但是我们现在没办法在Kali里输入中文

下载我们就来安装中文输入法

在安装中文输入法之前我们先来配置一下DNS服务器,这样就可以上网了

如果不项配置也可以在VMware的设置里面将联网模式改成NAT模式

NAT模式使用的物理机的IP,可以直接上网。
下面配置DNS服务器
使用的是阿里云的公共DNS服务器;
223.5.5.5
223.6.6.6

现在开始安装中文输入法

下面我们去搜狗官网下载Linux版的搜狗输入法

出现软件包依赖问题
可以使用
apt-get install -f
解决依赖问题

现在重启一下

现在可以输入中文啦

谢谢收看

Kali Linux中下载工具Axel的安装和使用

前言:

Axel是一个多线程的HTTP/FTP下载工具,支持断点续传。

Axel的安装

apt-get install axel

Axel的卸载

apt remove axel

安装完成之后输入

axel

回车就会显示Axel的帮助页面,Axel 2.15-1版本的帮助页面原文如下:

root@kali:~# axel
Usage: axel [options] url1 [url2] [url...]

--max-speed=x       -s x    Specify maximum speed (bytes per second)
--num-connections=x -n x    Specify maximum number of connections
--max-redirect=x        Specify maximum number of redirections
--output=f      -o f    Specify local output file
--search[=n]        -S[n]   Search for mirrors and download from n servers
--ipv4          -4  Use the IPv4 protocol
--ipv6          -6  Use the IPv6 protocol
--header=x      -H x    Add HTTP header string
--user-agent=x      -U x    Set user agent
--no-proxy      -N  Just don't use any proxy server
--insecure      -k  Don't verify the SSL certificate
--no-clobber        -c  Skip download if file already exists
--quiet         -q  Leave stdout alone
--verbose       -v  More status information
--alternate     -a  Alternate progress indicator
--help          -h  This information
--timeout=x     -T x    Set I/O and connection timeout
--version       -V  Version information

Visit https://github.com/axel-download-accelerator/axel/issues to report bugs

Axel的用法如下:

命令格式:

axel [选项和参数] [下载链接1] [下载链接2] [下载链接3]

常用的选项及功能描述如下:

-a 显示进度条
-s [x] 指定每秒下载速度的最大比特数,“x”一般设置成200000以上(单位是“字节/秒”)
-n [x] 指定同时打开的线程数,“x”一般设置成10以上
-S [x] 搜索镜像并从X servers服务器下载
-o f 指定本地的输出文件(即指定本地的另存为目录)
-N 不使用代理服务器
-v 显示更多状态信息

注:

1.上述选项后面的“[x]”中的x代表数字,为该选项的参数。
2.如果不指定“本地保存目录”,则下载的文件会保存在执行下载命令时所在的目录(即当前目录)。
3.Axel支持断点续传,如果下载过程中断,可以再次执行原下载命令,即可从上次下载的进度处开始继续下载。
4.Axel可以从多个地址下载同一个文件。

2017年Kali Linux更新源

终端输入:

leafpad /etc/apt/sources.list

打开更新源配置文件,将下面的更新源复制到原内容的前面:

#163网易 Kali源
deb http://mirrors.163.com/debian wheezy main non-free contrib 
deb-src http://mirrors.163.com/debian wheezy main non-free contrib 
deb http://mirrors.163.com/debian wheezy-proposed-updates main non-free contrib 
deb-src http://mirrors.163.com/debian wheezy-proposed-updates main non-free contrib 
deb-src http://mirrors.163.com/debian-security wheezy/updates main non-free contrib 
deb http://mirrors.163.com/debian-security wheezy/updates main non-free contrib

#阿里云 Kali源
deb http://mirrors.aliyun.com/kali kali main non-free contrib
deb-src http://mirrors.aliyun.com/kali kali main non-free contrib
deb http://mirrors.aliyun.com/kali-security kali/updates main contrib non-free

#中科大 Kali源
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib

#浙江大学 Kali源
deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free

#东软大学 Kali源
deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib

#重庆大学 Kali源
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib

#官方Kali源
#deb http://http.kali.org/kali kali-rolling main non-free contrib
#deb-src http://http.kali.org/kali kali-rolling main non-free contrib

最后保存并退出.

解决VMware虚拟机报错“无法连接MKS:套接字连接尝试次数太多,正在放弃”

1.错误描述

在VMware中打开虚拟机时报错:
“无法连接MKS:套接字连接尝试次数太多,正在放弃”
物理机操作系统:
Windows 7
虚拟机操作系统:
Kali Linux

2.解决办法如下

a.关闭出问题的虚拟机

b.依次打开:

“我的电脑”->“管理”->“服务和应用程序”->“服务”

c.右键启动以下服务:

VMware Authorization Service
VMware DHCP Service
VMware NAT Service
VMware USB Arbitration Service
VMware Workstation Server

开启原来出问题的虚拟机,可以正常启动,问题解决。

解决C语言程序报错:return type defaults to‘int’

下面是通过自定义一个函数printN,之后在main函数中调用printN,使得可以通过输入整数N,将从1到N的全部整数都打印出来的程序。
但是在编译过程中却报错:

return type defaults to ‘int’

产生报错的原因:

printN的默认返回值类型是int类型的,这样调用printN函数的main函数就需要定义为:

int main()

而不是:

main()

产生报错的程序:

#include<stdio.h>

//自定义printN函数
void printN (int N){
    int i;
    for(i = 1; i <= N; i++){
        printf("%d\n",i);
        }
        return;
    }

//声明printN函数
void printN(int N);

main(void)
{
    int N;
    printf("请输入N:");
    scanf("%d",&N);//传入参数
    printN(N);//调用printN函数
return 0;
    }

改正之后的程序:

#include<stdio.h>

//自定义printN函数
void printN (int N){
    int i;
    for(i = 1; i <= N; i++){
        printf("%d\n",i);
        }
        return;
    }

//声明printN函数
void printN(int N);

int main(void)
{
    int N;
    printf("请输入N:");
    scanf("%d",&N);//传入参数
    printN(N);//调用printN函数
return 0;
    }

解决BackBox中Fcitx输入法中文输入状态下不显示候选词框的问题

当我们安装Fcitx输入法时默认是安装了下面这个组件的:

fcitx-module-kimpanel

该组件在非KDE桌面环境下可能会使Fcitx输入法在输入中文时无法显示候选词框。

使用下面的命令移除该组件后重启操作系统即可:

sudo apt-get remove fcitx-module-kimpanel

注:该方法同样适用于尝试解决在Ubuntu上遇到的类似问题。

2017年BackBox5和Ubuntu16.04.1更新源

BackBox是基于Ubuntu的Linux发行版,因此,我们可以使用Ubuntu的更新源作为BackBox的更新源。
1.查看系统版本信息:
输入:

uname -a

显示计算机及操作系统的有关信息,在回显里我们可以看到:

Linux master 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:30:51 UTC 2017 i686 i686 i686 GNU/Linux

这表明我们现在使用的Linux内核是Ubuntu

另外我们还可以通过输入命令:

cat /proc/version

查看内核版本,运行回显如下:

Linux version 4.10.0-38-generic (buildd@lgw01-amd64-020) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #42~16.04.1-Ubuntu SMP Tue Oct 10 16:30:51 UTC 2017

输入:

cat /etc/issue

可以查看当前使用的发行版的信息,回显如下:

BackBox Linux 5 \n \l

因此,本文的操作环境为:
BackBox 5(基于Ubuntu16.04.1)

当然,在添加更新源时对版本的要求也不是这么绝对,一般情况下,只要更新源本身还在更新并能通过互联网访问,那么更新源就是可以使用的。

2.BackBox 5自带的更新源
BackBox 5自带的更新源均指向Ubuntu的官网地址,自带的更新源如下:

#deb cdrom:[BackBox Linux 5 - Release i386]/ xenial main multiverse restricted universe

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

3.补充BackBox国内更新源:
输入:

sudo leafpad /etc/apt/sources.list

使用leadpad打开更新源配置文件。
也可以输入:

sudo vi /etc/apt/sources.list

使用vi编辑器打开更新源配置文件
注:不要忘记加上sudo

将以下更新源复制到原更新源的前面保存即可:

#阿里云源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

#网易源
deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse

#中科大源:
deb http://debian.ustc.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ trusty-security main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe

#东北大学源
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse

#清华大学源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

注:更改更新源之前最好先对原有的更新源做一个备份,备份命令:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

附:
Ubuntu中文官网源列表地址

BackBox错误,无法获得锁…资源暂时不可用…无法锁定管理目录

今天准备给BackBox安装leafpad时,输入

sudo apt install leafpad

后出现了如下的错误提示:

E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
E: 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?

出现这种情况一般是由于apt-get进程在后台占用导致的,使用以下命令强制解锁被占用的资源:

sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

之后再安装leafpad,成功安装。

导航狗信息导航网站首页源代码(2017年11月03日版)

导航狗信息导航网址:http://www.daohanggou.wang/

<html>
<style> 
body{ text-align:center} 
.div1{ margin:0 auto; width:1000px; height:100px; border:1px} 
</style> 
<head>
<title>导航狗信息导航-您的一站式信息服务平台</title>
<link rel="icon" href="http://www.daohanggou.wang/huhuyp/web/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="http://www.daohanggou.wang/huhuyp/web/favicon.ico" type="image/x-icon">
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?ac6134fce8960896d0d72e97aeabd2f7";
var s = document.getElementsByTagName("script")[0]; 
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<meta charset="utf-8">
<div class = "div1">
<body bgcolor="#F0E68C">
<a href="http://www.daohanggou.wang/" title="导航狗"><img src="http://wx4.sinaimg.cn/mw690/006CBL8rly1fl2xy5l6jwj306s02q0so.jpg" alt="logo"><a>
<center>
<input name=ie type=hidden value=utf-8>
<form onsubmit="return baiduWithHttps(this)" action="http://www.baidu.com/baidu" target="_blank">
<input name="tn" type="hidden" value="SE_zzsearchcode_shhzc78w">
<input type="text"  onfocus="checkHttps" name="word"  size="30">
<input type="submit"value="百度搜索">
</form>
<script src="http://s1.bdstatic.com/r/www/cache/global/js/BaiduHttps_20150714_zhanzhang.js"></script>
<script>
function checkHttps () {
BaiduHttps.useHttps();    
};
function baiduWithHttps (formname) {
var data = BaiduHttps.useHttps();
if (data.s === 0) {
return true;
}
else {
formname.action = 'https://www.baidu.com/baidu' + '?ssl_s=1&ssl_c' + data.ssl_code;
return true;
}
};
</script>
</center>
<form>
<fieldset>
<legend></legend>
<nav>
<a href=""></a>
</nav>
</fieldset>
</form>
<form>
<fieldset>
<legend><li>英语学习</li></legend>
<nav>
<font size="3">
<a href="http://www.ftchinese.com/channel/ce.html" target="_blank">FT中文网 双语阅读</a>	|
<a href="http://www.ftchinese.com/channel/speedread.html" target="_blank">FT中文网 FT英语速读</a>	|
<a href="http://www.ftchinese.com/channel/ev.html" target="_blank">FT中文网 原声视频</a>	|
<a href="http://www.ftchinese.com/channel/radio.html" target="_blank">FT中文网 FT英语电台</a>	|
<a href="http://www.npr.org/" target="_blank">美国国家公共广播电台</a>	|
<a href="http://edition.cnn.com/" target="_blank">美国有线电视新闻网CNN</a>	|
<a href="http://www.bbc.com/news" target="_blank">BBC新闻</a>	|
<a href="https://www.ted.com/" target="_blank">TED</a>	|
<a href="http://www.iciba.com/" target="_blank">金山词霸</a>	|
<a href="http://fanyi.baidu.com/" target="_blank">百度翻译</a>	|
<a href="http://fanyi.youdao.com/" target="_blank">有道翻译</a>	|
<a href="https://translate.google.cn/" target="_blank">Google翻译</a>	|
<a href="http://dict.cn/" target="_blank">海词词典</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>计算机资源镜像站</li></legend>
<nav>
<font size="3">
<a href="http://mirrors.aliyun.com/" target="_blank">阿里云开源镜像站</a>	|
<a href="http://mirrors.163.com/" target="_blank">网易开源镜像站</a>	|
<a href="http://mirrors.ustc.edu.cn/" target="_blank">中国科学技术大学开源镜像站</a>	|
<a href="https://mirrors.tuna.tsinghua.edu.cn/" target="_blank">清华大学开源软件镜像站</a>	|
<a href="http://ftp.sjtu.edu.cn/" target="_blank">上海交通大学开源镜像站</a>	|
<a href="http://mirrors.zju.edu.cn/" target="_blank">浙江大学开源镜像站</a>	|
<a href="http://mirror.neu.edu.cn/" target="_blank">东北大学开源镜像站</a>	|
<a href="http://www.debian.org/mirror/list" target="_blank">Debian全球镜像站</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>Linux</li></legend>
<nav>
<font size="3">
<a href="https://www.linux.org/" target="_blank">Linux</a>
<a href="https://www.kali.org/" target="_blank">Kali Linux</a>	|
<a href="http://www.kali.org.cn/" target="_blank">Kali Linux中文网</a>	|
<a href="https://www.ubuntu.com/index_kylin" target="_blank">Ubuntu Linux</a>	|
<a href="https://www.centos.org/" target="_blank">CentOS Linux</a>	|
<a href="https://access.redhat.com/" target="_blank">RedHat Linux</a>	|
<a href="http://www.chinaunix.net/" target="_blank">ChinaUnix</a>	|
<a href="http://www.linuxidc.com/" target="_blank">Linux公社</a>	|
<a href="http://linux.vbird.org/" target="_blank">鸟哥的Linux私房菜</a>	|
<a href="https://linux.cn/" target="_blank">Linux中国开源社区</a>	|
<a href="http://www.linuxdiyf.com/" target="_blank">红联Linux</a>	|
<a href="http://www.linuxeden.com/" target="_blank">Linuxeden开源社区</a>	|
<a href="https://www.linuxfoundation.org/" target="_blank">The Linux Foundation</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>计算机程序设计</li></legend>
<nav>
<font size="3">
<a href="https://www.python.org/" target="_blank">Python</a>	|
<a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank">Java SE</a>	|
<a href="http://www.runoob.com/" target="_blank">RUNOOB</a>	|
<a href="http://www.w3school.com.cn/" target="_blank">W3school</a>	|
<a href="https://www.eclipse.org/" target="_blank">Eclipse</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>云计算服务提供商</li></legend>
<nav>
<font size="3">
<a href="https://www.aliyun.com/" target="_blank">阿里云</a>	|
<a href="https://cloud.tencent.com/" target="_blank">腾讯云</a>	|
<a href="https://www.mtyun.com/" target="_blank">美团云</a>	|
<a href="https://cloud.baidu.com/" target="_blank">百度云</a>	|	
<a href="http://www.huaweicloud.com/" target="_blank">华为云</a>	|
<a href="http://www.sinacloud.com/" target="_blank">新浪云</a>	|
<a href="https://www.jcloud.com/index" target="_blank">京东云</a>	|
<a href="https://www.qingcloud.com/" target="_blank">青云</a>	|
<a href="https://www.ucloud.cn/" target="_blank">UCloud</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>资料查询</li></legend>
<nav>
<font size="3">
<a href="https://www.wikipedia.org/" target="_blank">维基百科</a>	|
<a href="https://www.baidu.com/" target="_blank">百度</a>	|
<a href="https://www.bing.com/?intlF=" target="_blank">Bing</a>	|
<a href="https://www.zhihu.com/" target="_blank">知乎</a>	|
<a href="https://www.quora.com/" target="_blank">Quora</a>	|
<a href="http://www.sowang.com/" target="_blank">搜网</a>	|
<a href="https://stackoverflow.com/" target="_blank">StackOverflow</a>	|
<a href="http://www.chongbuluo.com/" target="_blank">虫部落</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>技术参考</li></legend>
<nav>
<font size="3">
<a href="http://www.williamlong.info/" target="_blank">月光博客</a>	|
<a href="http://www.freebuf.com/" target="_blank">FreeBuf</a>	|
<a href="http://www.iplaysoft.com/" target="_blank">异次元软件</a>	|
<a href="https://www.2cto.com/" target="_blank">红黑联盟</a>	|
<a href="http://bobao.360.cn/index/index" target="_blank">安全客</a>	|
<a href="https://technet.microsoft.com/en-us/" target="_blank">Microsoft TechNet</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>IT资讯</li></legend>
<nav>
<font size="3">
<a href="http://www.zol.com.cn/" target="_blank">中关村在线</a>	|
<a href="https://www.pconline.com.cn/" target="_blank">太平洋电脑网</a>	|
<a href="http://www.chinablackhat.com/" target="_blank">黑帽网</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>IT论坛</li></legend>
<nav>
<font size="3">
<a href="https://bbs.pediy.com/" target="_blank">看雪安全论坛</a>	|
<a href="https://www.52pojie.cn/" target="_blank">吾爱破解</a>	|
<a href="http://www.cnhonkerarmy.com/forum.php" target="_blank">红客联盟</a>	|
<a href="https://forum.eviloctal.com/" target="_blank">邪恶八进制社区</a>	|
<a href="http://bbs.chinablackhat.com/" target="_blank">黑帽论坛</a>	|
<a href="http://bbs.it-home.org/" target="_blank">程序员之家论坛</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>代码维护</li></legend>
<nav>
<font size="3">
<a href="https://github.com/" target="_blank">GitHub</a>	|
<a href="https://www.openshift.com/" target="_blank">OpenShift</a>	|
<a href="https://about.gitlab.com/" target="_blank">GitLab</a>	|
<a href="https://gitee.com/" target="_blank">码云</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>站长工具</li></legend>
<nav>
<font size="3">
<a href="http://zhanzhang.baidu.com/" target="_blank">百度站长平台</a>	|
<a href="http://tool.chinaz.com/" target="_blank">站长之家 站长工具</a>	|
<a href="https://thepaperwall.com/" target="_blank">The Paper Wall</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>放松一下</li></legend>
<nav>
<font size="3">
<a href="https://daily.zhihu.com/" target="_blank">知乎日报</a>	|
<a href="http://jandan.net/" target="_blank">煎蛋</a>	|
<a href="http://www.guokr.com/" target="_blank">果壳</a>	|
<a href="http://songshuhui.net/" target="_blank">科学松鼠会</a>	|
<a href="http://www.sfw.com.cn/" target="_blank">科幻世界</a>	|
<a href="https://what-if.xkcd.com/" target="_blank">What If</a>	|
<a href="https://www.bilibili.com/" target="_blank">哔哩哔哩</a>	|
<a href="http://huaban.com/" target="_blank">花瓣网</a>	|
</font>
</nav>
</fieldset>
</form>
<br>
<form>
<fieldset>
<legend><li>音乐电台</li></legend>
<nav>
<font size="3">
<a href="http://music.163.com/" target="_blank">网易云音乐</a>	|
<a href="https://douban.fm/" target="_blank">豆瓣FM</a>	|
<a href="http://www.kugou.com/" target="_blank">酷狗音乐</a>	|
<a href="https://y.qq.com/" target="_blank">QQ音乐</a>	|
<a href="http://www.ximalaya.com/explore/" target="_blank">喜马拉雅FM</a>	|
<a href="http://www.qingting.fm/" target="_blank">蜻蜓FM</a>	|
<a href="http://www.qpgfm.com/#index.php" target="_blank">青苹果音乐台</a>	|
<a href="http://www.lizhi.fm/" target="_blank">荔枝FM</a>	|
</nav>
</fieldset>
</form>
<br>
<div style="width:1000px;border:1px solid black;"></div>
<center>
<style>
.brh{font-size:12px;line-height:1px;}
</style>
<footer>
<br />
<div class=".brh" <span>Copyright &copy 2017.<a href="http://www.daohanggou.wang/">导航狗</a> All Rights Reserved </span><br />
E-mail:dog@daohanggou.wang
</div>
</footer>
</center>
</body>
</div>
</html>

解决WordPress无法上传媒体文件以及无法下载和安装主题与插件的问题

作者:荒原之梦

前言:

我的个人博客网站荒原之梦http://zhaokaifeng.com/在安装成功WordPress
之后本来是可以上传媒体文件,安装主题和插件的,但是后来不知道怎么回事就出了问题:不能上传媒体文件也不能安装主题和插件了。出现这个问题后我尝试了去解决,但是一时没能成功完成,后来博文里的图片都放到图床里了,这个问题也就一直被搁置到了今天(这样做是不对的,遇到问题要及时解决)。今天我决定解决这个问题,上网查资料,大概两个小时后弄好了,现在将解决过程记录下来。

操作环境:

1.网站服务器:Linux云服务器

2.网站程序:WordPress 4.7.5

一 我遇到的问题

使用WordPress上传媒体文件和安装主题及插件的时候均无法成功完成并出现如下错误提示:

1.上传媒体文件时显示“无法创建目录&quot;wp-content/*/*”:

图 1

2.安装主题或者插件时弹出窗口要求输入FTP账号和密码,输入FTP账号相关信息后点击“安装”,之后又显示安装失败,提示的失败原因是“无法创建目录”:

图 2

二 解决步骤如下:

1.    首先用FTP工具连接服务器,在*/wordpress/wp-content目录下将upgrade、themes和plugins都右键设置成766权限,并选中“包含子目录”复选框。

然后我们使用FTP工具在*/wordpress目录中,找到wp-config.php,添加如下代码:

define("FS_METHOD","direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);

添加后保存,再安装插件已经不再提示输入FTP密码,但是仍然安装失败,并显示“安装失败:无法创建文件(如图2一样)”。此时也无法上传媒体文件。

2.    登陆到数据库

找到数据库中的wp_options,查看其对应的upload_path表的键值是不是wp-content/uploads(不要给键值加双引号),如果为空或者不是该值则改成该值。

之后在wordpress仪表盘中找到“设置->多媒体”,将文件上传路径改成wp-content/uploads(不要给路径加双引号),点击“保存更改”。

这时再尝试上传媒体文件已经可以上传了,但是仍然不能安装主题或插件,安装主题或插件时仍然显示“无法创建目录”

3.    使用ssh工具连接到服务器,进入wordpress的上一级路径,输入:

ls -l wordpress

发现wordpress的用户和组都是root.

也就是说不能下载安装主题和插件并不仅仅是因为权限不够(出现无法创建目录的问题人们最直接的反应就是权限不够,但是我尝试过,即使给upgrade、themes和plugins这些文件夹777的权限,仍然无法解决问题,而且还会因为权限过高产生隐患),而是因为执行下载安装主题和插件的用户组是web用户组(名称一般为www)。

所以我们输入:

chown -R www:www wordpress

将wordpress所属的用户和组全部改成www.

至此问题已全部解决,可以上传媒体文件,以及安装主题和插件了。


荒原之梦网全部内容均为原创,提供了涵盖考研数学基础知识、考研数学真题、考研数学练习题和计算机科学等方面,大量精心研发的学习资源。

意见反馈 | 内容纠错 | 微信 | QQ | 公众号 | 知乎 | 微博 | 博客园 |CSDN | B 站 | 电子邮件
豫 ICP 备 17023611 号-1 | 公网安备 - 荒原之梦 豫公网安备 41142502000132 号 | SiteMap
Copyright © 2017-2024 ZhaoKaifeng.com 版权所有 All Rights Reserved.

Copyright © 2024   zhaokaifeng.com   All Rights Reserved.
豫ICP备17023611号-1
 豫公网安备41142502000132号

荒原之梦 自豪地采用WordPress