一些linux/Ubuntu常用命令
创建用户:useradd testuser
设置密码:passwd testuser
删除用户:userdel -rf testuser
查看当前路径:pwd
设置HWC时间:
hwclock --systohc
hwclock --hctosys
同步网络时间:ntpdate ntp.ubuntu.com
替代du的磁盘空间分析ncdu: sudo apt install ncdu
tar解压缩安装: tar xf [filename]
make:
./configure
make
sudo make install
开放端口tcp UDP:
sudo iptables -I INPUT -p tcp --dport 139 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 445 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 137 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 138 -j ACCEPT
TUI web浏览器: sudo apt install links
//替代browsh
//查看端口占用
//LISTENING并不表示端口被占用,不要和LISTEN混淆,查看具体端口时候,必须要看到tcp,端口号,LISTEN那一行,才表示端口被占用了
netstat -anp |grep {port}
netstat -nultp
nohup caddy -conf /root/caddy/Caddyfile &
//挂起执行caddy,默认输出到nohup.out
ps -ef | grep caddy
//通过程序名查程序是否在运行以及其占用的PID
kill -9 {PID}
//终止进程
fish: sudo apt install fish
//配置文件位置 ~/.config/fish/config.fish
whereis fish
chsh -s /usr/bin/fish
//将默认 shell 更改为 fish shell
echo /usr/bin/fish | sudo tee -a /etc/shells
//验证 Fish是否已添加到 /etc/shells 目录中
chsh -s /bin/bash
//改回bash
sudo chsh -s /bin/bash pi
//pi用户改回bash
sudo apt install tldr
//精简化man手册
多路复用ssh窗口替代tmux或者byobu ternimator:
sudo apt install terminator
//horizontal split: Ctrl-Shift-o
//vertical split: Ctrl-Shift-e
//Shift focus to:next terminal: Ctrl-Shift-n previous terminal: Ctrl-Shift-p
//Close terminal or tab:Ctrl-Shift-w
//Close window with all it's terminals and tabs: trl-Shift-q
alias:
alias
//列出现有Alias
unalias test
alias test='ls -al'
source ~/.bashrc
//source 配置文件来刷新配置更改
Bash: ~/.bashrc
ZSH: ~/.zshrc
fish: ~/.config/fish/config.fish
//shell的配置文件,并将Alias添加到文件末尾
cron:
30 21 * * * /usr/local/etc/rc.d/lighttpd restart
//每晚21点30重启apache
10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart
//每周六、周日的1 : 10重启apache
crontab -l
//列出计划任务
/etc/init.d/cron restart
//重启生效