- 如何修改sudoers配置
首先su root进入root管理员模式,然后chmod u+w /etc/sudoers对用户增加可写权限,之后vim /etc/sudoers进入编辑,大概在90行有看到如图这样的显示
在下面增加一条自己的用户名[tab]ALL=(ALL)[tab]ALL的指令即可 - 进度条代码
例如vim progressbar.c,编辑以下代码:
#include <stdio.h>
#include <unistd.h>
int main()
{
char buff[11]={0};
int i=0;
for(;i<10;i++)
{
buff[i]='-';
printf("%s\n",buff);
sleep(3);
}
return 0;
}
会出现每隔3秒打印一行的结果,结果是:
[Daisy@localhost ~]$ !gcc
gcc progressbar.c -o progressbar
[Daisy@localhost ~]$ ./progressbar
-
--
---
----
-----
------
-------
--------
---------
----------
注意:!gcc命令是直接对它进行编译处理,说明==\n(换行符)的作用是在标准输出下,刷新缓冲区,那么如果没有\n呢?
[Daisy@localhost ~]$ !gcc
gcc progressbar.c -o progressbar
[Daisy@localhost ~]$ ./progressbar
-------------------------------------------------------[Daisy@localhost ~]$
可以使用\r和fflush,例如:
#include <stdio.h>
#include <unistd.h>
int main()
{
char buff[11]={0};
int i=0;
for(;i<10;i++)
{
buff[i]='-';
printf("%s\r",buff);
fflush(stdout);
sleep(3);
}
return 0;
}
这样的结果就是每隔3秒打印一个‘-’在同一行,因为\r不具备换行和刷新作用。