惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

趣味问题 | 酷 壳 - CoolShell

Cuckoo Filter:设计与实现 | 酷 壳 - CoolShell 谜题的答案和活动的心得体会 | 酷 壳 - CoolShell 【活动】解迷题送礼物 | 酷 壳 - CoolShell 如何用最有创造力的方式输出42 | 酷 壳 - CoolShell 一个“蝇量级” C 语言协程库 | 酷 壳 - CoolShell 伙伴分配器的一个极简实现 | 酷 壳 - CoolShell 一个fork的面试题 | 酷 壳 - CoolShell 神奇的CSS形状 | 酷 壳 - CoolShell 软件真的好难做啊 | 酷 壳 - CoolShell 面试题:火车运煤问题 | 酷 壳 - CoolShell 又一个有趣的面试题 | 酷 壳 - CoolShell “火柴棍式”程序员面试题 | 酷 壳 - CoolShell 打印质数的各种算法 | 酷 壳 - CoolShell 140个Google的面试题 | 酷 壳 - CoolShell
chmod -x chmod的N种解法 | 酷 壳 - CoolShell
陈皓 · 2010-10-13 · via 趣味问题 | 酷 壳 - CoolShell

在SlidesShare.net上有这么一个幻灯片,其说了如下的一个面试题:

如果某天你的Unix/Linux系统上的chomd命令被某人去掉了x属性(执行属性),
那么,你如何恢复呢?

下面是一些答案:

1)重新安装。对于Debian的系统:

sudo apt-get install --reinstall coreutils

2)使用语言级的chmod

  • Perl:perl-e ‘chmod 0755, “/bin/chmod”‘
  • Python:python -c “import os;os.chmod(‘/bin/chmod’, 0755)”
  • Node.js:require(“fs”).chmodSync(“/bin/chmod”, 0755);
  • C程序:
#include <sys/types.h>
#include<sys/stat.h>
void main()
{
chmod("/bin/chmod", 0000755);
}

3)使用已有的可执行文件。

$cat - > chmod.c
void main(){}
^D

$cc chmod.c
$cat /bin/chmod > a.out
$./a.out 0755 /bin/chmod
$cp true > new_chmod
$cat /bin/chmod > new_chmod
$./new_chmod 0755 /bin/chmod

4)使用GNU tar命令

$tar --mode 0755 -cf chmod.tar /bin/chmod
$tar xvf chmod.tar

tar --mode 755 -cvf - chmod | tar -xvf -

5)使用cpio (第19到24字节为file mode – http://4bxf.sl.pt

echo chmod |
cpio -o |
perl -pe 's/^(.{21}).../${1}755/' |
cpio -i -u

6)使用hardcore

alias chmod='/lib/ld-2.11.1.so ./chmod'

7)使用Emacs

Ctrl+x b > * scratch*
(set-file-modes “/bin/chmod” (string-to-number “0755” 8))
Ctrl+j

嗯,挺强大的,不过为什么不用install命令呢?

install -m 755 /bin/chmod /tmp/chmod
mv /tmp/chmod /bin/chmod

各位,你的方法呢?

(全文完)

Loading...