the linux command?linux恢复出厂命令

大家好,今天来为大家分享the linux command的一些知识点,和linux恢复出厂命令的问题解析,大家要是都明白,那么可以忽略,如果不太清楚的话可以看看本篇文章,相信很大概率可以解决您的问题,接下来我们就一起来看看吧!

linux下vi编辑只读文档无法保存的解决方法

使用普通用户编辑nginx.conf等配置文件:

保存的时候会提示:没有Root Permission

可以用如下方法解决:

保存时加上:

:w!sudo tee%

我这里有一个问题。没有配置sudo权限。

用sudo时提示xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方法:

1)进入超级用户模式。也就是输入su-,系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用)

2)添加文件的写权限。也就是输入命令chmod u+w/etc/sudoers。

3)编辑/etc/sudoers文件。也就是输入命令vim/etc/sudoers,输入i进入编辑模式,找到这一行:root ALL=(ALL) ALL在起下面添加xxx ALL=(ALL) ALL(这里的xxx是你的用户名),然后保存(就是先按一下Esc键,然后输入:wq)退出。

4)撤销文件的写权限。也就是输入命令chmod u-w/etc/sudoers。

再次保存:

查看是否成功:

$ grep sudo nginx.conf

#test:w!sudo tee%

解释:

:w: Write a file.可以将文件写入,文件仍然是只读模式,通过:q!退出

!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.

补充:

在网上看了很多解答,大多是一句话:

:w!sudo tee%;

或者是:

你有权限修改文件吗?

如果是root权限,可以

:wq!

实际上我想说的就是一句话:在打开文件时加上sudo。

即:sudo vi/etc/crontab命令打开文件,此时便是以root权限进入该文件。

此时退出文件使用:wq!就可以了。

想必很多像我一样的小白在见到上面的答案时,最不了解的时自己出问题时是否具备root权限,苦恼全来源于此啊!

小白加油!

Linux中创建新分区提示没有可用自由部门怎么回事

Linux中创建新分区提示没有可用自由部门可以用fdisk命令新建分区,方法如下:

1、首先查看硬盘信息,用fdisk-l命令,如果有硬盘有剩余空间就可以对其进行分区。

[root@bogon桌面]# fdisk-l

Disk/dev/sda: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0x000471ad

Device Boot Start End Blocks Id System

/dev/sda1* 1 26 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 26 3851 30720000 83 Linux

/dev/sda3 3851 4106 2048000 82 Linux swap/ Solaris

/dev/sda4 4106 10444 50912256 5 Extended

/dev/sda5 4106 10444 50911232 83 Linux

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0x00000000

#从上面看出/dev/sda空间已经用完了,/dev/sdb没有使用。

2、下面对/dev/sdb进行分区

[root@bogon桌面]# fdisk/dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xfaa2aa49.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode(command'c') and change display units to

sectors(command'u').

Command(m for help): m//输入m查看帮助文档

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types

m print this menu

n add a new partition//添加一个新的分区

o create a new empty DOS partition table

p print the partition table

q quit without saving changes

s create a new empty Sun disklabel

t change a partition's system id

u change display/entry units

v verify the partition table

w write table to disk and exit

x extra functionality(experts only)

#fdisk选中/dev/sdb输入m所有基本选项都出现,输入n新建分区

Command(m for help): n

Command action

e extended

p primary partition(1-4)

3、有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。先建一个主分区:

Command(m for help): n

Command action

e extended

p primary partition(1-4)

p#建主分区

Partition number(1-4): 1#分区号为1

First cylinder(1-2610, default 1):#直接回车默认从第一个柱面开始划分

Using default value 1

Last

cylinder,+cylinders or+size{K,M,G}(1-2610, default 2610):+2G

#加空间大小,这里有很多种选择:+后面单位可以接M,G,K(记得要大写)表示划分你所加的空间,也可以是柱面数。不管怎样都不能超过该磁盘剩余的空间否则无效。

Command(m for help): p#分好后查看分区信息,刚所做的所有一目了然。

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System

/dev/sdb1 1 262 2104483+ 83 Linux

4、同上所述建立扩展分区:

Command(m for help): n

Command action

e extended

p primary partition(1-4)

e#建立扩展分区

Partition number(1-4): 4

First cylinder(263-2610, default 263):

Using default value 263

Last cylinder,+cylinders or+size{K,M,G}(263-2610, default 2610):+4G

Command(m for help): p

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System

/dev/sdb1 1 262 2104483+ 83 Linux

/dev/sdb4 263 785 4200997+ 5 Extended

5、扩展分区建好就可以在扩展分区建立逻辑分区了

