導航:首頁 > IDC知識 > ubuntu修改主機名

ubuntu修改主機名

發布時間:2020-08-15 16:56:54

1、如何修改ubuntu的計算機名

如果我們安裝ubuntu時隨便輸入了一個主機名,安裝完成後感覺不好又想修改,怎麼辦? 經過一番研究得到了修改的方法,其實很簡單,只要打開/etc/hostname和/etc/network文件修改裡面的老的主機名為你的新的主機名就可以了

2、ubuntu 怎麼修改@後面的那個名稱?例如我的系統在終端顯示的是:tgxblue@ubutun。我想修改ubuntu那個名稱

@之後的那個是主機名
打開終端:
輸入:sudo gedit /etc/hostname
刪除已有的主機名,輸入新的主機名保存。下載開機生效。

3、Ubuntu如何修改默認的用戶名

1.分別執行以下命令修改文件內容,將各個文件中的原名稱改為新名稱,比如我將用戶名user改為wnt,其它主機名和登陸界面顯示的信息也可以更改。
nano /etc/passwd # 更改用戶名、所屬組名、主目錄名
nano /etc/group # 更改組名,一定要將用戶名加入sudo
nano /etc/shadow # 更改用戶名
nano /etc/hosts # 更改主機名
nano /etc/hostname # 更改登錄界面顯示的信息
2.修改主目錄即/home下的用戶文件夾名字,執行命令:
mv /home/old/ /home/new/,其中old為原用戶名,new為新用戶名。比如我的old為user,new是wnt。
3.修改完後將根目錄掛載為只讀,執行命令:
mount -o remount, ro /。因為剛開始進入recovery模式時是修改為了讀寫模式,為了安全起見最好改回來。完事後reboot重啟,正常開機即可。

4、Ubuntu系統如何快速修改主機名?

1、快速查看主機名
在Ubuntu系統中,快速查看主機名有兩種方法:一是打開一個GNOME終端窗口,在命令提示符中可以看到主機名,主機名通常位於@符號後;二是在終端窗口中輸入命令:hostname或uname –n,均可以查看到當前主機名。
2、臨時修改主機名
修改主機名最為快速的方法就是使用命令hostname 新主機名來改變當前主機名,其中新主機名可以用任何合法字元串來表示。不過採用這種方式,新主機名並不保存在系統中,重啟系統後主機名將恢復為原先的主機名稱。
3、永久修改主機名
在Ubuntu系統中永久修改主機名也比較簡單。主機名存放在/etc/hostname文件中,修改主機名時,編輯hostname文件,在文件中輸入新的主機名並保存該文件即可。重啟系統後,參照上面介紹的快速查看主機名的辦法來確認主機名有沒有修改成功。
值得指出的是,在其他Linux發行版中,並非都存在/etc/hostname文件。如Fedora發行版將主機名存放在/etc/sysconfig/network文件中。所以,修改主機名時應注意區分是哪種Linux發行版。

5、Linux 伺服器如何修改主機名

1,通過修改文件/etc/sysconfig/network .  eg:

# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=Server34 ---->修改想要的名字

 2,修改文件/etc/hosts

127.0.0.1 localhost Server34 localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

3,reboot 既可修改原主機名。

(二)CentOS7.2修改主機名

CentOS7.2修改主機名相對於6.5版本又有所改進,不需要重啟就可以直接修改,具體的方法有如下三種:

(1)修改配置文件/etc/hostname來進行修改

12345

 

[root@localhost ~]# vim /etc/hostname server23[root@localhost ~]# systemctl restart systemd-hostnamed.service[root@localhost ~]# hostnameserver23

 

(2)通過nmtui修改主機名

12345678910111213

 

[root@localhost ~]# nmtui                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ┌─────────────────┤ Set Hostname ├──────────────────┐                                                                       │                                                   │                                                                       │ Hostname Server23________________________________ │                                                                       │                                                   │                                                                       │                                     <Cancel> <OK> │                                                                       │                                                   │                                                                       └───────────────────────────────────────────────────┘                                                                                                                                                                 [root@localhost ~]# hostnameServer23

 

 (3) hostnamectl的命令行工具

