一个人的角落,也许并没人会看到这里~~ 祝福你,工作顺心,学习快乐~

Linux系统

让 Grub2 记住上次选择的启动项

linux 下可以碰到各种各样的问题,今天解决了一部分,明天也许又会冒出一些新的问题, 但是,更重要的是,fix it and remenber it!

linux 使用配置文件进行管理,其中gurb 的配置文件有, /etc/default/grub/etc/grub.d/

前者存储grub变量,后者为生成一个完整,grub.cfg配置的脚本,

此外,还有一个官方给的/boot/grub2/grubenv

grub-mkconfig 没有Windows项

不知道什么时候开始,我的grub2-mkconfig

找不到Windows的启动项了, 说严重也不严重,但小问题堆起来也会成为大问题的 于是乎,追根溯源, Windows 项原本是在/etc/grub.d/30_os-prober生成

查看其代码,发现使用了os-prober寻找其他系统. 运行发现没有输出,可以确定是这个东西在抽风了

回头一想,之前由于部分主板EFI记动的时候,会检测是否存在/EFI/Microsoft/Boot/bootmfgw.efi,如果存在的话,会直接启动他,所以将其改名了. 将其改回再测试,os-prober可心正常找到Windows项了

于是乎,os-prober要改的话基本没戏,还是写脚本吧,

 vi /etc/grub.d/40_custom

直接将启动项加入就行了.

关于 grub 请详见官方文档!

在Linux下 使用Scroll键开关键盘背光灯

花了4天半的时间鼓捣好了一个机械键盘,

找了一个老外大牛写的stm32-based 键盘矩阵扫描器,改改装在了键盘上边

dfu功能,移植在keil下没有被识别,估计一阵子也没有多少时间来折腾,暂时先用着,

因为io口不够用,多区背光给改成了Scroll键开关,

但是,发现 Scroll 键 在高版本linux下给屏蔽了,

国内百度了半天没找到好的解决方案

转到google 发现 Why is the Scroll Lock key disabled in Cinnamon/Linux/Xorg? 一文给出了详细的方法

Open Here In Teminal From Nautilus

Linux 下的文件管理器 nautilus 可以很容易在终端中打开通过命令

[lanbing@LanBing-Laptop ~]$ nautilus .

但是要想在 nautilus 中打开 Terminal 却很麻烦 于是google了一下 发现软件包:nautilus-open-terminal 功能如其名,果断:

[lanbing@localhost ~]$ sudo dnf search  nautilus-open-terminal
[sudo] password for lanbing: 
Last metadata expiration check performed 1 day, 5:43:29 ago on Wed Apr 13 14:49:06 2016.
===================== N/S Matched: nautilus-open-terminal ======================
nautilus-open-terminal.x86_64 : Nautilus extension for an open terminal shortcut
[lanbing@localhost ~]$ sudo dnf install nautilus-open-terminal -y

安装后在 文件管理器 中右键 即可 方便打开 Terminal 了

WIN7加固态,无陨迁移同时改为EFI 启动

前阵子买了块SSD后,一直打算鼓捣鼓捣EFI启动,全新安装明显不符合IT精神,所以打算把 无陨迁移 以及EFI启动同时做了,机械原C盘做Linux

首先 在原win7下上固态后,4K ,删除自动生成的MBR分区,新建一个300M 的 ESP 分区 剩佘空间用做新系统盘,

之后进入PE

使用GHOST 将C盘  分区对分区 复制 到 固态的 系统盘上

 

转 Linux下关机命令的区别 (halt,poweroff,reboot,shutdown,init)

在linux下一些常用的关机/重启命令。

1.shutdown

    shutdown命令安全地将系统关机。
    有些用户会使用直接断掉电源的方式来关闭linux,这是十分危险的。因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导 致进程的数据丢失﹐使系统处于不稳定的状态﹐甚至在有的系统中会损坏硬件设备。而在系统关机前使用shutdown命令﹐系统管理员会通知所有登录的用户 系统将要关闭。并且login指令会被冻结﹐即新的用户不能再登录。直接关机或者延迟一定的时间才关机都是可能的﹐还可能重启。这是由所有进程 〔process〕都会收到系统所送达的信号〔signal〕决定的。这让像vi之类的程序有时间储存目前正在编辑的文档﹐而像处理邮件〔mail〕和新 闻〔news〕的程序则可以正常地离开等等。
     shutdown执行它的工作是送信号〔signal〕给init程序﹐要求它改变runlevel。Runlevel 0被用来停机〔halt〕﹐runlevel 6是用来重新激活〔reboot〕系统﹐而runlevel 1则是被用来让系统进入管理工作可以进行的状态﹔这是预设的﹐假定没有-h也没有-r参数给shutdown。要想了解在停机〔halt〕或者重新开机 〔reboot〕过程中做了哪些动作﹐你可以在这个文件/etc/inittab里看到这些runlevels相关的资料。

