首页 文章 精选 留言 我的

精选列表

搜索[加密工具],共10000篇文章
优秀的个人博客,低调大师

简介Valgrind工具包功能

我就不班门弄斧了。不过呢,有可能有些同学可能不知道Valgrind有哪些功能,那么我就从Valgrind的官方网站处,摘几段文字吧。 Memcheck Memcheck detects memory-management problems, and is aimed primarily at C and C++ programs. When a program is run under Memcheck's supervision, all reads and writes of memory are checked, and calls to malloc/new/free/delete are intercepted. As a result, Memcheck can detect if your program: Accesses memory it shouldn't (areas not yet allocated, areas that have been freed, areas past the end of heap blocks, inaccessible areas of the stack). Uses uninitialised values in dangerous ways. Leaks memory. Does bad frees of heap blocks (double frees, mismatched frees). Passes overlapping source and destination memory blocks to memcpy() and related functions. Memcheck reports these errors as soon as they occur, giving the source line number at which it occurred, and also a stack trace of the functions called to reach that line. Memcheck tracks addressability at the byte-level, and initialisation of values at the bit-level. As a result, it can detect the use of single uninitialised bits, and does not report spurious errors on bitfield operations. Memcheck runs programs about 10--30x slower than normal. Cachegrind Cachegrind is a cache profiler. It performs detailed simulation of the I1, D1 and L2 caches in your CPU and so can accurately pinpoint the sources of cache misses in your code. It identifies the number of cache misses, memory references and instructions executed for each line of source code, with per-function, per-module and whole-program summaries. It is useful with programs written in any language. Cachegrind runs programs about 20--100x slower than normal. Callgrind Callgrind, by Josef Weidendorfer, is an extension to Cachegrind . It provides all the information that Cachegrind does, plus extra information about callgraphs. It was folded into the main Valgrind distribution in version 3.2.0. Available separately is an amazing visualisation tool, KCachegrind , which gives a much better overview of the data that Callgrind collects; it can also be used to visualise Cachegrind's output. Massif Massif is a heap profiler. It performs detailed heap profiling by taking regular snapshots of a program's heap. It produces a graph showing heap usage over time, including information about which parts of the program are responsible for the most memory allocations. The graph is supplemented by a text or HTML file that includes more information for determining where the most memory is being allocated. Massif runs programs about 20x slower than normal. Helgrind Helgrind is a thread debugger which finds data races in multithreaded programs. It looks for memory locations which are accessed by more than one (POSIX p-)thread, but for which no consistently used (pthread_mutex_) lock can be found. Such locations are indicative of missing synchronisation between threads, and could cause hard-to-find timing-dependent problems. It is useful for any program that uses pthreads. It is a somewhat experimental tool, so your feedback is especially welcome here. DRD DRD is a tool for detecting errors in multithreaded C and C++ programs. The tool works for any program that uses the POSIX threading primitives or that uses threading concepts built on top of the POSIX threading primitives. While Helgrind can detect locking order violations, for most programs DRD needs less memory to perform its analysis. 原文:http://valgrind.org/info/tools.html

优秀的个人博客,低调大师

Facebook iOS UI 工具ComponentKit简介

