linux安装samba服务器教程的过程(linux基础入门知识)

安装ubuntu系统

  • 参考以下步骤进行安装
  • http://blog.sciencenet.cn/blog-892035-1083295.html
  • 其中注意以下几个问题:
  • 制作安装U盘时,使用universal-usb-installer制成的启动U盘无法正常启动,使用UltraISO制作的可以正常
  • 启动,UltraISO制作过程参考:
  • https://blog.csdn.net/fu6543210/article/details/79722615

安装和开启SSH服务

  • 系统安装后,默认是没有安装和开启SSH服务的,安装和开启过程如下:
    • sudo apt-get install openssh-server
    • sudo service ssh start
  • 按上述步骤安装和开启后,默认情况下SSH是开机自启动的,不需要再额外进行配置
  • https://www.cnblogs.com/EasonJim/p/7189509.html

批量创建用户和设置密码

  • 编写shell脚本用于批量创建用户,并且设置统一密码为123,其中要创建的用户名存放于文件users.txt中
  • 脚本如下:

#!/bin/bash

# usage:

# ./add-multi-user.sh users.txt

# sudo useradd -m -s /bin/bash <user_name>

for user_name in `cat $1`

do

echo $user_name

# -m: specify to create default home directory

# -s: specify the default shell to bash

sudo useradd -m -s /bin/bash $user_name

# set default password as “123”

echo “$user_name:123” | sudo chpasswd

done

  • users.txt内容如下:

user1

user2

user3

安装和批量配置samba服务

  • 安装
    • sudo apt-get install samba
  • 备份smb.conf
    • sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
  • 编写shell脚本进行配置,待创建的用户仍存于users.txt,脚本内容如下:

#!/bin/bash

for user_name in `cat $1`

do

echo config samba for $user_name …

# config smb.conf

echo “

[$user_name]

path = /home/$user_name

browseable = yes

writable = yes

valid users = $user_name

” | sudo tee -a /etc/samba/smb.conf

# add smb password for the user

echo -ne “123\n123\n” | sudo smbpasswd -a -s $user_name

echo “config success for $user_name”

echo

done

# restart samba service

sudo service smbd restart

  • 参考:
  • https://blog.csdn.net/wbaction/article/details/72758673

批量添加sudo用户

  • 一个简单而快捷的方式为:
    • sudo usermod -aG sudo <username>
  • 利用上述基本命令,批量添加的脚本如下(同时包括了force color prompt的修改):

#!/bin/bash

for user_name in `cat $1`

do

echo “add sudoer for $user_name”

sudo usermod -aG sudo $user_name

# force color prompt in login shell

sudo sed -i ‘s/#force_color_prompt/force_color_prompt/g’ /home/$user_name/.bashrc

done

安装和配置git

  • 安装很简单
    • sudo apt-get install git
  • 与git服务器的交互配置
  • 把旧服务器下用户主目录下的.ssh拷贝至新的用户主目录下即可
  • 其他git的配置根据自己的情况自定义,如user和mail等
  • 安装和配置post review
  • 下载对应系统python版本的RBTools工具(egg文件,系统python版本可以通过执行python看到,ubuntu 16.04 下默认为Python 2.7.12)
  • https://downloads.reviewboard.org/releases/RBTools/0.4/RBTools-0.4.3-py2.7.egg#md5=c28da8a7f961982958b89a2d17d2bbdf
  • 安装python setup tools
  • sudo apt-get install python-setuptools
  • 安装RBTools的egg文件
  • easy_install RBTools-0.4.3-py2.7.egg
  • 安装完毕后,在用户home目录下,配置review board用户和密码

cat .reviewboardrc

## Current Repository ##

#REPOSITORY = “/home/disk/cameo-src/icore”

## User Configuration ##

USERNAME = “zhifu”

PASSWORD = “123456”

## Review Board Settings ##

REVIEWBOARD_URL = “http://172.22.102.205”

  • 配置IP地址、子网掩码、网关和DNS server等
  • sudo vim /etc/network/interfaces
  • 在后面添加(其中eth0为要添加的网卡名称)

auto eth0

iface eth0 inet static

address 172.22.102.221

netmask 255.255.255.0

gateway 172.22.102.250

dns-nameservers 172.22.93.28 172.22.111.2 114.114.114.114

  • 修改网卡名称为eth0

sudo vim /etc/default/grub

GRUB_CMDLINE_LINUX=””

改为

GRUB_CMDLINE_LINUX=”net.ifnames=0 biosdevname=0″

执行

sudo grub-mkconfig -o /boot/grub/grub.cfg

vim /etc/network/interfaces

  • 更改原有网卡名称为eth0
  • 比如,在原有的内容之后添加eth0(假定配置的IP为192.168.101.111):

# interfaces(5) file used by ifup(8) and ifdown(8)

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 192.168.101.111

netmask 255.255.255.0

gateway 192.168.101.1

dns-nameservers 172.22.93.28 172.22.111.2 114.114.114.114

  • 设置网卡开机自启动
  • sudo systemctl enable networking.service
  • 重启系统
  • 参考:
  • http://blog.51cto.com/270142877/2047563
  • https://blog.csdn.net/wenwenxiong/article/details/52937539

64位环境下运行32位程序

  • 得益于ubuntu系统的multiarch支持,我们可以在64位系统下运行相应的32位程序
  • 添加32位程序multiarch支持(16.04下默认支持):
  • sudo dpkg –add-architecture i386
  • 为32位架构添加库支持(“:i386″后缀表示是32位库),当出现类似库的问题时,都可以通过这种方式来安装32位的库

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

sudo apt-get install libncurses5-dev:i386

sudo apt-get install zlib1g-dev:i386

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注