linuxkvm命令 linux comm命令詳解

linux怎樣啟動遠(yuǎn)程kvm圖形界面

使用VNC軟件:

站在用戶的角度思考問題,與客戶深入溝通,找到豐順網(wǎng)站設(shè)計與豐順網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名申請、虛擬主機、企業(yè)郵箱。業(yè)務(wù)覆蓋豐順地區(qū)。

Linux下VNC配置詳解,以下配置為配置VNC詳細(xì)介紹。并解決了用VNC View登入發(fā)現(xiàn)畫面是灰色的問題

1. Linux下VNC的配置

首先在Linux的add/remove applications中的system tools下面安裝VNC-server服務(wù)安裝完成后直接輸入vncserver 會出現(xiàn)以下內(nèi)容:

passwd: //只有這個帳號是第一次運行vncserver,才會要求你輸入連接的密碼。

verify:

New 'server1.linux:4 (demo)' desktop is server1.linux:1

Starting applications specified in /home/.vnc/xstartup

Log file is /home/.vnc/server1.linux:1.log

上面這段話表示起動了一個圖形終端,編號為1,要記住這個編號,等下登錄時需要提供這個編號。第一次啟動VNC一定要先直接輸入vncserver。如果你要停止這個進程,使用命令

vncserver -kill :1

啟動后就可以在客戶端上面輸入IP加剛才提到的那個編號即可登陸機器(xxx.xxx.xxx.xxx:1) 看到一個灰色的Xwindow桌面但上面什么也沒有

運行過一次VNSERVER后會在HOME目錄下面生成一個.VNC文件夾(在開始啟動的時候可看到該文件夾的位置)注:該目錄為隱藏,可直接輸入路徑進入。修改xstartup文件,去掉unset SESSION_MANAGER 和exec /etc/X11/xinit/xinitrc 前面的注釋符號,將最后一行twm 改成 gnome-session

vi /root/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER //此行注釋去掉

# exec /etc/X11/xinit/xinitrc //此行注釋去掉

