尝试system-config-users从命令行启动时,我收到以下警告,并且该工具未打开。我正在使用 CentOS 7 和 Mate 1.8.1。
警告**:枚举操作时出错:GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: 名称 org.freedesktop.PolicyKit1 未由任何 .service 文件提供
错误检查授权 org.freedesktop.policykit.exec: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: 名称 org.freedesktop.PolicyKit1 未由任何 .service 文件提供
yum 列表 polkit*
Installed Packages
polkit.x86_64 0.112-5.el7 @anaconda
polkit-devel.x86_64 0.112-5.el7 @base
polkit-docs.noarch 0.112-5.el7 @base
polkit-gnome.x86_64 0.105-6.el7 @epel
polkit-pkla-compat.x86_64 0.1-4.el7 @anaconda
Run Code Online (Sandbox Code Playgroud)
我的系统缺少什么导致此错误?
使用这篇有用的帖子,我可以在文件夹中设置默认组和文件权限。
我在设置默认所有者 (teamlead uid 1234) 时遇到问题。
setfacl -d -m g::rwx /my/test/folder
setfacl -d -m o::rx /my/test/folder
getfacl /my/test/folder
# file: /my/test/folder
# owner: teamlead
# group: web_prod
# flags: -s-
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x
Run Code Online (Sandbox Code Playgroud)
接着就,随即:
[mary@boxen]# touch /my/test/folder/somefile
[mary@boxen]# ll /my/test/folder/somefile
-rw-rw-r--. 1 mary web_prod 0 Nov 6 08:58 somefile
Run Code Online (Sandbox Code Playgroud)
因此分配了正确的组,但新文件拥有创建文件的用户的所有权。我希望新创建的文件具有 teamlead:web_prod 所有者/组。
似乎setfacl也可以用来设置默认用户。使用现有文件夹 acl config(上图):
[mary@boxen]# setfacl -d -m u:1234:rwx /my/test/folder
Run Code Online (Sandbox Code Playgroud)
现在以不同的用户身份创建一个文件。我希望它拥有 teamlead:web_prod 所有权。
[mary@boxen]# touch /my/test/folder/anotherfile
[mary@boxen]# ll /my/test/folder/anotherfile
-rw-rw-r--+ 1 mary …Run Code Online (Sandbox Code Playgroud) 我刚刚为 freetds 创建了一个空白的 conf 文件,并注意到权限错误:
[root@box etc]# touch freetds.conf.new
[root@box etc]# ll -lZ freetds.conf*
-rw-r--r--. root root system_u:object_r:etc_t:s0 freetds.conf
-rw-rw----. root root unconfined_u:object_r:etc_t:s0 freetds.conf.new
Run Code Online (Sandbox Code Playgroud)
所以我试过:
[root@box]# semanage fcontext -a -t system_u /etc/freetds.conf.new
Run Code Online (Sandbox Code Playgroud)
但这失败了:
ValueError: Type system_u is invalid, must be a file or device type
Run Code Online (Sandbox Code Playgroud)
我应该使用什么unconfined_u来system_u将文件 freetds.conf.new 上的标签从 更改为?
这个问题/答案有一些很好的解决方案来删除文件中的相同行,但在我的情况下不起作用,因为否则重复的行有一个时间戳。
是否可以告诉 awk 在确定重复项时忽略一行的前 26 个字符?
例子:
[Fri Oct 31 20:27:05 2014] The Brown Cow Jumped Over The Moon
[Fri Oct 31 20:27:10 2014] The Brown Cow Jumped Over The Moon
[Fri Oct 31 20:27:13 2014] The Brown Cow Jumped Over The Moon
[Fri Oct 31 20:27:16 2014] The Brown Cow Jumped Over The Moon
[Fri Oct 31 20:27:21 2014] The Brown Cow Jumped Over The Moon
[Fri Oct 31 20:27:22 2014] The Brown Cow Jumped Over The …Run Code Online (Sandbox Code Playgroud) 我已经更新了 login.defs 和 password-auth 以包含密码的最小长度 (12),但是当我尝试使用passwd.
没有强制执行任何密码大小写策略。我可以输入“aaaa1234”作为有效但弱且太短的密码。我还可以输入字典单词,例如“密码”。可以重复使用相同的密码。
总之,/etc/pam.d/password-auth似乎无法识别中的任何设置。
我为以下命令输入的密码是 blue1234
# passwd testy
Changing password for user testy.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
Run Code Online (Sandbox Code Playgroud)
这是/var/log/secure从上面的操作中登录的内容。这是活动的唯一线路。
Apr 1 11:41:37 myserver passwd: pam_unix(passwd:chauthtok): password changed for testy
Run Code Online (Sandbox Code Playgroud)
配置文件
# login.defs
# Password aging controls:
#
# PASS_MAX_DAYS Maximum number of days a password may be used.
# …Run Code Online (Sandbox Code Playgroud) 我发现调用 mail 命令导致脚本无错误挂起。要关闭脚本,我必须按 ctrl-c 或对进程 ID 发出 kill 命令。
脚本的相关部分如下:
EMAIL_TO="my@email.com"
if [ -f /www/archives/pdf/pdf_201207021048.tar ]; then
echo "file exists"
else
echo "file does not exist"
fi
echo "sending mail next..."
mail -s "pdfbackup" "$EMAIL_TO"
echo "mail sent?"
Run Code Online (Sandbox Code Playgroud)
运行此程序时,我看到文本“下一个发送邮件...”,仅此而已。它永远不会返回到提示。
我可以看到脚本仍然在内存中 ps -ax | grep myscript.sh。
我试过在主题和电子邮件周围使用引号,但又一次没有。无论哪种方式都会产生相同的结果。
我究竟做错了什么?
我将如何搜索特定长度之间的歌曲的 mp3 文件目录。前任:
findmp3 -min=03:00 -max=03:15 /music/mp3/ebm/
Run Code Online (Sandbox Code Playgroud)
将返回emb/目录中歌曲长度在 3:00 到 3:15 分钟之间的所有 mp3 文件。
我使用 Linux Mint、Ubuntu 和 CentOS。
我正在整理一个简单的备份脚本,该脚本将压缩文件夹的内容,然后将该文件移动到备份服务器。该脚本确保 tar 文件存在并且在移动之前不是零字节。
问题是脚本在其中一条 IF 行上死掉了
if [ -f /www/archives/pdf/pdf_201207021048.tar && 11294720 -gt 0 ]; then
echo "tar file exists and is greater than 0 bytes."
else
echo "tar file does not exist or is zero bytes"
fi
Run Code Online (Sandbox Code Playgroud)
控制台中的错误是:
./backup_pdf.sh: line 49: [: missing `]'
Run Code Online (Sandbox Code Playgroud)
第 49 行是上面的 if 语句。
该脚本已成功验证
sh -n backup.sh
Run Code Online (Sandbox Code Playgroud)
sh看到丢失的“]”有什么问题,但它通过了语法检查?
是否有独立或在 vi 或类似(可以是 gui)中的命令可以显示字符串的数字序列?
输入:猫跳进了一个盒子里。
输出:
T h e c a t h o p p e d i n a b o x .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Run Code Online (Sandbox Code Playgroud) 我试图遍历一个字符串数组,并对其中一个值做一些不同的事情。字符串比较在每个元素上都失败。
arr[0]='red'
arr[1]='blue'
arr[2]='yellow'
arr[3]='green'
## now loop through the above array
for i in "${arr[@]}"
do
if [ "$i"="green" ];
then
echo "i('$i') is equal to green"
else
echo "i('$i') is not equal to green"
fi
done
Run Code Online (Sandbox Code Playgroud)
我也试过(结果相同):
if [ "$i"='green' ];
Run Code Online (Sandbox Code Playgroud)
和
if [ $i='green' ];
Run Code Online (Sandbox Code Playgroud)
和
if [ $i="green" ];
Run Code Online (Sandbox Code Playgroud)
以上各项的输出:
i('red') is equal to green
i('blue') is equal to green
i('yellow') is equal to green
i('green') is equal to green
Run Code Online (Sandbox Code Playgroud)
我在比较时做错了什么?
我们刚刚将服务器从 CentOS 6 更新到 RHEL 7,在从 ppd 设置 HP LaserJet 600 后,我注意到所有打印作业现在在页面顶部都有大约 2 英寸的边距。
是否可以在配置文件中定义边距? 这个回复表明可以使用 lpr 的一些参数来设置边距,但我宁愿将它们存储在 conf 文件中。
using lp:
-o page-bottom=N
-o page-left=N
-o page-right=N
-o page-top=N
Sets the page margins when printing text files.
The values are in points - there are 72 points to the inch.
Run Code Online (Sandbox Code Playgroud) 我正在设置rsync将文件从 ServerA 传输到 ServerB,并且需要保留时间戳和权限。他们在这里的关键是文件由与执行文件传输的帐户不同的帐户拥有。
rsync 使用以下示例传输文件:
rsync -a /colorschemes/ acoder@bu.my.box.net:/colorschemes/ --delete
Run Code Online (Sandbox Code Playgroud)
该-a标志产生以下类型的错误:
rsync: failed to set times on "/colorschemes/946/ex": Operation not permitted (1)
rsync: failed to set permissions on "/colorschemes/946/ex/blue.pdf": Operation not permitted (1)
Run Code Online (Sandbox Code Playgroud)
在远程系统上,当尝试手动设置文件权限时,acoder 帐户有类似的错误:
[acoder@bu ~]$ chown apache:codingteam /colorschemes/946
chown: changing ownership of ‘/colorschemes/946’: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
不过,这可以正常工作:
[acoder@bu ~]$ sudo chown apache:codingteam /colorschemes/946
Run Code Online (Sandbox Code Playgroud)
有没有办法让远程 rsync 使用 sudo?