Text Editor

nano

Vim

VIM

NVIM

Show Capacity

show disk capacity

df -lh

show file size

ls -alh

show folder size

use ls cannot show the total size of the folder. ls only show the size of the “folder” file: 4k

use the command below to show the size of a folder:

du -h --max-depth=1 | sort -h

SSH

使用:

ssh <username>@<address> -p <port>

作为服务器

安装server端:

sudo apt-get install openssh-server

配置sshd文件,位于/etc/ssh/sshd_config。只需要注意一下Port需要更改即可

更改完配置需要重启服务:

sudo systemctl restart sshd

使用下面的命令检查状态:

sudo systemctl status sshd

端口转发

ssh -L <local-port>:<remote-address>:<remote-port> <username>@<address> -p <port>

一般而言,remote-address直接使用127.0.0.1即可

如果是将本地的端口转发给远程的机器,只需要将-L改成-R即可

ssh -R <remote-port>:<local-address>:<local-port> <username>@<address> -p <port>

相似的,<local-address>一般是127.0.0.1

scp

支持单文件,多文件,文件夹。

  1. 上传
    scp -P <remote-port> <-r> <local-file-position> <username>@<remote-address>:<remote-file-position>
    使用<-r>如果上传的是文件夹
  2. 下载
    scp -P <remote-port> <-r> <username>@<remote-address>:<remote-file-position> <local-file-position>
    使用<-r>下载文件夹

压缩文件:-C

Git

refer: git

Docker

refer: docker

Conda

refer: miniconda

pip

refer: pip

pacman & paru

default package manager on ArchLinux, etc.

manual install pkgs

use makepkg -si in the folder with PKGBUILD file.

you can manual write the PKGBUILD or get aur repo by clone:

git clone https://aur.archlinux.org/<pkg_name>

pacman

Configuration

edit /etc/pacman.d/mirrorlist for mirror source:

Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch

edit /etc/pacman.conf for configure:

command

install

sudo pacman -S <pkg_name>

update

sudo pacman -Sy

upgrade

sudo pacman -Syyu

uninstall

sudo pacman -Rsn <pkg_name>

force uninstall(ignore dependency):

Danger

this may cause lots of error.

please make sure you clearly know what you are doing

sudo pacman -Rdd <pkg_name>

clean cache:

sudo pacman -Scc

online search (search all pkgs):

pacman -Ss <pkg_name>

search (with locally installed pkgs):

pacman -Qs <pkg_name>

Paru

same usage as pacman.

download pkgs from aur.archlinux.org, which is not such official.

ntfsfix

修复一些基本的ntfs一致性问题, 不是chkdsk(没法修复复杂的问题, 如索引丢失等)

修复分区:

sudo ntfsfix /dev/nvme0n1p<*>

Clear the volume dirty flag if the volume can be fixed and mounted. If the option is not present or the volume cannot be fixed, the dirty volume flag is set to request a volume checking at next mount.

sudo ntfsfix -d /dev/nvme0n1p<*>

mount

挂载分区.

直接挂载到已有位置(文件夹):

sudo mount /dev/<disk&part> </path/to/mount>

挂载并自动创建文件夹(如果没有):

sudo mount --mkdir /dev/<disk&part> </path/to/mount>

使用option:

sudo mount --options key1=val1,key2=val2 /dev/<disk&part> </path/to/mount>

常用options - btrfs的分卷:

sudo mount -o subvol=/@,defaults,user /dev/<disk&part> </path/to/mount>

指定partition类型:

sudo -t <type> mount /dev/<disk&part> </path/to/mount>

有时候不同类型需要额外安装一些程序, 比如说ntfs需要pacman安装ntfs-3g