ubuntu: run program on startup
system invokes ~/.bashrc on startup. so we can do setup things in this file. we can do release or backup things in ~/.bash_logout file.
查看进程内存占用情况
`ps -ef`
:获取进程ID `cat /proc/proc_id/status`
查看某个进程或服务是否开启 `ps -aux | grep xxxservice xxx status`
查看所有服务的状态 ` service --status-all`
解压和压缩
`tar -xzvf xxx.tar.gz tar -czvf xxx.tar.gz ./xxx`
virtualbox mount
`virtualbox mount -t vboxsf source /mnt/e/source`
如何避免升级LTS版本
换更新源时注意版本对应,16.04 (代号 Xenial Xerus),18.04(Bionic Beaver),20.04 (Focal Fossa)
How to run sudo command without a password on a Linux or Unix
- Backup your `/etc/sudoers` file by typing the following command: `
sudo cp /etc/sudoers /root/sudoers.bak`
- Edit the `/etc/sudoers` file by typing the visudo command: `sudo visudo`
- Append/edit the line as follows in the `/etc/sudoers` file for user named ‘vivek’ to run ‘/bin/kill’ and ‘systemctl’ commands: `
vivek ALL = NOPASSWD: /bin/systemctl restart httpd.service, /bin/kill`
example `lee ALL=(ALL) NOPASSWD:ALL`
安装openssh-server
正常情况下直接执行 `sudo apt install openssh-server`
即可,如果无法安装,可能是因为已经安装了 openssh-client,并且版本过你导致,可执行 `sudo apt remove openssh-client & sudo apt autoremove`
然后再执行前面那句
设置时区
正常情况下,执行以下命令即可:
# ubuntu:
tzselect
# centos:
timedatectl set-timezone Asia/Shanghai
如果 tzselect
报错 "/usr/share/zoneinfo/iso3166.tab: No such file or directory"
,则需要执行:
apt install tzdata