Linux环境搭建
当前使用ubuntu 18.04,Desktop和Server都可以。
建议直接用:
env_init.sh 去安装,不过注意samba等服务需要修改为自己的目录,vimrc和git等都需要切换自己的配置
常用命令
ssh 比如A要远程登录B,可以在A中配置密码,避免以后每次都需要密码
ssh-copy-id baiy@192.168.0.160
装机基础服务
更换阿里源
修改 /etc/apt/sources.list 更换源
baiy@baiy-All-Series:workspace$ cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
注:如果想搭建本地源环境,请参考 《Ubuntu常用操作》apt-mirror文档,不过需要准备200G+硬盘空间
常用基础工具下载
sudo apt-get install -y net-tools vim git tree ssh nfs-kernel-server \
dos2unix exuberant-ctags \
tftp-hpa tftpd-hpa xinetd \
samba smbclient cifs-utils \
android-tools-fsutils \
autoconf automake build-essential \
libass-dev libfreetype6-dev libsdl2-dev \
libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev \
libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config \
texinfo wget zlib1g-dev \
lib32z1 libc6-i386 lib32ncurses5 \
flex bison \
qemu gcc make gdb git figlet \
libncurses5-dev iasl wget \
device-tree-compiler \
flex bison libssl-dev libglib2.0-dev \
libfdt-dev libpixman-1-dev \
python pkg-config u-boot-tools intltool xsltproc \
gperf libglib2.0-dev libgirepository1.0-dev \
gobject-introspection \
python2.7-dev python-dev bridge-utils \
uml-utilities net-tools \
libattr1-dev libcap-dev \
kpartx libsdl2-dev libsdl1.2-dev \
debootstrap bsdtar \
libelf-dev gcc-multilib g++-multilib \
libcap-ng-dev
Ubuntu下ssh支持root登陆
1.添加root用户密码
sudo passwd root
2.修改root配置
sudo vi /etc/ssh/sshd_config
# Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes
改为
# Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes
3.重启ssh
sudo service ssh restart
`
Ubuntu下NFS服务搭建
安装服务和创建目录
sudo apt-get install nfs-kernel-server
sudo mkdir /nfs_server && sudo chmod 777 /nfs_server -R
修改配置文件/etc/exports
在最后一行添加:
/nfs_server *(rw,sync,no_root_squash,no_subtree_check)
其中:
/nfs_server是与nfs服务客户端共享的目录,
*代表允许所有的网段访问(也可以使用具体的IP)
rw:挂接此目录的客户端对该共享目录具有读写权限
sync:资料同步写入内存和硬盘
no_root_squash:客户机用root访问该共享文件夹时,不映射root用户。(root_squash:客户机用root用户访问该共享文件夹时,将root用户映射成匿名用户)
no_subtree_check:不检查父目录的权限。
重启nfs服务:
sudo service rpcbind restart
sudo service nfs-kernel-server restart
sudo showmount -e
测试
sudo mkdir /mnt/nfs && sudo mount -t nfs 127.0.0.1:/nfs_server /mnt/nfs
mount
然后操作任意目录都可访问
Linux下TFTP服务搭建
安装软件包
sudo mkdir /tftpboot && sudo chmod 777 /tftpboot -R
sudo apt-get install tftp-hpa tftpd-hpa xinetd
配置相关文件
参考 tftp配置 中的附件
cp tftp-conf/tftp /etc/xinetd.d/tftp
cp tftp-conf/tftpd-hpa /etc/default/tftpd-hpa
cp tftp-conf/xinetd.conf /etc/xinetd.con
重新启动服务
sudo service tftpd-hpa restart
sudo /etc/init.d/xinetd reload
sudo /etc/init.d/xinetd restart
测试
# 创建测试文件
man printf > /tftpboot/p1
cd /tmp/ && man printf > p2
# 测试上传和下载文件
tftp 127.0.0.1
get p1
put p2
quit
# 比较md5值
md5sum p1
md5sum p2
md5sum /tftpboot/p1
md5sum /tftpboot/p2
# 删除
rm -r /tmp/p1 /tmp/p2 /tftpboot/p1 /tftpboot/p2
cd -
Linux samba环境搭建
安装软件包
sudo apt-get install samba samba-common
创建目录
# 创建目录,可根据自己选择修改
sudo mkdir -p /home/baiy/workspace
sudo chown baiy /home/baiy/workspace
sudo chgrp baiy /home/baiy/workspace
sudo chmod 777 /home/baiy/workspace
添加用户
# 添加用户
sudo smbpasswd -a baiy
配置
参考 samba 中的附件
# 添加samba配置
sudo cp samba-conf/smb.conf /etc/samba/smb.conf
# 重启samba
sudo service smbd restart
然后windows可以挂盘使用