在 iOS 上面开发界面,需要创建视图、配置界面、视图分层等等很多步骤,也就不可避免的需要书写 N 多的代码。这还仅仅是界面设计,除此之外,完成 controllers 的回调、控制内部事务在界面上的显示效果、界面的操控和内部事务的联系等等多方面的事情都需要手动解决。即便是界面很简单的 App,如果存在这种复杂的双向数据流的关系,那么代码也会变得很复杂很容易出错。Qt 的信号、槽和 iOS 的 Target-Action 机制其实也是很容易实现这种双向数据流的关系,但是没有办法解决界面和事务之间的联系,也有很多其他的问题:性能、测试等。 这些问题曾经困扰了我们多年。News Feed 是有着复杂的列表样式外观的 iOS 软件,由许多的 Row Type 组成,每一个 Row 都有各种各样不同的很烦的界面样式和交互方式,这个就很坑了。每次维护这个东西都像是在清理厕所,尤其是它的功能还在不断增加,它的代码在不断变多,版本迭代速度快到你都没办法直到每天都到底增添了什么新代码,上司还要拿着报告说“你这个软件太慢了,影响用户体验,给你三个小时把这个 App 的速度提高 80%”。 为了解决这一挑战性的问题,我们从自己的 ReactJS 得到启发,把很多具体的东西抽象出来,做出一个功能性的、响应式编程模型的 iOS 原生 UI 框架 ComponentKit,目前 News Feed 在应用这个框架。 ComponentKit 简介 ComponentKit 使用功能性和声明性(declarative)的方法来进行创建界面,和以往不同的是,ComponentKit 使用单向数据流的形式从 不可变的模型 映射到不可变的组件来确定视图的显示方式。ComponentKit 的 declarative 看上去和 declarative UI(QML) 差不多,其实差得远。QML 更偏向于 UI 设计的描述性,而 ComponentKit 则是做好基本 UI 和事件之间的联系,让事件设计和 UI 设计可以分开单独完成。 内在决定外在,组件的功能和内部的层次决定了用户界面该如何规划,界面的规划决定了 UI Kit 的元素层次结构的设计。 传统做法的结果是大部分时间都被浪费在 UI 该如何实现,ComponentKit 却可以让你把时间都用在在 UI 该怎么设计上面。 例如,传统的 iOS 开发中,为了开发一个带有 header、text 和 footer 的视图,需要以下步骤: 分别创建 header 视图、text 视、footer 视图的实例 将三个视图添加为 container 的子视图 添加约束条件,让每个视图和 container 的宽度相同 添加更多的约束条件,确保每个视图的摆放位置 但是 ComponentKit 不一样,ComponentKit 是一种描述性的开发包:你只需要提供你希望得到什么便能得到什么,而不和传统的 iOS 开发一样,再去一个一个地创建视图、修改视图样式、添加视图、添加约束条件。如图所示,想要得到这个布局,只需要使用描述性的语言描述“我想要一个 header 组件,一个 text 组件,一个 footer 组件,他们的宽度相同,从上到下排列在一起”。单单从这点来看,和 QML 相比,ComponentKit 更类似于 Bootstrap:提供已经完成的组件,你只需要决定组件如何摆放,便可轻松地开发出 UI 界面。 ComponentKit 已经完全把如何渲染 UI 的事情抽象出来,程序员完全可以不去考虑具体是如何实现渲染的,也不用去考虑界面渲染该如何优化。ComponentKit 使用后台线程进行界面布局,也实现了智能组件重用,你完全可以不去考虑界面导致的内存泄露问题。ComponentKit 不仅仅可以极大地提高开发效率,界面响应速度和软件的运行效率也会有极大地提升。 News Feed 移植到 ComponentKit ComponentKit 极大地提升了 News Feed 的 UI 响应速度和稳定性,也让整个软件的内部编码更容易理解。ComponentKit 达到了如下的目标: 减少了 70% 的界面渲染代码,麻麻再也不用担心我每次去维护之前都要看那本又臭又长的手册然后花一上午的时间去理解那个错综复杂的布局了。 显著地提高了滑屏的性能。ComponentKit 消除了许多的 container视图,尽力将所有的视图结构化简。更简洁的视图结构意味着界面的渲染性能和执行效率更高。 提高测试覆盖率。ComponentKit 对于 UI 模块化的设计保证了每一部分都可以被分离开来单独进行测试。再加上 snapshot tests,我们现在几乎已经可以对 News Feed 的所有部分都进行测试了。 引入了 ComponentKit 之后,我们能够维护更少的代码,有更少的 bug 需要修复,有更大的测试覆盖率:我们现在可以有更多的时间做羞羞的事情了 ComponentKit 已经在生产环境的 News Feed 上用了六个月,我们觉得可以一直用下去。现在将 ComponentKit 开源,让整个 iOS 开发者社区的人都有 Facebook 的生产效率,也都能和 Facebook 一样做出高性能的 App。很希望你也能在你的开发环境中使用 ComponentKit,然后给我们反馈。 我们重新定义了如何在 iOS 上开发界面,希望你也能用 ComponentKit 开发出更优雅的 App。 快速入门 ComponentKit 已经在 CocoaPods 中可用了,只需要在 Podfile 添加如下代码即可: pod 'ComponentKit', '~> 0.9' pod try ComponentKit 原文:Introducing ComponentKit: Functional and declarative UI on iOS