Command(m for help): n

Command action

l logical(5 or over)

p primary partition(1-4)

l#建逻辑分区

First cylinder(263-785, default 263):

Using default value 263

Last cylinder,+cylinders or+size{K,M,G}(263-785, default 785):+2G

Command(m for help): p

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System

/dev/sdb1 1 262 2104483+ 83 Linux

/dev/sdb4 263 785 4200997+ 5 Extended

/dev/sdb5 263 524 2104483+ 83 Linux

6、上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效,需要保存退出。

Command(m for help): w#保存退出

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

linux内核打印linux内核打印

linuxconsole是什么文件

linuxconsole是一个为内核提供打印的缓冲文件。

linux系统下的打印机无法打印怎么解决?

点击屏幕左下角的“开始”按钮,从弹出的菜单列表中选择“打印机和传真”;

在打开的“打印机和传真”窗口中单击左侧的“添加打印机”命令;

接着会弹出“添加打印机向导”对话框,单击“下一步”按钮继续;

一般我们是选择第一项,使用网络打印机也更多的选.

Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的UNIX工具软件、应用程序和网络协议。

它支持32位和64位硬件。Linux继承了Unix以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

Linux操作系统诞生于1991年10月5日(这是第一次正式向外公布时间)。Linux存在着许多不同的Linux版本,但它们都使用了Linux内核。

Linux可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、视频游戏控制台、台式计算机、大型机和超级计算机。

严格来讲,Linux这个词本身只表示Linux内核,但实际上人们已经习惯了用Linux来形容整个基于Linux内核,并且使用GNU工程各种工具和数据库的操作系统。

在Linux下查自己的IP怎么查?

可以使用ifconfig命令查看IP。

ifconfig命令用于配置和显示Linux内核中网络接口的网络参数。

输入ifconfig,会打印出网络接口的参数,除了IP地址还会打印出物理地址、掩码地址等网络接口相关参数.

linuxdmesg命令详解?

linuxdmesg命令参数及用法详解(linux显示开机信息命令)

功能说明:显示开机信息。

语法:dmesg

补充说明:kernel会将开机信息存储在ringbuffer中。您若是开机时来不及查看信息,可利用dmesg来查看。开机信息亦保存在/var/log目录中,名称为dmesg的文件里。

参数:

-c显示信息后,清除ringbuffer中的内容。

-s缓冲区大小>预设置为8196,刚好等于ringbuffer的大小。

-n设置记录信息的层级。扩展阅读一:dmesg命令主要用途

主要应用:

dmesg用来显示内核环缓冲区(kernel-ringbuffer)内容,内核将各种消息存放在这里。在系统引导时,内核将与硬件和模块初始化相关的信息填到这个缓冲区中。内核环缓冲区中的消息对于诊断系统问题通常非常有用。在运行dmesg时,它显示大量信息。通常通过less或grep使用管道查看dmesg的输出,这样可以更容易找到待查信息。例如,如果发现硬盘性能低下,可以使用dmesg来检查它们是否运行在DMA模式:

$dmesg|grepDMA

...

ide0:BM-DMAat0xf000-0xf007,BIOSsettings:hda:DMA,hdb:DMA

ide1:BM-DMAat0xf008-0xf00f,BIOSsettings:hdc:DMA,hdd:DMA

...上面几行可以说明每个IDE设备正在什么模式下运行。如果以太网连接出现问题,那么可以在dmesg日志中搜索eth:

$dmesg|grepeth

forcedeth.c:ReverseEngineerednForce

ethernetdriver.Version0.49.

eth0:forcedeth.c:subsystem:0147b:1c00

boundto0000:00:04.0

eth0:noIPv6routerspresent如果一切正常,那么dmesg显示每个网卡的硬件配置信息。如果某项系统服务未能得到正确的配置,dmesg日志很快就填满错误消息,这是诊断故障的良好起点。

还可以用来探测系统内核模块的加载情况,比如要检测ACPI的加载情况,使用dmesg|grepacpi

dmesg|egrep-i''(apm|acpi)''

Kernelcommandline:vga=274quietconsole=ttyS3,9600acpi=no-idleoot=/dev/hda3

ACPI:CoreSubsystemversion

ACPI:Subsystemenabled

ACPI:Systemfirmwaresupports:C2

ACPI:plvl2lat=99plvl3lat=1001

ACPI:C2enter=1417C2exit=354

ACPI:C3enter=-1C3exit=-1

ACPI:NotusingACPIidle

ACPI:Systemfirmwaresupports:S0S1S4S5

扩展阅读二:dmesg命令使用示例

