linux命令

HomeBrew

1
/bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh]ahttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh))"

OnMyZsh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//zsh 设置为默认的shell
chsh -s `which zsh`

Insecure completion-dependent directories detected: 解决方案

chmod 755 /usr/local/share/zsh & chmod 755 /usr/local/share/zsh/site-functions

sudo apt install curl wget git vim

//安装zsh ohmyzsh
sudo apt install zsh && sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

//安装插件

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k && vim ~/.zshrc

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

ZSH_THEME="powerlevel10k/powerlevel10k"

//最后刷新一下
source ~/.zshrc

yyyy 1112 2111 21 y1y

Mac Vim 高亮

1
2
3
set nu 
colorscheme desert
syntax on

查看命令路径

1
2
3
which 用来查看当前要执行的命令所在的路径

whereis 用来查看一个命令或者文件所在的路径

SMB服务安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sudo apt-get install samba

sudo vim /etc/samba/smb.conf

sudo smbpasswd -a admin

sudo service smbd restart

[share]
comment = jshare
path = /home/jokin/share
valid users = admin
read only = no
writable = yes
create mask = 0777
directory mask = 0777
guest ok = no
browseable = yes

远程执行 命令

1
ssh user:192.168.1.1 "touch a.txt"

node安装

1
2
3
sudo apt install npm 
sudo npm install -g n
sudo n stable

压缩

Zip

1
zip -r archivename.zip directory_name

tar.gz

1
2
3
4
//压缩
tar -zcvf 压缩文件名 .tar.gz 被压缩文件名
//解压
tar -zxvf 压缩文件名.tar.gz

ssh免密登录

1
2
3
4
//生成公私钥 一路回车
ssh-keygen
//上传公钥到服务器
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.235.22

清除buff/cache

1
2
3
4
5
6
7
8
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches"

sudo sh -c "echo 2 > /proc/sys/vm/drop_caches"

sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"

或者
echo 1 |sudo tee /proc/sys/vm/drop_caches

查看端口占用

1
sudo lsof -i:80

没有sudo

apt install sudo

没有sudo权限

1
2
3
4
5
6
7
8
1.切到root

2. chmod u+w /etc/sudoers

3. vim /etc/sudoers
添加没有权限的用户
youuser ALL=(ALL) ALL
4. chmod u-w /etc/sudoers

解决git每次都要输入密码

1
git config --global credential.helper store

命令行连接ftp

apt insstall ftp

ftp

Open 192.168.2.1

put

get

ubuntu 源

sudo vim /etc/apt/sources.list

1
2
3
4
5
6
7
8
9
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

sudo apt update

ubuntu

ssh连接不上

apt-get update

apt-get install openssh-server

apt-get install nano

nano /etc/ssh/sshd_config

PermitRootLogin 修改为PermitRootLogin yes

service ssh restart

passwd root

添加用户useradd -m jokin

ubuntu 时间不对

1
2
3
4
5
sudo vim /etc/profile
在文件前面插入
export TZ='CST-8'

source /etc/profile