优秀的个人博客,低调大师

Filebeat轻量级日志采集工具

Beats 平台集合了多种单一用途数据采集器。这些采集器安装后可用作轻量型代理,从成百上千或成千上万台机器向 Logstash 或 Elasticsearch 发送数据。 一、架构图 此次试验基于前几篇文章,需要先基于前几篇文章搭建基础环境。 二、安装Filebeat 下载并安装Filebeat wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.0.1-x86_64.rpm yum install ./filebeat-6.0.1-x86_64.rpm 修改Filebeat配置文件 vim /etc/filebeat/filebeat.yml # 主配置文件 \- type: log # 文档类型 paths: \- /var/log/httpd/access.log* # 从哪里读入数据 # 输出在elasticsearch与logstash二选一即可 output.elasticsearch: #将数据输出到Elasticsearch。与下面的logstash二者选一 hosts: ["localhost:9200"] output.logstash: # 将数据传送到logstash,要配置logstash使用beats接收 hosts: ["172.18.68.14:5044"] 启动Filebeat systemctl start filebeat 三、配置Filebeat 配置Logstash接收来自Filebeat采集的数据 vim /etc/logstash/conf.d/test.conf input { beats { port => 5044 # 监听5044用于接收Filebeat传来数据 } } filter { grok { match => { "message" => "%{COMBINEDAPACHELOG}" # 匹配HTTP的日志 } remove_field => "message" # 不显示原信息,仅显示匹配后 } } output { elasticsearch { hosts => ["http://172.18.68.11:9200","http://172.18.68.12:9200","http://172.18.68.13:9200"] # 集群IP index => "logstash-%{+YYYY.MM.dd}" action => "index" document_type => "apache_logs" } } 启动Logstash /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/test.conf 四、模拟日志访问 通过curl命令来模拟客户访问,生成访问日志 curl 127.0.0.1 curl 172.18.68.51 curl 172.18.68.52 curl 172.18.68.53 五、验证信息 清除之前实验的旧数据(删除时要在对话框中输入删除),然后可以看到filebeat采集数据经过Logtash过滤再送给Elasticsearch的数据。 扩展 随着ELK日志系统逐渐升级,现在已经能基于Filebeat采集各节点日志,Logstash过滤、修剪数据,最后到ELasticsearch中进行索引构建、分词、构建搜索引擎。现在可以基于Elasticsearch的Head查看在浏览器中查看,但是Head仅仅能简单查看并不能有效进行数据分析、有好展示。要想进行数据分析、有好展示那就需要用到Kibana,Kibana依然放在下一篇文章中讲解,这里先放上架构图。

优秀的个人博客,低调大师

几个移动App测试工具