linux 输出重定向问题

> :用于左边指定描述符
&>/dev/null :此处& 指所有输出 ,即全部重定向 至 文件

2>1 :用于将错误输出重写向至当前目录的文件名为1的文件中

2>&1 :用于将错误输出重写至 标准输出

sudo 时 内部命令无法使用 IO重定向
调用 sh -c “command” 来运行命令

sudo sh -c "cat hosts >> /etc/hosts"

bash 启动参数复习

BASH的参数可以用$加数字编号来访问。

如$1代表第一个参数,$2代表第二个参数,以此类推.

但不能用$10来访问第十个参数,如果遇到参数超过十个的情况,必须处理或保存第一个参数($1),然后使用 shift命令删除参数1并将所有剩余的参数下移一位,因此$10就变成了$9.

$#的值将被更新以反映参数的剩余数量。

#!/bin/bash
i=1;
while (($#>0))
do
    echo $i, $1
    shift
    let i=i+1
done

显示了所有参数

Vim: Save file in read-only mode without restart your work

Open a file as normal, forgetting to use “sudo”, and therefore viewing a read-only file.

Then mistakenly try to edit the read-only file in the traditional manner.

:w !sudo tee%

At this point we will be presented with the content of the file and a prompt to press ENTER or type another command.

To simply save the file and move on we just press ENTER, and then press the letter “O” (oh).

(NOTE: “L” seems to do pretty much the same thing.)

The file will be saved but remains open in vi/vim for more editing or reading.

We can now exit normally by typing “:q!” since the file is still open as “read-only”.

What the command does:
:w = Write a file.
!sudo = Call shell sudo command.
tee = The output of the vi/vim write command is redirected using tee.
% = Triggers the use of the current filename.
Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.

Fedora彻底移除Nvidia显卡驱动,以及恢复开源Nouveau驱动

我首先提倡一种思维模式,就是用小白的眼光去看“高深”的问题!

在Fedora中安装Nvidia显卡驱动方法有很多:

  1. 到Nvidia官网下载官方驱动并安装。
  2. 使用第三方源中的软件包。
  3. 使用Bumblebee
    Bumblebee是为解决双显卡切换问题而存在的一个开源产品

不幸的是以上三种方法安装之后,均出现同样失败的结局。

Errors in Upgrade from Fedora 21 to Fedora 22

1. Make sure your current system is up-to-date and backed up

First up, ensure that you have the most up-to-date version of Fedora 21 by updating your system using the Software application, or running the following command in the terminal:

sudo dnf update

2. Install the FedUp tool

Now, open up a Terminal and install FedUp package by using the following command line:

sudo dnf install fedup

3. Start the update with FedUp

Now your system is fully up-to-date, start the upgrade using the following command:

sudo fedup --network 22

This command will tell FedUp to download all the appropriate packages from the Fedora repositories, and prep your system for the upgrade.
4. Reboot, and upgrade

Once the FedUp command from step 3 has completed without errors, reboot your system. In the Fedora Boot Menu (i.e. grub), there will be a menu item “System Upgrade”, select that and press enter.
Boot menu with System Upgrade (fedup) option selected
Boot menu with update option selected

All the appropriate packages and upgrade tasks will now be completed automatically, and when completed you will be able to start using your newly upgraded Fedora system.

# fedup --network 22
setting up repos...
Error: can't get boot images.
The installation repo isn't currently available.
Try again later, or specify a repo using --instrepo.

Using --instrepo To special a repo :

[lanbing@LanBing-PC ~]$ setting up repos...
getting boot images...

Downloading failed: couldn't get boot images: No more mirrors to try.
Last error was: [Errno 14] curl#56 - "Proxy CONNECT aborted"

Change the /etc/yum.conf file to disable Proxy settings ,