root

How can I use 'do I have root access?' as a conditional in bash?

感情迁移 提交于 2020-01-17 03:59:30
问题 I am writing an installation script, and would like it to install in a local directory if the user does not have root access. specifically, I am looking for the code that goes between the carats ( <> ) if [[<do I have root access? = TRUE>]]; then .. install .. else .. install in $HOME/mylib .. fi 回答1: For bash, you can use the EUID variable: if [ "$EUID" == 0 ] ; then ..something.. else ..something else fi For a POSIX-compliant solution, use: if [ "`id -u`" == 0 ] ; then Although be aware

LeetCode 725. 分隔链表

て烟熏妆下的殇ゞ 提交于 2020-01-17 02:32:12
给定一个头结点为 root 的链表, 编写一个函数以将链表分隔为 k 个连续的部分。 每部分的长度应该尽可能的相等: 任意两部分的长度差距不能超过 1,也就是说可能有些部分为 null。 这k个部分应该按照在链表中出现的顺序进行输出,并且排在前面的部分的长度应该大于或等于后面的长度。 返回一个符合上述规则的链表的列表。 举例: 1->2->3->4, k = 5 // 5 结果 [ [1], [2], [3], [4], null ] 示例 1: 输入: root = [1, 2, 3], k = 5 输出: [[1],[2],[3],[],[]] 解释: 输入输出各部分都应该是链表,而不是数组。 例如, 输入的结点 root 的 val= 1, root.next.val = 2, \root.next.next.val = 3, 且 root.next.next.next = null。 第一个输出 output[0] 是 output[0].val = 1, output[0].next = null。 最后一个元素 output[4] 为 null, 它代表了最后一个部分为空链表。 示例 2: 输入: root = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k = 3 输出: [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]

docker-以root用户进入容器

▼魔方 西西 提交于 2020-01-17 01:52:51
docker-以root用户进入容器 问题描述 有些时候,进入到容器内部不能进行对文件及文件夹的访问,修改和删除,如在搭建 jenkins 容器的时候,想在容器内部增加文件夹,但是往往系统告知 Permission Denied 解决方案 # exec方式在退出的时候不会将容器服务关闭 docker exec -it --user root container_id /bin/bash 来源: CSDN 作者: iiaythi 链接: https://blog.csdn.net/u013887008/article/details/104010669

logging 模块

僤鯓⒐⒋嵵緔 提交于 2020-01-16 23:36:36
日志模块 为什么要写日志 一个卡务系统 : 记录时间 地点 金额 谁在什么时候 删掉了某一个用户 某时某刻登录了系统 检测代码是不是像我们想像的这样执行的 写文件 ,输出到屏幕 f.write,print 时间格式,级别控制,更加便捷 *** logging模块不能自动生成你需要的日志 logging模块的使用 简单配置法 *** 编码问题 logger对象法 ***** 简单配置: # 默认情况下 不打印warning以下级别的信息 默认的日志格式为日志级别:Logger名称:用户输出消息。 import logging logging.debug('debug message') # 调试 logging.info('info message') # 普通信息 logging.warning('warning message') # 警告 logging.error('error message') # 错误信息 logging.critical('critical message')# 严重错误 #WARNING:root:warning message #ERROR:root:error message #CRITICAL:root:critical message import logging logging.basicConfig(level=logging.DEBUG

Attempting to link to root directory on home computer

被刻印的时光 ゝ 提交于 2020-01-16 20:36:30
问题 I'm attempting to build a website on my computer and I'm having issues linking with my root directory from anywhere on the website. I know I can use ../ to go up 1 directory as many times as needed, but I need a way to link to my root directory without using the whole address so I can use "absolute links" to use in my PHP pages which I want to use all over my site for ease of editing. I've been told that / will take me back to the root, but it isn't working on my computer. Here is the address

将下载下来的rpm包生成自己的yum源

