Linux shell 常用命令记录


最近为了方便管理托管的服务器,开始部署vmserver了。db服务器打算部署成linux的,目前采用的是Ubuntu,server版本的系统装好之后傻了眼,全命令行的。。。所以开始大肆搜集有用到的命令,放在这里做个备忘吧。

1、强制卸载、安装网卡,用于强制从dhcp获取ip

sudo ifdown eth0

sudo ifup eth0

(类似sudo dhclient -r之类的,目前使用情况来看,貌似没生效。回头发现什么再补充吧。)

2、关机、重启

sudo shutdown –p 0 在0秒后关机并关闭电源

sudo shutdown –r 0 在0秒后关机并重启

3、ubuntu server设置静态IP

$sudo vi /etc/network/interfaces 编辑IP设置文件

-------------------------------------------------分割线------------------------------------------------

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

# This is a list of hotpluggable network interfaces.

# They will be activated automatically by the hotplug subsystem.

mapping hotplug

script grep

map eth0

# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.0.100 # This is your IP

netmask 255.255.255.0

network 192.168.0.0

broadcast 192.168.0.255

gateway 192.168.0.1

-------------------------------------------------分割线------------------------------------------------

sudo /etc/init.d/networking restart 重启网络连接

4、解压tar.gz包

tar –xzf  不打印解压进度

tar –xvzf 打印解压进度

5、移动文件夹或重命名文件夹

mv from to

6、新增用户、用户组

groupadd usergroup 增加用户组

useradd –r – g user usergroup 增加用户到组

7、变更文件夹所属owner及 group(.表示所有文件及文件夹)

chown –R user .

chgrp –R user .

8、复制文件

cp from to

9、修改用户密码

passwd [username]

其他待续吧

相关内容