123456789101112131415161718192021222324252627282930313233

 

            [root@localhost ~]# hostnamectl -helphostnamectl [OPTIONS...] COMMAND ...Query or change system hostname.  -h --help              Show this help     --version           Show package version     --no-ask-password   Do not prompt for password  -H --host=[USER@]HOST  Operate on remote host  -M --machine=CONTAINER Operate on local container     --transient         Only set transient hostname     --static            Only set static hostname     --pretty            Only set pretty hostnameCommands:  status                 Show current hostname settings  set-hostname NAME      Set system hostname  set-icon-name NAME     Set icon name for host  set-chassis NAME       Set chassis type for host  set-deployment NAME    Set deployment environment for host  set-location NAME      Set location for host[root@localhost ~]# hostnamectl status   Static hostname: Server23         Icon name: computer-vm           Chassis: vm        Machine ID:            Boot ID:     Virtualization: microsoft  Operating System: CentOS Linux 7 (Core)       CPE OS Name: cpe:/o:centos:centos:7            Kernel: Linux 3.10.0-327.el7.x86_64      Architecture: x86-64[root@localhost ~]# hostnamectl set-hostname servers23[root@localhost ~]# hostnameservers23

 

6、如何在ubuntu下更改主機名/更改ubuntu電腦名

如果我們安裝ubuntu時隨便輸入了一個主機名,安裝完成後感覺不好又想修改,怎麼辦?
經過一番研究得到了修改的方法,其實很簡單,只要打開/etc/hostname和/etc/network文件修改裡面的老的主機名為你的新的主機名就可以了!
在Terminal下輸入:
gedit /etc/hostname (Root許可權環境下)
sudo gedit /etc/hostname (非Root許可權環境下)
更改相應的Host名,保存退出!因為是在x-window下修改的,所以需要注銷一下,重新登陸即生效!
如果是在字元界面用
vi /etc/hostname
然後在Terminal下執行hostname命令看看改動是否生效了!(當然文中所說的修改默認都是root許可權之下)。hostname命令不帶任何參數默認是用來顯示主機名的,如果在該命令的後面加上一個字元串,那麼這個字元串就是新設置的主機名,但是這樣的主機名系統沒有記錄,在下次登陸時還是老的主機名。

7、如何修改主機名

登錄伺服器後, 使用以下命令查看主機名hostname -f以Linode的VPS主機產品為例, 你會看到類似以下的信息:li123-45.members.linode.com如果你不在意這些, 可以跳過這篇文章. 這里以Debian/Ubuntu操作系統為例1. 配置/etc/hostname通過以下命令修改主機名echo "myhostname" /etc/hostnamehostname -F /etc/hostname2. 配置/etc/default/dhcpcd如果配置文件/etc/default/dhcpcd存在, 將這個文件內的這段內容注釋掉#SET_HOSTNAME='yes'3. 配置/etc/hosts將"myhostname"替換成你的主機名, "mydomain.com"替換成你伺服器的域名, "123.123.12.12"替換為你伺服器的IP地址127.0.0.1 localhost.localdomain localhost123.123.12.12 myhostname.mydomain.com myhostname4. 重啟networking服務5. 測試結果hostnamehostname -f

8、ubuntu下如何設置主機名

終端 hostname 查看主機名
主機名存放在/etc/hostname中 ,sudo gedit /etc/hostname 修改後保存
/etc/hosts 還有一份 , sudo gedit /etc/hosts 修改保存 重啟即可

9、怎麼把ubuntu改成其他系統名字

修改個系統名字算個毛。。。為啥不來個全套copy?


http://www.noobslab.com/2014/04/macbuntu-1404-pack-is-released.html