[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"

twm //改成 gnome-session

重新啟動VNCSERVER即可

2、VNC的啟動/停止/重啟

#service vncserver start/stop/restart

關(guān)閉具體的vncserver命令:

vncserver -kill :1

vncserver -kill :2

3、設(shè)置密碼

#vncpasswd

4、客戶端登陸

在vnc客戶端中輸入:服務(wù)器端IP:1或服務(wù)器端IP:2

5、設(shè)置登陸到KDE桌面

注:很多情況下,提示VNC無法連接,或者提示10086錯誤都是沒有修改vncservers文件的問題,所以編輯該文件修改

# VNCSERVERS="1:myusername"

# VNCSERVERARGS[1]="-geometry 800x600"

這兩行問題一般都可以解決。

a.

[root@CentOS ~]# vi /etc/sysconfig/vncservers

# # Uncomment the line below to start a VNC server on display :1 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see # URL:.

# VNCSERVERS="1:myusername"

VNCSERVERS="1:root"

# VNCSERVERARGS[1]="-geometry 800x600"

VNCSERVERARGS[1]=”-geometry 800×600 -alwaysshared -depth 24″

-alwaysshared代表允許多用戶同時登錄 -depth代為色深,參數(shù)有8,16,24,32。

注:紅色部分就是被修改或增加的部分

b.

[root@centos .vnc]$ vi /root/.vnc/xstartup #!/bin/sh

# Uncomment the following two lines for normal desktop:

unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" #gnome-session #set starting GNOME desktop startkde kde desktop

#twm

#Text interface

注:紅色部分就是被修改或增加的部分

c.

重啟VNC即可。

vnc安裝 Oracle:

出現(xiàn)錯誤提示:“Xlib: connection to ":1.0" refused by server”

如下處理:

實用技巧:在Linux下設(shè)置xhost方法步驟

source:

第一步:用root登陸linux,啟動vnc服務(wù);

第二步:根據(jù)vnc起來的端口,設(shè)置export DISPLAY=localhost:1(1表示vnc在第一個tty上啟動的),vnc的啟動信息見附件1;

第三步:執(zhí)行xhost +,并且提示“access control disabled, clients can connect from any host”才正確。

Linux下的操作日志如下:

[root@localhost ~]# vncserverNew 'localhost:1 (root)' desktop is localhost:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost:1.log[root@localhost ~]# export DISPLAY=localhost:1 [root@localhost ~]# xhost +access control disabled, clients can connect from any host

在設(shè)置xhost時,出現(xiàn)了unable的問題。

使用上訴方法就可以搞定。

一下為我以root身份登錄的配置文件

[root@PC-223-CE ~]# vi /etc/sysconfig/vncservers

# The VNCSERVERS variable is a list of display:user pairs.

#

# Uncomment the lines below to start a VNC server on display :2

# as my 'myusername' (adjust this to your own). You will also

# need to set a VNC password; run 'man vncpasswd' to see how

# to do that.

#

# DO NOT RUN THIS SERVICE if your local area network is

# untrusted! For a secure way of using VNC, see

# URL:;.

# VNCSERVERS="2:myusername"

# VNCSERVERARGS[2]="-geometry 800x600"

VNCSERVERS="1:root"

VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared -depth 24"

~

[root@PC-223-CE ~]# vi /root/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER

# exec /etc/X11/xinit/xinitrc

xrdb $HOME/.Xresources

# [ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup

# [ -r $HOME/.Xresources ] xrdb $HOME/.Xresources

xsetroot -solid grey

# vncconfig -iconic

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"

# twm

gnome-session

~

更改完后保存,重新啟動VNC即可

3.多個用戶登錄

linux的VNC可以實現(xiàn)多個用戶同時鏈接.方法如下

su 用戶名

vncserver (這里就是第二個用戶了)

第三個用戶是

su 用戶名

vncserver

添加完后需要在/etc/sysconfig/vncserver里面添加這個用戶,不然就會出現(xiàn)登錄后都是灰色的

另外還需要 修改用戶目錄下的.vnc/xstartup文件

例:我的電腦上已經(jīng)有一個root用戶,此時我還需要ocmSUSEr這個用戶可以VNC登錄

[root@linuxidc~]# su ocmsuser

[ocmsuser@linuxidcroot]$ vncserver

You will require a password to access your desktops.

Password:

Verify:

New 'ywei:2 (ocmsuser)' desktop is ywei:2

Creating default startup script /home/ocmsuser/.vnc/xstartup

Starting applications specified in /home/ocmsuser/.vnc/xstartup

Log file is /home/ocmsuser/.vnc/ywei:2.log

[ocmsuser@linuxidcroot]$ su - root

Password:

[root@linuxidc~]# vi /etc/sysconfig/vncservers

The VNCSERVERS variable is a list of display:user pairs.

#

# Uncomment the lines below to start a VNC server on display :2

# as my 'myusername' (adjust this to your own). You will also

# need to set a VNC password; run 'man vncpasswd' to see how

# to do that.

#

# DO NOT RUN THIS SERVICE if your local area network is

# untrusted! For a secure way of using VNC, see

# URL:;.

# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

# Use "-nohttpd" to prevent web-based VNC clients connecting.

# Use "-localhost" to prevent remote VNC clients connecting except when

# doing so through a secure tunnel. See the "-via" option in the

# `man vncviewer' manual page.

VNCSERVERS="1:root"

VNCSERVERARGS[1]="-geometry 1280x800 -alwaysshared -depth 24"

VNCSERVERS="2:ocmsuser"

VNCSERVERARGS[2]="-geometry 1280x800 -alwaysshared -depth 24"

~

[root@linuxidc~]# cat /root/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:

unset SESSION_MANAGER

exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"

twm

[root@linuxidc~]# cat /home/ocmsuser/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER

# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"

twm

[root@linuxidc~]# cp /home/ocmsuser/.vnc/xstartup /home/ocmsuser/.vnc/xstartup.bak

[root@linuxidc~]# cp /root/.vnc/xstartup /home/ocmsuser/.vnc/xstartup

cp: overwrite `/home/ocmsuser/.vnc/xstartup'? yes

[root@linuxidc~]# service vncserver restart

Shutting down VNC server: 2:ocmsuser [ OK ]

Starting VNC server: 2:ocmsuser

New 'ywei:2 (ocmsuser)' desktop is ywei:2

Starting applications specified in /home/ocmsuser/.vnc/xstartup

Log file is /home/ocmsuser/.vnc/ywei:2.log

[ OK ]

linux kvm怎么改鏡像文件

制作鏡像文件有三種方法,cp, cat, dd 和其它專用工具。cp ,cat 和 dd都可以從設(shè)備復(fù)制文件來創(chuàng)建鏡像。而 dd 命令更為強大,可以通過指定塊大小,塊多少來直接創(chuàng)建鏡像。

IMG 文件:

因為cp, cat 只能從設(shè)備來制作鏡像,但又沒有專用工具來做 IMG 文件,故這里用 dd 命令來制作 IMG 文件。

1,制作

dd if=/dev/zero of=fdimage.img count=2880

or

dd if=/dev/zero of=fdimage.img bs=1024 count=1440

2,格式化

mkfs.msdos fdimage.img

3,修改

可以用下面的命令 mount 后,可直接修改

mount -o loop *.img /mnt

4,可啟動

因為制作可啟動鏡像一定會用到虛擬機,推薦用 Virtualbox,先到網(wǎng)上下個 DOS 啟動盤來引導(dǎo)。用 DOS 的 sys 命令傳遞系統(tǒng)。推薦使用 FreeDOS,屬自由軟件。也可用 dd 命令 來傳遞引導(dǎo)引導(dǎo)信息,并復(fù)制啟動啟動時所需文件來做啟動盤。以 FreeDOS 為例,傳遞啟動信息用以下命令,其中下載的啟動盤為 balder10.img 文件

dd if=balder10.img of=fdimage.img bs=512 count=1 conv=notrunc

多系統(tǒng)用 grub4dos,

1),用 grub.exe 引導(dǎo)多系統(tǒng)

2),安裝 grub 到MBR,用 grldr 來引導(dǎo)多系統(tǒng)。當(dāng)然也可用同上面一樣的辦法用 dd 直接寫入引導(dǎo)信息。

bootlace.com --floppy --chs 0x00

注:才發(fā)現(xiàn)用 dd 命令只能從邏輯扇區(qū)開始 copy,先前我想可否用 dd 來將 grldr.mbr 寫入 u 盤,我用自己的 U 盤試了,結(jié)果不能打開了。因為我的 U 盤為 fat16 格式,邏輯扇區(qū)開始是OBR,接著是FAT表,結(jié)果把 FAT1 表給蓋了,那時還沒有想到還有 FAT2 呢,就格了,現(xiàn)在想起來郁悶啊,好多東西都沒有了。

為什么軟盤可以呢,因為它就沒有前面的63個扇區(qū),直接從邏輯0扇區(qū)開始的。

ISO 文件:

因為文件系統(tǒng)的關(guān)系,就不能用 dd 來直接做 ISO 鏡像了(當(dāng)然,它還是可以從設(shè)備制作 ISO 鏡像)。 ISO 文件的制作有專用工具,

1,制作

mkisofs -r -o cdimage.iso /home/XXX/cddir

2,格式化

用mkiso制作的 iso 已有文件系統(tǒng) iso9660

3,可啟動

無論是引導(dǎo)單系統(tǒng)還是引導(dǎo)多系統(tǒng)都還是用 mkisofs 這個工具,只是加載到光盤的 boot loader 不一樣而已。當(dāng)然也可以將 DOS 的引導(dǎo)器 (也就是它的引導(dǎo)扇區(qū)) 或 windows 的引導(dǎo)器 ( XP 系統(tǒng)的是 ntldr ) 放入讓光盤引導(dǎo)。下面只討論 grub4dos 的使用

1),用 grub.exe 引導(dǎo)多系統(tǒng)

用 DOS 加載 grub.exe 引導(dǎo)多系統(tǒng)

2),將 grub 安裝到光盤 MBR

在制作時可用下面的命令直接生成可啟動鏡像,其中 grldr, menu.lst 要放在 cddir 目錄下,也就是在 cd 根目錄。

mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -o cdimage.iso cddir

mkisofs -R -b grldr -no-emul-boot -boot-load-size 4 -o cdimage.iso cddir

PS,下面給出 dd 命令和 mkisofs 參數(shù)說明

dd (convert and copy files)

dd 是 Linux/UNIX 下的一個非常有用的命令,作用是用指定大小的塊拷貝一個文件,并在拷貝的同時進行指定的轉(zhuǎn)換。

dd 的主要選項:

指定數(shù)字的地方若以下列字符結(jié)尾乘以相應(yīng)的數(shù)字:

b=512, c=1, k=1024, w=2, xm=number m

if=file

輸入文件名,缺省為標(biāo)準(zhǔn)輸入。

of=file

輸出文件名,缺省為標(biāo)準(zhǔn)輸出。

ibs=bytes

一次讀入 bytes 個字節(jié)(即一個塊大小為 bytes 個字節(jié))。

obs=bytes

一次寫 bytes 個字節(jié)(即一個塊大小為 bytes 個字節(jié))。

bs=bytes

同時設(shè)置讀寫塊的大小為 bytes ,可代替 ibs 和 obs 。

cbs=bytes

一次轉(zhuǎn)換 bytes 個字節(jié),即轉(zhuǎn)換緩沖區(qū)大小。

skip=blocks

從輸入文件開頭跳過 blocks 個塊后再開始復(fù)制。

KVM之一: linux如何配置console

The /usr/lib/systemd/system/getty@.service file is responsible for the virtual terminals (/dev/tty[X]). /usr/lib/systemd/system/serial-getty@.service is responsible for all other terminals, such as a serial terminal on /dev/ttyS0 .

Systemd provides a template unit file for serial getty. Template file can be found here /lib/systemd/system/serial-getty@.service

?There are many cloud platforms which are working in Linux virtualisation on back-end. In terms of connectivity we have better option in KVM, which connect it through serial console.

?In this post we would see how we could connect Ubuntu17.04 KVM Virtual machine through serial console. I remember in earlier version and distributions, it need to configure serial console in grub file, but in Ubuntu its very easy and reliable as most of configurations and settings are already configured in OS.

let’s see how things happened here …

?For this post, we are using Ubuntu-17.04 Guest Machine on Ubuntu-16.04 Host machine.

?How to setup serial console, for same we have to connect machine and login on as root user.

?We could connect on KVM Guest machine through SSH from Host Machine.

?We could connect Guest machine through VNC Viewer and could setup Serial console from there. Configuring and connecting VNC viewer posted here . This could be best option to connect Guest machine in any troubleshooting because it could configure without any network connectivity, this also make it same control which we have in serial console with Graphical User Interface from remote host.

?This is Graphical User interface on Host Machine. For this we should have access to Host Machine or Graphical desktop from remote through SSH or VNC.

?Above package should installed for this command. Like in below image we could connect KVM Guest machine.

?Configure a serial console in the Ubuntu guest

?After getting login console we need to start serial console and enable it with below two commands.

?Now we could connect serial console in easy way with virsh console command.

以下方法: 在centos6.5也適用

文章名稱:linuxkvm命令 linux comm命令詳解
網(wǎng)頁路徑:http://muchs.cn/article48/docsdhp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、服務(wù)器托管外貿(mào)網(wǎng)站建設(shè)ChatGPT、網(wǎng)站收錄、網(wǎng)站排名

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作