大致介绍如下: bugly:腾讯推出的移动应用崩溃检测服务,提升团队解决异常的效率。 bugHD:开发者可以追踪崩溃信息、崩溃版本、崩溃总数、发生设备和是否修复等信息。是Fir.im 团队做的产品; ----------------------------更多介绍如下,详细请参考个网站官网,及阅读相关帮助 -------------------------- Bugly 是腾讯内部使用的移动应用崩溃检测服务,同时支持 iOS和 Android 平台。目前 Bugly 已经对移动开发者开放。移动开发者在自己的 App 中接入 Bugly 的 SDK 后,就能在应用崩溃后获得信息上报。开发者可以通过 Bugly 的网站看到崩溃的概要和详情。崩溃概要包括,崩溃的列表、近日按小时统计趋势、昨天前天的崩溃次数和崩溃率。 每一类的崩溃详情包括,崩溃发生的机型和系统配置、崩溃时的运行状态、出错线程和其他线程的堆栈,甚至还有系统日志。崩溃详情让开发者了解崩溃发生时各方面的情况,从而方便开发者查找崩溃原因。 Bugly的优势在于,Bugly已经在腾讯内部使用了 4 年,产品经过了细致的内部打磨。 根据团队的介绍,Bugly是业内首家能检测卡顿 / ANR(应用主线程长时间失去响应时弹出的 “等待或关闭” 报错,在 iOS 平台一般称卡顿,Android 平台一般称 ANR )的服务。 依托腾讯的服务器,Bugly对用户在海外发生的应用崩溃也能实时上报。这个功能对于希望海外发行应用的团队很有吸引力,比如游戏海外发行商。 对于 Android 移动应用的异常监控,除了普通的Java类型崩溃,Bugly 还能检测原生崩溃。因此使用AndroidNDK开发C/C++的移动开发团队也能使用 Bugly。 Bugly 能够统计应用启动多少秒之后崩溃的用户数,方便开发者直观了解对用户伤害巨大的闪退的情况。Bugly 还能显示应用崩溃多少次以上的用户数,方便开发者了解对忠诚用户的伤害程度。 Bugly还有问题搜索功能,允许开发者输入关键字搜索相关的崩溃。比如开发者需要找到空指针引起的崩溃,只需在搜索框输入"NullPoint"即可。 Bugly 会定期为开发者提供崩溃信息日报,以数据可视化的形式总结一段时间内的崩溃情况。目前有很多海内外游戏发行商开始使用 Bugly 的服务,测试其代理游戏的用户体验和实际质量。据 Bugly 团队说明:手机QQ、QQ 播放器和QQ邮箱等全部腾讯开发的移动应用及其发行的游戏都在使用 Bugly 进行崩溃监控。 根据团队的说明,目前所有 Bugly 用户都能无限制免费使用这项服务,并且短期内没有收费计划。Bugly 是腾讯开发者服务体系开放的第一步,未来他们会在这个入口基础上陆续接入同样由内部服务平台开放而来的 RDM 灰度体验、持续集成和自动化测试(优测)等服务。 本文转自 念槐聚 博客园博客,原文链接:http://www.cnblogs.com/haochuang/p/4729872.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

编写脚本实用工具

