Linux发行版家族
文件结构介绍
设置apt,国内下载源
# /etc/apt/sources.list
#阿里源
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
查看某个端口被占用
ps aux | grep 2379
显示结果如下:
强制杀掉某个进程
kill -9 7098
显示网络的一些信息(前面最好加上sudo)
# linux
netstat -ntlp | grep 8080
# windows
netstat -ano | findstr 8080
如何启动、关闭和设置ubuntu防火墙,参考此文章 http://blog.sina.com.cn/s/blog_866c5a5d0101ihxv.html
sudo ufw enable|disable
设置机器的主机名
hostnamectl --static set-hostname <your new hostname>
安装telnet
apt-get install telnet
安装ifconfig
apt-get install net-tools
安装curl
apt-get install iputils-ping -y
# 或者
apt install curl
查找某个文件
whereis nginx
查找某个命令在什么位置
type curl
# curl is /usr/bin/curl
环境变量
# 查看环境变量
env
echo $ENV
# 设置临时环境变量,只在当前session中有效
myname=cong
echo $myname
# 设置永久环境变量,所有session中都有效。
export myname=cong
# 打开另一个bash,输入echo $myname 依然可以看到名字
查看系统的设备(mouted device)
df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 476G 458G 18G 97% /
root 476G 458G 18G 97% /root
home 476G 458G 18G 97% /home
data 476G 458G 18G 97% /data
cache 476G 458G 18G 97% /cache
mnt 476G 458G 18G 97% /mnt
none 476G 458G 18G 97% /dev
none 476G 458G 18G 97% /run
none 476G 458G 18G 97% /run/lock
none 476G 458G 18G 97% /run/shm
none 476G 458G 18G 97% /run/user
cgroup 476G 458G 18G 97% /sys/fs/cgroup
C:\ 476G 458G 18G 97% /mnt/c
查看所有的硬件(hardware), 包含CPU和内存等
lshw
lshw|less
查看所有连接的设备
dmesg
dmesg | grep wl
wget下载与tar压缩/解压,参考https://www.cnblogs.com/guanyuespace/p/wget_tar.html
#下载
sudo wget https://download.jetbrains.8686c.com/python/pycharm-community-2020.1.2.tar.gz
#压缩与解压
*.tar 用 tar –xvf 解压
*.gz 用 gzip -d或者gunzip 解压
.tar.gz和.tgz 用 tar –xzf 解压
*.bz2 用 bzip2 -d或者用bunzip2 解压
*.tar.bz2用tar –xjf 解压
*.Z 用 uncompress 解压
*.tar.Z 用tar –xZf 解压
*.rar 用 unrar e解压
*.zip 用 unzip 解压
安装deb文件
sudo dpkg -i /path/to/package.deb