您的当前位置:首页正文

ubuntu

2020-07-29 来源:爱go旅游网
ubuntu 改 hostname, 改 密码,改 开机画⾯, 查看进程/服务:杂烩⾯

⽤到了以下⼏个操作,全是从⽹上找到的,不忍舍弃,⽴此存照:⼀、改hostname

我⽤的直接改/etc/hostname的名字的⽅法。其它见原⽂:

引⽤⾃:http://www.ducea.com/2006/08/07/how-to-change-the-hostname-of-a-linux-system/

Normally we will set the hostname of a system during the installation process. Many peoples don’t care about this, and don’t change the hostname even if for

example this was set to something really stupid by the datacenter that installed the system (most likely they will set this to “debian” on any debian installation, etc).For me, it is important to see on each one of the ssh screens I will have open at any time a different hostname that is relevant and will give me quickly theinformation on what system I am logged in.

Change the hostname on a running system

On any Linux system you can change its hostname with the command ‘hostname‘ (surprised?)… Here are some quick usages of the command line hostname:

hostname

without any parameter it will output the current hostname of the system.

hostname --fqd

it will output the fully qualified domain name (or FQDN) of the system.

hostname NEW_NAME

will set the hostname of the system to NEW_NAME. This is active right away and will remain like that until the system will be rebooted (because at system boot itwill set this from some particular file configurations – see bellow how to set this permanently). You will most probably need to exit the current shell in order to seethe change in your shell prompt.

Permanent hostname change on Debian based systems

Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh

/etc/hostnameserver

So on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run:

/etc/init.d/hostname.sh start

to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we usedhostname.sh).

Permanent hostname change on RedHat based systems

RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit

/etc/sysconfig/networkNETWORKING=yes

HOSTNAME=\"plain.domainname.com\"GATEWAY=\"192.168.0.1\"GATEWAYDEV=\"eth0\"FORWARD_IPV4=\"yes\"

So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME variable.

Use sysctl to change the hostname

Why would someone need a different method of doing the same thing as above? No idea, but here is anyway: use sysctl to change the variable kernel.hostname:Use:

sysctl kernel.hostname

to read the current hostname, and

sysctl kernel.hostname=NEW_HOSTNAME

to change it.⼆、改密码

密码本来没有忘,⼀直ssh登录不上,想到改密码,改完才发现是系统没有启动。悲剧。 清空密码后,ssh⽆法登录,系统可以估计是安全考虑。shadow中的密码可以从已知的⽂件复制,⽐如你有⼀个已知密码的系统,把相应的字段复制过来即可。主要参考了:http://www.chinaunix.net 作者:bjchenxu 发表于:2009-01-1914:13:03中的以下部分:

⼆. grub

1. 在出现grub画⾯时,⽤上下键选中你平时启动linux的那⼀项(别选dos哟),然后按e键

2. 再次⽤上下键选中你平时启动linux的那⼀项(类似于kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/),然后按e键 3. 修改你现在见到的命令⾏,加⼊single,结果如下: kernel /boot/vmlinuz-2.4.18-14 single ro root=LABEL=/ 4. 回车返回,然后按b键启动,即可直接进⼊linux命令⾏ 5. #vi /etc/shadow

将第⼀⾏,即以root开头的⼀⾏中root:后和下⼀个:前的内容删除, 第⼀⾏将类似于

root::...... 保存

6. #reboot重启,root密码为空

⽹友 snail429 回复于:2002-11-15 14:48:36进⼊单⽤记模式

直接# passwd 就⾏了三、改开机画⾯

在ubuntu 10.10要修改为直接启动到⽂本模式,我完全参考的下⾯内容:修改/etc/default/grub

把GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”改成GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash text”(即在GRUB_CMDLINE_LINUX_DEFAULT项的后⾯加上” text”),然后再运⾏”sudo update-grub”即可。ubuntu 10.04可以在各个模式间切换,按ctrl+alt+f2或着f6 f7

http://my.chinaunix.net/space.php?uid=20586655&do=blog&id=1671143

只是我去掉了splash换成text。开机进⼊tty1, 查看gdm服务没有运⾏,想切到X画⾯要开启gdm服务。四、查看进程、服务

来⾃百度知道http://zhidao.baidu.com/question/151398129.html?push=ql

使⽤root⽤户执⾏如下命令:service XXXX status

⽐如我想确认FTP服务是否正在运⾏:

[root@svr28-69 ~]# service vsftpd statusvsftpd (pid 12520 12518 3545) is running...[root@svr28-69 ~]#

⾸先查看进程是否存在,如服务名为serv,使⽤以下命令:ps -ef|grep serv

如果你知道服务端⼝号的话,如8885,可以使⽤以下命令:netstat -an|grep 8885

如能查出记录,则说明服务是启动的

如果服务运⾏但连接不上,说明服务有问题了,⼀般重启能解决

后记: 许多东西随着我年龄的增加⽽变的⽆⾜轻重,懂了舍弃,懂了冷眼相看,还是不懂世故,还是那么幼稚,单纯,希望这个世界也像我⼀样就好了。好像写在这⾥有点不搭调,这确实是我的感受。继续努⼒吧!

因篇幅问题不能全部显示,请点此查看更多更全内容