落花浮王杯 提交于 2020-01-16 18:29:27
由于服务器的网络并不是都与外网通,所以需要将外网传过来的包存到本地,搭建一个本地yum源,供其他机器使用 1.开启包缓存 sed -i 's/keepcache=0/keepcache=1y/g' /etc/yum.conf 2.安装createrepo软件包 yum install createrepo 3.将安装包移动到某个位置 mv /var/cache/yum/x86_64/6/*/packages/* /root/yum/ 4.创建yum源xml mkdir -p /root/yum/repodata/ touch /root/yum/repodata/myyum.xml createrepo -g /root/yum/repodata/myyum.xml /root/yum/ 5.编辑yum源配置 cd /etc/yum.repos.d vi test.repo [test] name=base baseurl=file:///root/yum enabled=1 gpgcheck=0 可以使用ftp共享 baseurl=ftp://192 . 168 . 0 . 6/pub/Server 6.测试 yum repolist 7 以后若有新增的包 重做第3-4部就可以了 来源: CSDN 作者: sailooor 链接: https://blog.csdn.net

使用nginx作为http/https正向代理

喜夏-厌秋 提交于 2020-01-16 18:14:30
默认nginx是不支持https的正向代理的,要想通过nginx的正向代理,作为https服务器,需要增加一个模块并重新编译nginx。 环境: centos 7 所需要的文件: https://github.com/chobits/ngx_http_proxy_connect_module http://nginx.org/packages/centos/7/SRPMS/nginx-1.12.2-1.el7_4.ngx.src.rpm 安装编译工具 yum install gcc gcc-c++ make -y yum install rpm-build rpmdevtools -y 安装依赖 yum install pcre-devel pcre -y yum install zlib-devel zlib -y yum install openssl-devel openssl -y yum install redhat-lsb-core -y 下载nginx源码、模块源码及rpm构建包 cd /root # 用于支持https代理的模块 git clone https://github.com/chobits/ngx_http_proxy_connect_module.git # rpm构建及nginx源码 wget http://nginx.org/packages

docker部署数据库

ε祈祈猫儿з 提交于 2020-01-16 15:15:40
   搜索数据库镜像images     docker search mysql   搜索结果如下图所示:      选择合适自己的mysql版本   因为mysql新版本出来了,很多特性没有学习,所以笔者安装了mysql:5.6 这个版本比较友好   使用docker pull进行下载 docker pull mysql:5.6   等待下载完成之后,使用 docker run 进行部署 docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name mysql mysql:5.6   参数解析:     -d : 表示后台运行     -p : 表示端口映射 服务器端口:docker 内部mysql暴露的端口 即 你想自定义的端口号:3306     -e : 环境变量或者参数设置 这里设置的是mysql 的root密码     --name : 此容器的名字 可以通过 docker ps -a 进行查看 对容器的操作可以通过容器id 也可以通过容器名     mysql:5.6 指的是使用那一个镜像(image) 进行部署   如此mysql就部署成功了   进入容器,使用mysql,使用docker exec进入容器内部 docker exec -it mysql /bin/bash   参数解析:     -it

Powershell: Saving file to root

僤鯓⒐⒋嵵緔 提交于 2020-01-16 11:49:13
问题 I'm running a powershell file which are going to gather information an save it to an XML-file. This script will run on several computers, and so I want to save them all to a rootpath. The question is, how do I save an XML-file to root on a computer? To specify: The script will always run on a local computer, hence I need to save the xml file to a local path.. 回答1: Basicly the path to save on a root is: \\servername\c$\myfile.xml This is the path to save in the c:\ root folder of a remote

Powershell: Saving file to root

拟墨画扇 提交于 2020-01-16 11:48:59
问题 I'm running a powershell file which are going to gather information an save it to an XML-file. This script will run on several computers, and so I want to save them all to a rootpath. The question is, how do I save an XML-file to root on a computer? To specify: The script will always run on a local computer, hence I need to save the xml file to a local path.. 回答1: Basicly the path to save on a root is: \\servername\c$\myfile.xml This is the path to save in the c:\ root folder of a remote