ubuntu server小技巧(不定期更新)

0.常用工具apt安装包名

# ssh服务器工具
apt-get install openssh-server

# RabbitMQ
apt-get install rabbitmq-server

# python3-pip
apt-get install python3-pip

 

 

1.Linux下增加用户

sudo useradd –d /home/fastdfs -m fastdfs
sudo passwd fastdfs

sudo vi /etc/sudoers

增加该用户的管理员权限,在文件中添加一行

fastdfs ALL=(ALL:ALL) ALL

像下面这样

# User privilege specification
root    ALL=(ALL:ALL) ALL
fastdfs ALL=(ALL:ALL) ALL

保存即可。

 

2.Linux修改静态/动态ip

a) 修改ip获取方式,保存文件:

sudo vi /etc/network/interfaces

动态ip格式:

auto ens33
iface ens33 inet dhcp

静态ip格式

auto ens33
iface ens33 inet static
address 192.168.1.221
netmask 255.255.255.0
gateway 192.168.1.1

b) 修改DNS

sudo vi /etc/resolvconf/resolv.conf.d/base

内容如下

nameserver 192.168.1.1
nameserver 180.76.76.76
nameserver 114.114.114.114
search lan

 

c) 重启网卡/重启网络

sudo /etc/init.d/networking restart
sudo ifconfig ens33 down
sudo ifconfig ens33 up

实在不行重启机器...

reboot

 

3.新增国内的更新源

sudo vi /etc/apt/sources.list

在末尾加入如下内容(网易的源):

deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb http://mirrors.163.com/ubuntu/ precise universe
deb-src http://mirrors.163.com/ubuntu/ precise universe
deb http://mirrors.163.com/ubuntu/ precise-updates universe
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
deb http://mirrors.163.com/ubuntu/ precise multiverse
deb-src http://mirrors.163.com/ubuntu/ precise multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse

最后更新一下清单

sudo apt-get clean
sudo
apt-get update

还可以更新所有工具

sudo apt-get upgrade

 可以c开发类库

sudo apt-get install build-essential
sudo apt-get install gcc

 

posted @ 2015-01-23 09:53  紫零大仙  阅读(374)  评论(0编辑  收藏  举报