使用示例

示例一将开机信息发邮件

mandmesg写道

Theprogramhelpsuserstoprintouttheirbootupmessages.Insteadofcopyingthemessagesbyhand,theuserneedonly:

dmesg>boot.messages

andmailtheboot.messagesfiletowhoevercandebugtheirproblem.

#dmesg>boot.messages

#ls-lboot.messages

-rw-r--r--1rootroot1583812-0912begin_of_the_skype_highlighting

1583812-0912免费end_of_the_skype_highlighting:55boot.messages#mail-s"BootLogofLinuxServer"public@web3q.netboot.messages

#示例二浏览dmesg输出的信息

#uname-a

Linuxnew552.6.18-194.el5#1SMPTueMar1621:52:43EDT2010i686i686i386GNU/Linux#dmesg|less

Linuxversion2.6.18-194.el5(mockbuild@x86-007.build.bos.redhat.com)(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010

BIOS-providedphysicalRAMmap:

BIOS-e820:0000000000010000-000000000009fc00(usable)

BIOS-e820:000000000009fc00-00000000000a0000(reserved)

BIOS-e820:00000000000e0000-0000000000100000(reserved)

BIOS-e820:0000000000100000-000000001f7d0000(usable)

BIOS-e820:000000001f7d0000-000000001f7efc00(reserved)

BIOS-e820:000000001f7efc00-000000001f7fb000(ACPINVS)

BIOS-e820:000000001f7fb000-000000001f800000(reserved)

BIOS-e820:00000000e0000000-00000000f0000000(reserved)

BIOS-e820:00000000fec00000-00000000fec02000(reserved)

BIOS-e820:00000000fed20000-00000000fed9b000(reserved)

BIOS-e820:00000000feda0000-00000000fedc0000(reserved)

BIOS-e820:00000000ffb00000-00000000ffc00000(reserved)

BIOS-e820:00000000fff00000-0000000100000000(reserved)

0MBHIGHMEMavailable.

503MBLOWMEMavailable.

Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange

disablingkdump

Usingx86segmentlimitstoapproximateNXprotection

Onnode0totalpages:128976

DMAzone:4096pages,LIFObatch:0

Normalzone:124880pages,LIFObatch:31

DMI2.3present.

UsingAPICdriverdefault

ACPI:RSDP(v000HP)@0x000fe270

ACPI:RSDT(v001HP30C40x31100620HP0x00000001)@0x1f7efc84

ACPI:FADT(v002HP30C40x00000002HP0x00000001)@0x1f7efc00

ACPI:MADT(v001HP30C40x00000001HP0x00000001)@0x1f7efcb8

ACPI:MCFG(v001HP30C40x00000001HP0x00000001)@0x1f7efd14

ACPI:SSDT(v001HPHPQPpc0x00001001MSFT0x0100000e)@0x1f7f6698

ACPI:DSDT(v001HPDAU000x00010000MSFT0x0100000e)@0x00000000

ACPI:PM-TimerIOPort:0x1008

ACPI:LocalAPICaddress0xfec01000

ACPI:LAPIC(acpi_idlapic_idenabled)

Processor#06:13APICversion20

ACPI:LAPIC_NMI(acpi_idhighedgelint)

ACPI:IOAPIC(idaddressgsi_base)

IOAPIC:apic_id1,version32,address0xfec00000,GSI0-23

:

示例三查看dmesg尾部的信息

#dmesg|tail

Bluetooth:L2CAPver2.8

Bluetooth:L2CAPsocketlayerinitialized

Bluetooth:RFCOMMsocketlayerinitialized

Bluetooth:RFCOMMTTYlayerinitialized

Bluetooth:RFCOMMver1.8

Bluetooth:HIDP(HumanInterfaceEmulation)ver1.1

eth0:noIPv6routerspresent

Installingknfsd(copyright(C)1996okir@monad.swb.de).

NFSD:Using/var/lib/nfs/v4recoveryastheNFSv4staterecoverydirectory

NFSD:starting90-secondgraceperiod

#

示例四安装SS7卡驱动时的内核日志

#cdSS7HD_DRIVER/

#ls

bbdddlnx_iss.hbbd_hbi.hbbd_ioc.cbbd_isr.cbbd_pci.cBSD_license.txtGPL_V2-only_license.txtinstall_ss7hd.shMakefile26

bbd_def.hbbd_hs.cbbd_ioc.hbbd_lnx.cbbd_pro.hbuild_ss7hd.shi21555.hMakefile24

#./build_ss7hd.sh

make:Enteringdirectory`/usr/src/kernels/2.6.9-22.EL-i686'

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_hs.o

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_ioc.o

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_isr.o

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_pci.o

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_lnx.o

LD/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.o

Buildingmodules,stage2.

MODPOST

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.mod.o

LD/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.ko

make:Leavingdirectory`/usr/src/kernels/2.6.9-22.EL-i686'

#lsmod|grepss7

ss7hddvr26258080

#dmesg|tail

ACPI:PCIinterrupt0000:02:0d.0->GSI9(level,low)->IRQ9

BBD64bit

SS7HD-suspend

DialogicSS7HDDeviceDriverV100.00(SourceV1.21)

Copyright(C)DialogicCorporation2003-2010.AllRightsReserved

Usingmajordevicenumber251.

ACPI:PCIinterrupt0000:02:0d.0->GSI9(level,low)->IRQ9

BBD64bit

#./install_ss7hd.shremove

#lsmod|grepss7

#dmesg|tail

BBD64bit

SS7HD-suspend

DialogicSS7HDDeviceDriverV100.00(SourceV1.21)

Copyright(C)DialogicCorporation2003-2010.AllRightsReserved

Usingmajordevicenumber251.

ACPI:PCIinterrupt0000:02:0d.0->GSI9(level,low)->IRQ9

BBD64bit

SS7HD-suspend

#

示例五打印并清除内核环形缓冲区

#dmesg-c

Linuxversion2.6.18-194.el5(mockbuild@x86-007.build.bos.redhat.com)(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010

BIOS-providedphysicalRAMmap:

BIOS-e820:0000000000010000-000000000009fc00(usable)

BIOS-e820:000000000009fc00-00000000000a0000(reserved)

BIOS-e820:00000000000e0000-0000000000100000(reserved)

BIOS-e820:0000000000100000-000000001f7d0000(usable)

BIOS-e820:000000001f7d0000-000000001f7efc00(reserved)

BIOS-e820:000000001f7efc00-000000001f7fb000(ACPINVS)

BIOS-e820:000000001f7fb000-000000001f800000(reserved)

BIOS-e820:00000000e0000000-00000000f0000000(reserved)

BIOS-e820:00000000fec00000-00000000fec02000(reserved)

BIOS-e820:00000000fed20000-00000000fed9b000(reserved)

BIOS-e820:00000000feda0000-00000000fedc0000(reserved)

BIOS-e820:00000000ffb00000-00000000ffc00000(reserved)

BIOS-e820:00000000fff00000-0000000100000000(reserved)

0MBHIGHMEMavailable.

503MBLOWMEMavailable.

Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange

disablingkdump

Usingx86segmentlimitstoapproximateNXprotection

Onnode0totalpages:128976

DMAzone:4096pages,LIFObatch:0

Normalzone:124880pages,LIFObatch:31

DMI2.3present.省略输出

Bluetooth:HIDP(HumanInterfaceEmulation)ver1.1

eth0:noIPv6routerspresent

Installingknfsd(copyright(C)1996okir@monad.swb.de).

NFSD:Using/var/lib/nfs/v4recoveryastheNFSv4staterecoverydirectory

NFSD:starting90-secondgraceperiod

#dmesg#less/var/log/dmesg

Linuxversion2.6.18-194.el5(mockbuild@x86-007.build.bos.redhat.com)(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010

BIOS-providedphysicalRAMmap:

BIOS-e820:0000000000010000-000000000009fc00(usable)

BIOS-e820:000000000009fc00-00000000000a0000(reserved)

BIOS-e820:00000000000e0000-0000000000100000(reserved)

BIOS-e820:0000000000100000-000000001f7d0000(usable)

BIOS-e820:000000001f7d0000-000000001f7efc00(reserved)

BIOS-e820:000000001f7efc00-000000001f7fb000(ACPINVS)

BIOS-e820:000000001f7fb000-000000001f800000(reserved)

BIOS-e820:00000000e0000000-00000000f0000000(reserved)

BIOS-e820:00000000fec00000-00000000fec02000(reserved)

BIOS-e820:00000000fed20000-00000000fed9b000(reserved)

BIOS-e820:00000000feda0000-00000000fedc0000(reserved)

BIOS-e820:00000000ffb00000-00000000ffc00000(reserved)

BIOS-e820:00000000fff00000-0000000100000000(reserved)

0MBHIGHMEMavailable.

503MBLOWMEMavailable.

Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange

disablingkdump

Usingx86segmentlimitstoapproximateNXprotection

Onnode0totalpages:128976

DMAzone:4096pages,LIFObatch:0

Normalzo

阅读剩余
THE END