1、查看哪个文件占用最大 查看前十名磁盘空间用户,到第11行,sed会删除列表的剩余部分,然后给列表中每行一个行号。要让行号和磁盘空间文本 位于同一行,用N命令将文本行合并在一行。然后用gawk命令清理,在行号后,加一个冒号(:),还给每行文本的输出行中的每个字段放了一个制表符。这样就生成了一个格式精致的前十名 磁盘空间用户列表了 1 2 3 4 5 6 7 8 9 10 11 [root@digitcube-test1qingyun]#du-Sh/home/*|sort-rn|sed '{11,$D;=}' |sed 'N;s/\n//' |gawk '{print$1":""\t"$2"\t"$3"\n"}' 1 :1020K/home/nexus/sonatype-work/nexus/storage/central/org/springframework/spring-context/ 2.5 . 6 2 :1020K/home/nexus/sonatype-work/nexus/storage/central/ant/ant/ 1.6 . 5 3 :1012K/home/nexus/sonatype-work/nexus/storage/central/org/springframework/spring-beans/ 2.5 . 6 4 :1012K/home/maven/.m2/repository/org/xerial/snappy/snappy-java/ 1.0 . 4.1 5 :1008K/home/home/hadoop/jstorm/dc_topology/tmp/org/apache/hadoop/hdfs/server/namenode 6 :1008K/home/home/hadoop/hadoop- 1.0 . 4 /docs/api/org/apache/hadoop/mapreduce 7 :1008K/home/hadoop/sam/datatask/doubixiyou_1290 8 :1008K/home/hadoop/hadoop- 1.0 . 4 /docs/api/org/apache/hadoop/mapreduce 9 :1004K/home/home/hadoop/jstorm/dc_topology/tmp/kafka/log 10 :1000K/home/maven/.m2/repository/org/xerial/snappy/snappy-java/ 1.0 . 3.2 2、创造加了日期的前十名磁盘空间用户报告的脚本 1 <br> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [root@digitcube-test1tmp] #vimfile_siz.sh #!/bin/bash #Big_User-findbigdiskspaceusersinvariousdirecotries #ParametersforScript # CHECK_DIRECTORIES= "/var/log/home" #direcotriestocheck # ######################MainScript########################### # DATE=` date +%m%d%y` #Dateforreportfile exec >space_file_$DATA.rpt # # echo "TopTenDiskSpaceUsage" #Reportheaderforwholereport echo "for$CHECK_DIRECTORIESDirecotries" # for DIR_CHECK in $CHECK_DIRECTORIES #looptodudirectories do echo "" echo "The$DID_CHECKDirectory:" #Titleheaderforeachdirecotry # #Createalistingoftoptendiskspaceusers du -S$DIR_CHECK2> /dev/null | sort -rn| sed '{11,$D;=}' | sed 'N;s/\n//' | gawk '{printf$1":""\t"$2"\t"$3"\n"}' # done exec > /tmp/test .txt 2、创建按日期归档的脚本 归档文件,让脚本读取file_to_backup里面每个目录或文件,用到一个简单read命令,来读取该文件中的每一条记录。 exec<$CONFIG_FILE read FILE_NAME 为归档配置文件以及从file_to_backup读取每条记录都用了变量.只要read命令在配置文件中发现还有记录要读,它就会在?变量中返回一退出状态码0表示成功,以while循环的测试条件来读取file_to_backup的所有记录 while [ $? -eq 0 ] do .... read FILE_NAME done 一旦read命令到了末尾,返回一个非0状态码,脚本会退出while循环 1 2 3 4 5 [root@digitcube-test1tmp]#cat/home/qingyun/file_to_backup /home/qingyun/test1 /home/qingyun/test2 /home/qingyun/test3 /home/qingyun/love 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 [root@digitcube-test1tmp]#vimDaily_Archive.sh # #SetConfigurationandDestinationFile # CONFIG_FILE=/home/qingyun/file_to_backup DESTINATION=/home/qingyun/$FILE # ##############MainScript###################### # #CheckBackupConfigfileexists # if [-f$CONFIG_FILE]#Makesuretheconfigfilestillexits then echo else echo echo "$CONFIG_FILEdoesnotexist" echo "BackupnotcompletedduetomisstingConfigurationfile" echo exit fi # #Buildthenameofallthefilestobackup # FILE_NO= 1 #Startonline 1 ofConfigFile exec<$CONFIG_FILE#RedirectStdInputtonameofConfigFile # readFILE_NAME#Read1strecord # while [$?-eq 0 ]#Createlistoffilestobackup do #Makesurethefileordirectoryexists if [-f$FILE_NAME] then #Iffileexists.additsnametothelist echo$FILE_NAME FILE_LIST= "$FILE_LIST$FILE_NAME" else #Iffiledoesn'texist.issuewarning echo echo "$FILE_NAME,doesnotexist" echo "Obviously,Iwillnotincludeiinthisarchive" echo "Itislistedonline$FILE_NOoftheconfigfile." echo "Continuingtobuildarchivelist...." echo fi # FILE_NO=$[$FILE_NO+ 1 ]#IncreaseLine/Filenumberbyon readFILE_NAME#Readnextrecord done ############################################################ # #BackupthefilesandCompressArchive # tar-czf$DESTINATION$FILE_LIST 2 >/dev/ null 按小时归档的脚本 归档目录包含了跟一年中的各个月份对应的目录,将月的序号作为目录名。而每月的目录中又包含跟一个月中的各天对应的目录(用天序号来作为目录)。这样只用给每个归档文件加时间戳然后将它他们放到跟日和月份对应的目录就行了。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 [root@digitcube-test1tmp]#vimHourly_Archive.sh #!/bin/bash # #Hourly_Archive-Everyhourcreateanarhive ############################################## # #SetConfigureationFile # CONFIG_FILE=/home/qingyun/hourly/file_to_backup # #SetBaseArchiveDestinationLocation # BASEDEST=/home/qingyun/hourly # #GatherCurrentDay.Month&Time # DAY=`date+%d` MONTH=`date+%m` TIME=`date+%k%M` # #CreateArchiveDestinationDirectory # mkdir-p$BASEDEST/$MONTH/$DAY DESTINATION=$BASEDEST/$MONTH/$DAY/archive.$TIME.tar.gz # #BuildArchvieDestinationfileName # ###############MAINScript##################################### #CheckBackupConfigfileexists # if [-f$CONFIG_FILE]#Makesuretheconfigfilestillexits then echo else echo echo "$CONFIG_FILEdoesnotexist" echo "BackupnotcompletedduetomisstingConfigurationfile" echo exit fi # #Buildthenameofallthefilestobackup # FILE_NO= 1 #Startonline 1 ofConfigFile exec<$CONFIG_FILE#RedirectStdInputtonameofConfigFile # readFILE_NAME#Read1strecord # while [$?-eq 0 ]#Createlistoffilestobackup do #Makesurethefileordirectoryexists if [-f$FILE_NAME] then #Iffileexists.additsnametothelist echo$FILE_NAME FILE_LIST= "$FILE_LIST$FILE_NAME" else #Iffiledoesn'texist.issuewarning echo echo "$FILE_NAME,doesnotexist" echo "Obviously,Iwillnotincludeiinthisarchive" echo "Itislistedonline$FILE_NOoftheconfigfile." echo "Continuingtobuildarchivelist...." echo fi # FILE_NO=$[$FILE_NO+ 1 ]#IncreaseLine/Filenumberbyon readFILE_NAME#Readnextrecord done ############################################################ # #BackupthefilesandCompressArchive # tar-czf$DESTINATION$FILE_LIST 2 >/dev/ null 3、管理用户账号 脚本进入删除用户4个步聚: 1、获得并确认用户账户名, 2、查找和终止用户的进程, 3、创建一份属于该用户账号的所有文件报告, 4、最终删除用户账号 用到判断参数 -z:字符长度0,为真 -n:字符长度非0,为真 unset:删除变量和函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 [root@logicservertmp]#vimDelte_user.sh #!/bin/bash # #Delte_User-Automatesthe 4 steptoremoveanaccount # #DefinFunctions # ########################################################## function get_answer{ unsetANSWER ASK_COUNT= 0 # while [-z "$ANSWER" ]# while noanwser is given.keeipasking do ASK_COUNT=$[$ASK_COUNT+ 1 ] # case $ASK_COUNT in #Ifusergivesnoanswer in timeallotted 2 ) echo echo "Pleaseanswerthequestion" echo ;; 3 ) echo echo "Onelasttry.....pleaseanswerthequestion." echo ;; 4 ) echo echo "Sinceyourefusetoanswerthequestion.." echo "exitingprogram." # exit ;; esac # echo # if [-n "$LINE2" ] then#print 2 lines echo$LINE1 echo-e$LINE2 "\c" else echo-e$LINE1 "\c" fi # #Allow 60 secondtoanswerbefortime-out read-t 60 ANSWER done #Doalittel var iableclean-up unsetLINE1 unsetLINE2 # }#Endofget_answer function # ##################################################################### function process_answer{ # case $ANSWER in y|Y|YES|yes|Yes|yEs|yeS|YEs|yES) #Ifuseranswer "yes" . do noting ;; *) #Ifuseransweranythingbut "yes" .exitscript echo echo$EXIT_LINE1 echo$EXIT_LINE2 echo exit ;; esac # #Doalittle var iableclean-up # unsetEXIT_LINE1 unsetEXIT_LINE2 # }#Endofprocess_answerfuntion # ################################################################### #EndofFunctionDefinitions # ######################MianScript################################# #GetnameofUserAccounttocheck # echo "Step$1-DeterminUserAccountnametoDelete" echo LINE1= "pleaseentertheusernameoftheuser" LINE2= "Accountyouwishtodeletefromsystem:" get_answer USER_ACCOUNT=$ANSWER # #Doublecheck with scriptuserthat this is thecoreectUserAccount # LINE1= "Is$USER_ACCOUNTtheuseraccount" LINE2= "Youwishtodeletefromthesystem?[y/n]" get_answer # #Callprocess_answerfuntion: #Ifuseransweranythingbut "yes" .exitscript # EXIT_LINE1= "Becausetheaccount,$USER_ACCOUNT,isnot" EXIT_LINE2= "Theoneyouwishtodelete.weareleavingthescript..." process_answer # ############################################################################ # USER_ACCOUNT_RECORD=$(cat/etc/passwd|grep-w$USER_ACCOUNT) # if [$?-eq 1 ]#Iftheaccount is notfound.exitscript then echo echo "Account,$USER_ACCOUNT.notfound" echo "Leavingthescript..." echo exit fi # echo "Ifoundthisrecord:" echo$USER_ACCOUNT_RECORD echo # LINE1= "IsthisthecorrectUserAccount?[y/n]" get_answer # # #Callprocess_answer function : #Ifuseranswersanythingbut "yes" ,exitscript # EXIT_LINE1= "Becausetheaccount,$USER_ACCOUNT,isnot" EXIT_LINE2= "Theoneyouwishtodelete.weareleavingthescript...." process_answer # ##################################################################### #Search for anyrunningprocessesthatbelongtotheUserAccount # echo echo "Step#2-Findprocessonsystembelogingtouseraccount" echo echo "$USER_ACCOUNThasthefollowingprocessrunning:" echo # ps-u$USER_ACCOUNT#Listuserprocessesrunning. case $? in 1 )#Noprocessesrunning for this UserAccount # echo "Therearenoprocessesforthisaccountcurrentlyrunning." echo ;; 0 )#Processesrunning for this UserAccount. #AskScriptUser if wantsustokilltheprocesses. # unsetANSWER LINE1= "Wouldyoulikemetokillmeprocess(es)?[y/n]" get_answer # case $ANSWER in y|Y|YES|yes|Yes|yEs|yeS|YEs|yES)#Ifuseranswers "yes" #KillUserAccountprocesses. # echo # #Clean-uptempfileuponsignals trap "rm$USER_ACCOUNT_Running_Process.rpt" SIGTERMSIGINTSIGQUIT # #Listuserprocessesrunning ps-u$USER_ACCOUNT>$USER_ACCOUNT_Running_Process.rpt # exec<$USER_ACCOUNT_Running_Process.rpt#MakereportStdInput readUSER_PROCESS_REC#Firstrecordwillbeblank readUSER_PROCESS_REC # while [$?-eq 0 ] do #obtainPID USER_PID=`echo$USER_PROCESS_REC|cut-d "" -f1` kill- 9 $USER_PID echo "Killedprocess$USER_PID" readUSER_PROCESS_REC done # echo rm$USER_ACCOUNT_Running_Process.rpt#Removetempreport. ;; *)#Ifuseransweranythingbut "yes" , do notkill echo echo "Willnotkilltheprocess(es)" echo ;; esac ;; esac ########################################################################## #CreateareportofallfilesownedbyUserAccount # echo echo "Step#3-Findfilesonsystembelongingtouseraccount" echo echo "Creatingareportofallfilesownedby$USER_ACCOUNT." echo echo "Itisrecommendedthatyoubackup/archivethesefiles." echo "andthendooneoftwothings;" echo "1)Deletethefiles" echo "2)Changethefiles'ownershiptoacurrentuseraccount." echo echo "Pleasewait.Thismaytakeawhile...." echo echo "Pleasewait.Thismaytakeawhile...." # REPORT_DATE=`date+%y%m%d` REPORT_FILE=$USER_ACCOUNT "_files_" $REPORT_DATE ".RPT" # find/-user$USER_ACCOUNT>$REPORT_FILE 2 >/dev/ null # echo echo "Reportiscommlete." echo "Nameofreport:$REPORT_FILE" echo "Locationofreport:`pwd`" echo ############################################ #RemoveUserAccount echo echo "Step#4-Removeuseraccount" echo # LINE1= "Doyouwishtoremove$USER_ACCOUNTaccountfromsystem?[y/n]" get_answer # #Callprocess_answer function : # if useransweranythinbut "yes" .exitscript # EXIT_LINE1= "Sinceyoudonotwishtoremovetheuseraccount." EXIT_LINE2= "$USER_ACCOUNTatthistime.exitingthescript..." process_answer # userdel$USER_ACCOUNT# delete useraccount echo echo "Useraccount.$USER_ACCOUNT.hasbeenremoved" echo 本文转自 zouqingyun 51CTO博客,原文链接:http://blog.51cto.com/zouqingyun/1696340,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册