每天一个命令(18)hostname,命令18hostname


hostname 获取本机名字/设置本机名字

hostname

root@nginx02  /application/ngx_openresty/nginx/conf/extra
# hostname
nginx02

hostname nginx 设置临时的会话有效

root@nginx02  /application/ngx_openresty/nginx/conf/extra
# hostname
nginx

设置永久有效 vi /etc/sysconfig/network 并且马上生效,新开会话起作用

root@nginx02  /application/ngx_openresty/nginx/conf/extra
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=nginx02

root@nginx02  /application/ngx_openresty/nginx/conf/extra
# echo "nginx"  > /proc/sys/kernel/hostname

相关内容

    暂无相关文章