What's in this Version?

    Themes are shiny, smooth, and fast

    Mac Boot Splash auto configuration

    Mac theme for LightDM auto configuration

    Four GTK Themes

Three Icon Sets


>> Video Instructions are here

Mac wallpapers

Download Mac OS X Wallpapers


2.  Docky

From last MacBuntu pack I recommended docky because cairo-dock were having issues with power-menu. It is light-weight and works without any problem.


First of all install docky with following command then install Mac theme for docky:

Terminal Commands:

sudo add-apt-repository ppa:docky-core/ppa

 

sudo apt-get update

 

sudo apt-get install docky

 


Download Mac theme for docky and follow the screenshot for theme setup.


Tip: To pin application to dock just open Application and right click on app icon then select 'Pin to dock'.


3: Mac OS X Lion Theme, Icons and cursors:


This pack offers four themes and three icon sets, enter these commands in terminal to get themes, icons and cursors.

Terminal Commands:

sudo add-apt-repository ppa:noobslab/themes

 

sudo apt-get update

 

sudo apt-get install mac-ithemes-v3

 

sudo apt-get install mac-icons-v3

 

After installation choose theme, icons and mac cursor from tweak tool.

To Uninstall themes, icons and cursors

Terminal Commands:

cd /usr/share/icons/mac-cursors && sudo ./uninstall-mac-cursors.sh

 

sudo apt-get remove mac-ithemes-v3 mac-icons-v3

 



4: Apply MBuntu Splash:


Enter following commands to install splash:

Terminal Commands:

sudo add-apt-repository ppa:noobslab/themes

 

sudo apt-get update

 

sudo apt-get install mbuntu-bscreen-v3

 


If you don't like MBuntu Splash, You can get back Ubuntu splash:
Enter following command to remove splash:

Terminal Command:

sudo apt-get autoremove mbuntu-bscreen-v3

 



5: Install MacBuntu theme for LightDM:


Enter following commands to install Mac LightDM theme:

Terminal Commands:

sudo add-apt-repository ppa:noobslab/themes

 

sudo apt-get update

 

sudo apt-get install mbuntu-lightdm-v3

 


If you want to revert back, You can get back LightDM default look:
Enter following command to remove LightDM theme:

Terminal Command:

sudo apt-get remove mbuntu-lightdm-v3

 



6: Indicator Synapse (Alternative to Spotlight)


Indicator-Synapse is developed by elementary OS team and it does the same function like "Spotlight".
To install enter following commands in terminal:

Terminal Commands:

sudo add-apt-repository ppa:noobslab/apps

 

sudo apt-get update

 

sudo apt-get install indicator-synapse

 



7: Replace 'Ubuntu Desktop' text with 'Mac' on the Panel


Enter following commands to change 'Ubuntu Desktop' text on the panel:

Terminal Commands:

cd && wget -O Mac.po http://drive.noobslab.com/data/Mac-14.04/change-name-on-panel/mac.po

 

cd /usr/share/locale/en/LC_MESSAGES; sudo msgfmt -o unity.mo ~/Mac.po;rm ~/Mac.po;cd

 


Revert back to 'Ubuntu Desktop' text, enter following commands in the Terminal:

Terminal Commands:

cd && wget -O Ubuntu.po http://drive.noobslab.com/data/Mac-14.04/change-name-on-panel/ubuntu.po

 

cd /usr/share/locale/en/LC_MESSAGES; sudo msgfmt -o unity.mo ~/Ubuntu.po;rm ~/Ubuntu.po;cd

 



8: Replace Overlay Scroll-bars with Normal


Enter following command in terminal to disable overlay scrollbar:

Terminal Command:

gsettings set com.canonical.desktop.interface scrollbar-mode normal

 


If you want to get back overlay bar, enter following command:

Terminal Command:

gsettings reset com.canonical.desktop.interface scrollbar-mode

 



9: Remove White Dots and Ubuntu Logo from Lock Screen:

