linux 使用chage 设置密码永不过期

 vmware安装的虚拟机, 今天登录忽然提示“You must change your password now and login again!”, 密码过期了, 我登录设置了ssh免密登录, 输入原始密码,输入新密码后解决。修改成功登录后看了下,密码有效期60天。 通过chage 修改应用用户密码永不过期。 weida@vm-134:~$ chage -l weida Last password change : Apr 28, 2019 Password expires : Jun 27, 2019 Password inactive : Jul 07, 2019 Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 60 Number of days of warning before password expires : 7 设置密码永不过期: ...

2019-04-28 · 1 min · 127 words

ramfs, rootfs and initramfs

查找initramfs资料的时候看到了这篇文章 ramfs-rootfs-initramfs.txt, ramfs, ramdisk, tmpfs, rootfs 文件系统: 1. ramfs内存文件系统,没有硬件存储,仅存放在内存; 2. ramdisk 生成一种块设备, 并且是固定大小, 文件系统需被挂在到系统; 3. tmpfs有大小限制,可以写回到swap space,是ramfs升级版本; 4. rootfs 是特殊ramfs, tmpfs, 2.6版本后支持, 不可卸载就像不能kill init进程一样。 可以通过修改CONFIG_TMPFS 使用tmpfs, 如需设置为ramfs, 强制"rootfstype=ramfs" initramfs与initrd的区别: 1. initrd 单个文件, initramfs 则可以链接到内核镜像 2. initrd文件格式 a gzipped filesystem image , 是需要驱动的, initramfs则是 a gzipped cpio archive 内核支持: 3. initrd使用的启动进程为initrd, 提供后调用内核;initramfs没有使用overmount 后调用内核init完成加载; 4. 切换到 其他的root设备, initrd使用 pivot_root之后卸载ramdisk, initramfs, 删除现有rootfs空间数据 find -xdev / -exec rm '{}' ';' overmount rootfs cd /newmount; mount --move . /; chroot . 构建initramfs工具包: 1. The “klibc” package ...

2019-04-28 · 1 min · 101 words

LeetCode - Palindrome Linked List

Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time and O(1) space? 解题: 找到中间节点后反转判断节点回文 实现: /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ bool isPalindrome(struct ListNode* head){ if (head == NULL || head->next == NULL) { return true; } struct ListNode* slow=head; struct ListNode* fast=head; struct ListNode* pre=NULL; struct ListNode* next=NULL; //get middle while( fast!=NULL && fast->next!=NULL){ slow = slow->next; fast = fast->next->next; } if(fast) { slow=slow->next; } struct ListNode* cur=slow; //and reverse while(cur!=NULL){ pre = cur; cur = cur->next; pre->next = next; next = pre; } //compare cur = head; while(pre!=NULL){ //printf("%d %d\n", head->val, pre->val); if (cur->val != pre->val){ return false; } cur=cur->next; pre= pre->next; } return true; }

2019-04-27 · 1 min · 145 words

关于鸟哥是如何解开 initramfs 的:)

1. 问题: 鸟哥解析 CentOS 7.x 的initramfs 档案内容 文章内容时, 主要疑问是为什么使用的是512bytes去算 “initramfs 档案的前置字元容量 ”的大小。 # 1.先取得initramfs前面应该要去除的容量有多少才对!使用下列方式取得 [root@study ~]# mkdir /dev/shm/initramfs [root@study ~]# cd /dev/shm/initramfs [root@study initramfs]# cpio -i -d --no-absolute- filenames \ > -I /boot/initramfs-3.10.0-229.el7.x86_64.img 22 blocks #这个重点就是在前面的字元占了几个block容量,每个block容量为512bytes, # 因此,前面的部份就总共占了: 22 * 512 = 11264 个bytes 的意思! # 每一个initramfs 档案的前置字元容量都不相同,所以需要先找出来去除才行! 2. 概念: initrd,initramfs的出现:硬件类型增多,要直接存储上的Linux kernel,需要硬件驱动, 而这些驱动由存放在文件系统根目录下, linux通过 虚拟档案系统(Initial RAM Disk或Initial RAM Filesystem) , 把这些启动引导需要的文档驱动加载到RAM中, 通过RAM上的init(systemd)加载我们实际存储上的(init)systemd, 完成后续的正常开机流程。 3. 处理过程: 1. 解析方法: 可以参考 上一篇文章。 2. initramfs格式: 根据解析方法看cenos不同版本cenos6 , cenos7, initramfs格式也是不同。以cenos7 为例,使用skipcpio工具可以实现解析: ...

2019-04-26 · 2 min · 369 words

initramfs 解压方法

最近在学习 鸟哥私房菜第19章,文章在分析Boot Loader 过程中, 提到到了虚拟档案系统(Initial RAM Disk或Initial RAM Filesystem), 1. CentOS7 initramfs CPIO解压方案: 用是cpio分解 initramfs文件, 处理过程如下(以CentOS7 为例): lsinitrd 查看initramfs文件内容;头部说明文档+需要加载内存的核心组件; cpio 算出头部文件占用的block , dd 命令将头部文件跳过, 输出压缩文件; 分解步骤: cpio -i -d --no-absolute-filenames -I /boot/initramfs-3.10.0-862.el7.x86_64.img 输出 26 blocks, 计算获得 512*26=13312bytes dd if=/boot/initramfs-3.10.0-862.el7.x86_64.img of=initramfs.gz bs=13312 skip=1 输出: 1620+1 records in 1620+1 records out 21576502 bytes (22 MB) copied, 0.0304529 s, 709 MB/s 再用gzip,cpio 解压 initramfs.gz。 具体步骤参考鸟哥私房菜 19.3.4 initramfs 的重要性与建立新initramfs 档案 2. 其他方法 google下面有两篇关于解压initramfs文件的文章。 CentOS / RHEL 7 : How to extract initramfs image and edit/view it ...

2019-04-23 · 1 min · 102 words

LeetCode - Find Pivot Index

题目: Given an array of integers nums, write a method that returns the “pivot” index of this array. We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index. If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index. ...

2019-04-22 · 2 min · 222 words

提升编程技巧的关键

这篇文章 The Key To Accelerating Your Coding Skills, 是皓哥推荐的文章。 读完这边文章,结合我自身经历有以下几点感受: 1. 开始学习时要注重细节, 学会调试错误,就是要多动手实际操作; 2. 编程是一件终身学习的过程, 不断的犯错误, 不断进步; 3. 编程需要学习特定领域知识和过程知识。( domain-specific and procedural knowledge.)

2019-04-22 · 1 min · 23 words