Ubuntu 日常使用命令(日常更新)

问题描述

记录日常使用Ubuntu中遇到问题的解决方案

1.增加用户
sudo adduser username 即可

2.ssh链接
简单情况下, ssh username@IPaddress 即可
参考此文

3.python3和python2切换
参考此文
sudo update-alternatives --install /usr/bin/python python /usr/local/lib/python2.7 100
sudo update-alternatives --install /usr/bin/python python /usr/local/lib/python3.2 150
sudo update-alternatives --config python

4.文件夹复制、删除
参考此文
cp -r dir1 dir2 # 文件夹复制
rm -r file1 dir1 # 文件夹删除

5.ls命令
参考此文
ls -l # 显示类型、权限、用户、修改时间等信息
ls -i # 显示文件存储位置

6.硬链接、软链接
参考此文
ln source destination 硬链接,内容存在同一地址
ln -s source destination 软链接,相当于快捷方式

7.alias 创建命令别名
参考此文
命令结构:alias name='string'
例如:alias foo='cd /usr; ls; cd -'
单独使用alias显示所有别名命令
使用unalias命令删除别名

8.重定向
参考此文
8.1、在命令后面加 > output_file_name进行重定向,会把命令原本的标准输出写到文件中。
8.2、 >> output_file_name表示追加模式
8.3、标准错误重定向:文件流的前 三个称作标准输入、输出和错误,shell 内部分别将其称为文件描述符0、1和2。可用2> output_file_name对输出的错误进行重定向。
8.4、错误与输出同时重定向:ls -l /bin/usr &> ls-output.txt
8.5、处理不必要的输出:例如,ls -l /bin/usr 2> /dev/null,可将不必要的输出写到null中,系统不做处理,也不输出到屏幕
8.6、cat file命令可以以无分页的形式打开一个或多个文件。通过cat与重定向符号>
的配合,可以实现将多个文件连接的效果。cat output.txt output1.txt >m.txt

9、管道线"|"。command1 | command2。command1的输出可以作为command2的输入。
通过管道线可以实现过滤器的功能,例如ls /bin /usr/bin | sort | less,实现了文件列表排序后的输出。
ls /bin /usr/bin | sort | uniq | less实现了列表中内容的不重复输出
ls /bin /usr/bin | sort | uniq -d | less实现了列表中重复内容的输出
ls /bin /usr/bin | sort | uniq | wc -l 实现了输出信息行数的输出。
ls /bin /usr/bin | sort | uniq | wc 实现了输出信息行数、字数(单词数)、字节数的输出

10、匹配符"grep"
格式grep pattern [file...]
ls /bin /usr/bin | sort | uniq | grep zip 实现了对两个文件列表下包含‘zip’字符串文件名的输出。
ls /bin /usr/bin | sort | uniq | grep zip |head -n 5 实现了输出前五个,不加参数默认输出10个
ls /bin /usr/bin | sort | uniq | grep zip |tail -n 5 实现了输出后五个,不加参数默认输出10个
tail -f [file...] 实现了实时观察更新

11、系统升级
sudo apt-get update
sudo apt-get upgrade / sudo apt-get dist-upgrade
若升级某个软件,则直接用sudo apt-get install ***即可

12、文件数量及大小
统计当前文件夹下的所有子文件夹大小:du -h
统计某个文件夹下的一级子文件夹大小:du -h --max-depth=1 /[name]
统计当前文件夹下的文件个数:ls -l | grep "^-" | wc -l

13、安装Anaconda

bash ~/Downloads/Anaconda3-5.2.0-Linux-x86_64.sh

添加清华镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

导出配置:

conda env export > environment.yaml

根据导出配置安装:

conda env create -f environment.yaml

pip 离线安装

pip install --download d:\python27\packs pandas(-r requirements.txt)
pip install --no-index --find-index='******/******' -r requirements.txt

你可能感兴趣的:(Ubuntu 日常使用命令(日常更新))