Ubuntu 14.04 got new lock screen, I already instructed theme for LightDM but this step is necessary if you are using unity lock screen.


Enter following commands in terminal to remove white dots and Ubuntu logo:

Terminal Commands:

sudo xhost +SI:localuser:lightdm

 

sudo su lightdm -s /bin/bash

 

gsettings set com.canonical.unity-greeter draw-grid false;exit

 

sudo mv /usr/share/unity-greeter/logo.png /usr/share/unity-greeter/logo.png.backup

 


If you want to revert back then use following commands.

Terminal Commands:

sudo xhost +SI:localuser:lightdm

 

sudo su lightdm -s /bin/bash

 

gsettings set com.canonical.unity-greeter draw-grid true;exit

 

sudo mv /usr/share/unity-greeter/logo.png.backup /usr/share/unity-greeter/logo.png

 



10: Apple Logo in Launcher


Enter following commands to install Apple Logo:

Terminal Commands:

wget -O launcher_bfb.png http://drive.noobslab.com/data/Mac-14.04/launcher-logo/apple/launcher_bfb.png

 

sudo mv launcher_bfb.png /usr/share/unity/icons/

 


If you want back Ubuntu logo enter following commands in terminal:

Terminal Commands:

wget -O launcher_bfb.png http://drive.noobslab.com/data/Mac-14.04/launcher-logo/ubuntu/launcher_bfb.png

 

sudo mv launcher_bfb.png /usr/share/unity/icons/

 



11: Auto-hide Unity Launcher:

You can hide unity launcher from Appearance -> Behavior and turn off.



12: Unity Tweak Tool to change Themes & Icons:

You can use these popular tools to change themes and icons in Ubuntu, Also you can change other settings from these tweak tools. You can also install Ubuntu Tweak.

Enter following command to install tweak tools.

Terminal Command:

sudo apt-get install unity-tweak-tool

 



13: Install Monochrome icons for Libreoffice:

Human icons are default in LibreOffice which kind of look weird with this transformation pack, to make LibreOffice more elegant with monochrome icons follow these instructions.

Enter following commands to install monochrome icons for libreoffice.

Terminal Command:

sudo apt-get install libreoffice-style-sifr

 

After installation go to LibreOffice menu select "Tools" > "Options" > "LibreOffice" > "View" and select "Sifr" under "Icon size and style". See following screenshots




14: (Optional) Mac fonts:

Last time I received request about Mac fonts, so this time I am including them with this pack. So here are fonts for you.


Terminal Commands:

wget -O mac-fonts.zip http://drive.noobslab.com/data/Mac-14.04/macfonts.zip

 

sudo unzip mac-fonts.zip -d /usr/share/fonts; rm mac-fonts.zip

 

sudo fc-cache -f -v

 

You can change fonts from Unity-Tweak-Tool, Gnome-Tweak-Tool or Ubuntu Tweak
That's it 

10、如何修改ubuntu系統的電腦名

如果我們安裝ubuntu時隨便輸入了一個主機名,安裝完成後感覺不好又想修改,怎麼辦?
經過一番研究得到了修改的方法,其實很簡單,只要打開/etc/hostname和/etc/network文件修改裡面的老的主機名為你的新的主機名就可以了!
在Terminal下輸入:
gedit /etc/hostname (Root許可權環境下)
sudo gedit /etc/hostname (非Root許可權環境下)
更改相應的Host名,保存退出!因為是在x-window下修改的,所以需要注銷一下,重新登陸即生效!
如果是在字元界面用
vi /etc/hostname
然後在Terminal下執行hostname命令看看改動是否生效了!(當然文中所說的修改默認都是root許可權之下)。hostname命令不帶任何參數默認是用來顯示主機名的,如果在該命令的後面加上一個字元串,那麼這個字元串就是新設置的主機名,但是這樣的主機名系統沒有記錄,在下次登陸時還是老的主機名。

與ubuntu修改主機名相關的知識