Linux初配置 Initial Configuration of Linux
发现每次自己拿到一个新的Linux系统(通常是ubuntu)都有一些程序性的工作,于是写了这个文档。等我有时间写个脚本出来。
I found that every time I got a new Linux system(usually ubuntu), there was always some procedural work, so I wrote this document. I might write a script when I have time.
一、apt换源
可以先备份一下/etc/apt/sources.list,这一步不做也行。
sudo cp /etc/apt/sources.list /etc/apt/sources_copy.list然后编辑原来的这个文件,
去这个网站找对应的代码,换成阿里云的源即可(https://developer.aliyun.com/mirror/ubuntu)
例如我用ARM Ubuntu16.04,用的是这段
# 默认注释了源码仓库,如有需要可自行取消注释
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-security main restricted universe multiverse二、修改每次登录时的默认目录
vi /etc/passwd找到用户所在行,把后面的路径改成想要的即可
三、查看当前ip
hostname -I四、配置静态ip
编辑/etc/dhcpcd.conf文件,加入以下内容,重启即可。
#设置网口的静态 IP 地址
interface eth0
static ip_address=192.168.60.242/24
static routers=192.168.60.1
static domain_name_servers=192.168.60.1
#设置 WiFi 的静态 IP 地址
interface wlan0
static ip_address=192.168.60.242/24
static routers=192.168.60.1
static domain_name_servers=192.168.60.1routers是路由器,domain_name_servers是DNS服务器,一般二者填一样的。
五、配置使用帮助tldr
ubuntu下安装很简单,执行以下三条命令:
sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install -g tldr如果出现了警告,有可能是因为nodejs版本问题,用一下命令升级nodejs:
sudo apt-get install nodejs-legacy
sudo npm install -g n
sudo n latest如果升级nodejs失败,可能是Ubuntu版本问题,用以下命令安装稳定版nodejs:
sudo n stable
sudo node -v然后再安装tldr
sudo npm install -g tldr用一下命令可以对tldr更新
tldr --update六、查看系统架构:
uname -mx86:Intel;x64:AMD