
正文
linux命令pf linux命令poweroff
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
怎么结束 linux /pfdump
dump命令用于备份ext2或者ext3文件系统。可将目录或整个文件系统备份至指定的设备,或备份成一个大文件。 命令格式:dump [选项] [参数] 需要备份的文件 常用选项即参数: -[0-9]:备份的层级 -f 设备名称:指定备份设备
相关问答
Q1: linux系统中tar命令的使用详解
Linux系统中tar命令是针对tar包的解压缩命令,下面由我为大家整理了linux系统中tar命令的使用详解,希望对大家有帮助!
linux系统中tar命令的使用详解
一、tar命令用法
#压缩
tar -czvf ***.tar.gz
tar -cjvf ***.tar.bz2
#解压缩
tar -xzvf ***.tar.gz
tar -xjvf ***.tar.bz2
+++++++++++++++++++++++++++++++++++++++++++++
二、tar命令参数说明
-c :建立一个压缩档案的参数指令(create 的意思);
-x :解开一个压缩档案的参数指令!
-t :查看 tarfile 里面的档案!
特别注意,在参数的下达中, c/x/t 仅能存在一个!不可同时存在!
因为不可能同时压缩与解压缩。
-z :是否同时具有 gzip 的属性?亦即是否需要用 gzip 压缩?
-j :是否同时具有 bzip2 的属性?亦即是否需要用 bzip2 压缩?
-v :压缩的过程中显示档案!这个常用,但不建议用在背景执行过程!
-f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
例如使用『 tar -zcvfP tfile sfile 』就是错误的写法,要写成
『 tar -zcvPf tfile sfile 』才对喔!
-p :使用原档案的原来属性(属性不会依据使用者而变)
-P :可以使用绝对路径来压缩!
-N :比后面接的日期(yyyy/mm/dd)还要新的才会被打包进新建的档案中!
--exclude FILE:在压缩的过程中,不要将 FILE 打包!
三、tar命令使用范例
范例一:将整个 /etc 目录下的档案全部打包成为 /tmp/etc.tar
[root@linux ~]# tar -cvf /tmp/etc.tar /etc ==仅打包,不压缩!
[root@linux ~]# tar -czvf /tmp/etc.tar.gz /etc ==打包后,以 gzip 压缩
[root@linux ~]# tar -cjvf /tmp/etc.tar.bz2 /etc ==打包后,以 bzip2 压缩
# 特别注意,在参数 f 之后的档案档名是自己取的,我们习惯上都用 .tar 来作为辨识。
# 如果加 z 参数,则以 .tar.gz 或 .tgz 来代表 gzip 压缩过的 tar file ~
# 如果加 j 参数,则以 .tar.bz2 来作为附档名啊~
# 上述指令在执行的时候,会显示一个警告讯息:
# 『tar: Removing leading `/' from member names 』那是关于绝对路径的特殊设定。
范例二:查阅上述 /tmp/etc.tar.gz 档案内有哪些档案?
[root@linux ~]# tar -tzvf /tmp/etc.tar.gz
# 由于我们使用 gzip 压缩,所以要查阅该 tar file 内的档案时,
# 就得要加上 z 这个参数了!这很重要的!
范例三:将 /tmp/etc.tar.gz 档案解压缩在 /usr/local/src 底下
[root@linux ~]# cd /usr/local/src
[root@linux src]# tar -xzvf /tmp/etc.tar.gz
# 在预设的情况下,我们可以将压缩档在任何地方解开的!以这个范例来说,
# 我先将工作目录变换到 /usr/local/src 底下,并且解开 /tmp/etc.tar.gz ,
# 则解开的目录会在 /usr/local/src/etc 呢!另外,如果您进入 /usr/local/src/etc
# 则会发现,该目录下的档案属性与 /etc/ 可能会有所不同喔!
范例四:在 /tmp 底下,我只想要将 /tmp/etc.tar.gz 内的 etc/passwd 解开而已
[root@linux ~]# cd /tmp
[root@linux tmp]# tar -xzvf /tmp/etc.tar.gz etc/passwd
# 我可以透过 tar -tzvf 来查阅 tarfile 内的文件名称,如果单只要一个档案,
# 就可以透过这个方式来下达!注意到! etc.tar.gz 内的根目录 / 是被拿掉了!
范例五:将 /etc/ 内的所有档案备份下来,并且保存其权限!
[root@linux ~]# tar -czvpf /tmp/etc.tar.gz /etc
# 这个 -p 的属性是很重要的,尤其是当您要保留原本档案的属性时!
范例六:在 /home 当中,比 2005/06/01 新的档案才备份
[root@linux ~]# tar -N '2005/06/01' -czvf home.tar.gz /home
范例七:我要备份 /home, /etc ,但不要 /home/dmtsai
[root@linux ~]# tar --exclude /home/dmtsai -czvf myfile.tar.gz /home/* /etc
范例八:将 /etc/ 打包后直接解开在 /tmp 底下,而不产生档案!
[root@linux ~]# cd /tmp
[root@linux tmp]# tar -cvf - /etc | tar -xvf -
# 这个动作有点像是 cp -r /etc /tmp 啦~依旧是有其有用途的!
# 要注意的地方在于输出档变成 - 而输入档也变成 - ,又有一个 | 存在~
# 这分别代表 standard output, standard input 与管线命令啦!
# 这部分我们会在 Bash shell 时,再次提到这个指令跟大家再解释啰!
++++++++++++++++++++++++++++++++++++++++++++
补充:tar如何解压文件到指定的目录
tar czvf mysql.tar.gz /var/lib/mysql
压缩的文件,我想解压到当前目录下,而不是绝对路径下,该如何解压?
tar cxvf mysql.tar.gz 的话,会覆盖 /var/lib/mysql 下全部文件吧?我现在就一个表坏了,想单独恢复一个表的资料,而不是恢复全部数据库,所以要解压到指定的目录下,再把那个表资料找不来恢复。
============================================
#tar zxvf mysql.tar.gz -C /home/aaa
============================================
tar zxvf mysql.tar.gz -C /home/aaa
这样的话,解压后的目录结构是怎么样的?
/home/aaa/var/lib/mysql 吗?
============================================
试下就知道了....
============================================
归档里面的所有文件均是相对引用,归档解压缩(释放)在了当前目录。归档文件总是释放到当前目录,为的是防止破坏文件系统中重名的文件。
所以,楼主的解压缩不会覆盖/var/lib/mysql,只会释放在当前目录先,即./var/lib/mysql如果想覆盖的话,在归档和解压时请使用-P参数:
tar zcvf mysql.tar.gz -P /var/lib/mysql
tar -Pzxvf mysql.tar.gz
Q2: 如何使用Linux命令dhclient
如何使用Linux命令
dhclient
The
Internet Systems Consortium DHCP Client, dhclient, provides a means for
configuring one or more network interfaces using the Dynamic Host Configuration
Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an
address.
linux
dhclient linux命令pf的语法
dhclient
[ -p port ] [ -d ] [ -e VAR=value ] [ -q ] [ -1 ] [ -r ] [ -lf lease-file ] [
-pf pid-file ] [ -cf config-file ] [ -sf script-file ] [ -e ENVVAR=value ] [ -s
server ] [ -g relay ] [ -n ] [ -nw ] [ -w ] [ if0 [ ...ifN ] ]
-p port
If the DHCP client should listen and transmit on a port other
than the standard (port 68), the -p flag may used. It should be followed by the
udp port number that dhclient should use. This is mostly useful for debugging
purposes. If a different port is specified for the client to listen on and
transmit on, the client will also use a different destination port - one greater
than the specified destination port.
-s
The DHCP client normally transmits any protocol messages it sends
before acquiring an IP address to, 255.255.255.255, the IP limited broadcast
address. For debugging purposes, it may be useful to have the server transmit
these messages to some other address. This can be specified with the -s flag,
followed by the IP address or domain name of the destination.
-g
For testing purposes, the giaddr field of all packets that the
client sends can be set using the -g flag, followed by the IP address to send.
This is only useful for testing, and should not be expected to work in any
consistent or useful way.
-d
The DHCP client will normally run in the foreground until it has
configured an interface, and then will revert to running in the background. To
run force dhclient to always run as a foreground process, the -d flag should be
specified. This is useful when running the client under a debugger, or when
running it out of inittab on System V systems.
-e
The dhclient daemon creates its own environment when executing
the dhclient-script to do the grunt work of interface configuration. To define
extra environment variables and their values, use the -e flag, followed by the
environment variable name and value assignment, just as one would assign a
variable in a shell. Eg: -e IF_METRIC=1
-r
The client normally doesn't release the current lease as it is
not required by the DHCP protocol. Some cable ISPs require their clients to
notify the server if they wish to release an assigned IP address. The -r flag
explicitly releases the current lease, and once the lease has been released, the
client exits.
-1
The -1 flag cause dhclient to try once to get a lease. If it
fails, dhclient exits with exit code two.
-cf, -lf, -pf, and -sf
The DHCP client normally gets its configuration information from
/etc/dhcp3/dhclient.conf, its lease database from
/var/lib/dhcp3/dhclient.leases, stores its process ID in a file called
/var/run/dhclient.pid, and configures the network interface using
/sbin/dhclient-script To specify different names and/or locations for these
files, use the -cf, -lf, -pf and -sf flags, respectively, followed by the name
of the file. This can be particularly useful if, for example, /var/lib/dhcp3 or
/var/run has not yet been mounted when the DHCP client is started.
-w
The DHCP client normally exits if it isn't able to identify any
network interfaces to configure. On laptop computers and other computers with
hot-swappable I/O buses, it is possible that a broadcast interface may be added
after system startup. The -w flag can be used to cause the client not to exit
when it doesn't find any such interfaces. The omshell (1) program can then be
used to notify the client when a network interface has been added or removed, so
that the client can attempt to configure an IP address on that
interface.
-n
The DHCP client can be directed not to attempt to configure any
interfaces using the -n flag. This is most likely to be useful in combination
with the -w flag.
-nw
The client can also be instructed to become a daemon immediately,
rather than waiting until it has acquired an IP address. This can be done by
supplying the -nw flag.
-e
The client runs child processes (scripts) with a clean
environment. Use the -e flag to specify additional environment variables to pass
to child processes.
linux
dhclient linux命令pf的演示示例linux命令pf:
dhclient
eth0
Renews
the IP address.
Linux
renew ip command
$
sudo dhclient -r //release ip 释放IP
$
sudo dhclient //获取IP
Q3: 用c语言编写一个linux程序:通过find一个文件名,系统给一个路径,然后用c语言展开这个路径
#include stdio.h
#include stdlib.h
#include string.h
int main(int argc, char *argv[])
{
char file_name[64] = {0};
char file_path[128] = {0};
char dir_path[64] = {0};
char cmd[256] = {0};
int re = 0;
FILE *pf = NULL;
char *p = NULL;
printf("请输入文件名:\n");
scanf("%s", file_name);
snprintf(cmd, 256, "find -name %s tmp.txt", file_name);//如果文件不在程序运行的本地目录(或者子目录)下,则需要改成find / -name xxxx 但耗时会很长
system(cmd);
//文件中取绝对路径
pf = fopen("tmp.txt", "r");
if (pf)
{
re = fscanf(pf, "%s", file_path);//只取第一行 也就是默认不存在同名文件
if (-1 == re)
{
printf("err0\n");
return 0;
}
else
{
flcose(pf);
pf = NULL;
}
}
else
{
printf("err1\n");
return 0;
}
if (0 == strlen(file_path))
{
printf("err2\n");
return 0;
}
//获取目录名
p = strstr(file_path, file_name);
if (p)
{
*p = '\0';
strcpy(dir_path, file_path);//也可以不cp直接用file_path
}
//通过c语言展开ls这个路径c语言变量 其实我没有理解这句话... 先这么做吧
snprintf(cmd, 256, "ls %s", dir_path);
system(cmd);
return 0;
}
如果哪里有异常就加printf打印出来各个变量
Q4: LINUX、UNIX系统启动不成功,要如何解决?
A 内核引导
当计算机打开电源后linux命令pf,首先是BIOS开机自检linux命令pf,按照BIOS中设置的启动设备(通常是硬盘)来启动。紧接着由启动设备上的grub程序开始引导linuxlinux命令pf,当引导程序成功完成引导任务后,Linux从它们手中接管linux命令pf了CPU的控制权,然后CPU就开始执行Linux的核心映象代码,开始了Linux启动过程。也就是所谓的内核引导开始了,在内核引导过程中其实是很复杂的,我们就当它是一个黑匣子,反正是linux内核做了一些列工作,最后内核调用加载了init程序,至此内核引导的工作就完成了。交给了下一个主角init。
B 运行init
init
进程是系统所有进程的起点,你可以把它比拟成系统所有进程的老祖宗,没有这个进程,系统中任何进程都不会启动。init 程序首先是需要读取配置文件
/etc/inittab。inittab是一个不可执行的文本文件,它有若干行指令所组成。具体内容如下:(你可以在你的linux上执行命令 cat
/etc/inittab 这样获得)
复制代码
代码如下:
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg,
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not havenetworking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
###表示当前缺省运行级别为5(initdefault)linux命令pf;
id:5:initdefault:
###启动时自动执行/etc/rc.d/rc.sysinit脚本(sysinit)
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
###当运行级别为5时,以5为参数运行/etc/rc.d/rc脚本,init将等待其返回(wait)
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
###在启动过程中允许按CTRL-ALT-DELETE重启系统
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
###在2、3、4、5级别上以ttyX为参数执行/sbin/mingetty程序,打开ttyX终端用于用户登录,
###如果进程退出则再次运行mingetty程序(respawn)
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
###在5级别上运行xdm程序,提供xdm图形方式登录界面,并在退出时重新执行(respawn)
# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon
以上面的inittab文件为例,来说明一下inittab的格式。其中以#开始的行是注释行,除了注释行之外,每一行都有以下格式:
代码如下:
id:runlevel:action:process
对上面各项的详细解释如下:
1. id
id是指入口标识符,它是一个字符串,对于getty或mingetty等其他login程序项,要求id与tty的编号相同,否则getty程序将不能正常工作。
2. Runlevel
runlevel是init所处于的运行级别的标识,一般使用0-6以及S或s。0、1、6运行级别被系统保留:其中0作为shutdown动作,1作为重启至单用户模式,6为重启;S和s意义相同,表示单用户模式,且无需inittab文件,因此也不在inittab中出现,实际上,进入单用户模式时,init直接在控制台(/dev/console)上运行/sbin/sulogin。在一般的系统实现中,都使用了2、3、4、5几个级别,在CentOS系统中,2表示无NFS支持的多用户模式,3表示完全多用户模式(也是最常用的级别),4保留给用户自定义,5表示XDM图形登录方式。7-9级别也是可以使用的,传统的Unix系统没有定义这几个级别。runlevel可以是并列的多个值,以匹配多个运行级别,对大多数action来说,仅当runlevel与当前运行级别匹配成功才会执行。
3. action
action是描述其后的process的运行方式的。action可取的值包括:initdefault、sysinit、boot、bootwait等: initdefault是一个特殊的action值,用于标识缺省的启动级别;当init由核心激活以后,它将读取inittab中的initdefault项,取得其中的runlevel,并作为当前的运行级别。如果没有inittab文件,或者其中没有initdefault项,init将在控制台上请求输入runlevel。sysinit、boot、bootwait等action将在系统启动时无条件运行,而忽略其中的runlevel。其余的action(不含initdefault)都与某个runlevel相关。各个action的定义在inittab的man手册中有详细的描述。
Q5: 如何在Linux系统下,用PF
这些是tar打包工具的选项,现在tar都集成了gzip和bzip的功能 没有zxpf吧。 -c 建立新的归档文件 -r 向归档文件末尾追加文件 -x 从归档文件中解出文件 -O 将文件解开到标准输出 -v 处理过程中输出相关信息 -f 对普通文件操作 -z 调用gzip来压缩归...
关于linux命令pf和linux命令poweroff的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






