# Check hardware info
$ cat /etc/centos-release # version | |
$ lspci | grep -i nvidia # gpu | |
$ uname -a # kernel | |
$ lshw -html > /hardware.html # print all info | |
$ lscpu # cpu info | |
$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c # cpu parameters | |
$ cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l # physical cpus | |
$ cat /proc/cpuinfo| grep "cpu cores"| uniq # no.cores | |
$ cat /proc/cpuinfo| grep "processor"| wc -l # virtual cpus | |
$ cat /proc/meminfo |grep MemTotal # memory | |
$ fdisk -l |grep Disk # disk info | |
$ lsscsi # SSD | |
$ lsof -i # list the process name and number that has opened the ports | |
$ netstat -tulnp # see if a program or process is listening on a port, ready to accept a packet |
# Switch to multi-user mode
$ systemctl get-default # graphical.target is useless | |
$ systemctl stop gdm.service | |
$ systemctl set-default multi-user.target |
Reference1
# Empty the buffers and cache
# To clear the swap:
$ swapoff /dev/dm-1 | |
$ swapon /dev/dm-1 | |
$ swapon -s |
Reference2
# Yum
$ yumdownloader packagename # off-line install | |
$ yum --disablerepo='*' install rpm-package |
# File operation
# Permission
$ chmod -R 700 ./file | |
$ chown -R user:group ./file |
# Move
# copy all the files including hidden files | |
$ cp -a /old/. /folder/ |
# Download
# background, continue, input, output | |
$ wget -bc -i url.list -o log.txt | |
# advanced options: -r recursive //-np no-parent //-4 connect only to IPv4 addresses. | |
# write output to a file named as the remote file | |
$ curl -O http://file |
# compress & uncompress
$ tar -zxvf file -C /dir # -C uncompress to directory //-z for gzip //-j for bzip | |
$ unzip file -d ./dir # -d uncompress to directory | |
$ tar -cfz archive.tar.gz file1 file2 file3 | |
$ tar -czPf archive.tar.gz /file_dir -C /outdir # -P don't strip leading `/'s from file names |
# Sync time
# on master node
$ date -s "2021-11-22 13:15:43" |
$ clock -w | |
$ systemctl restart ntpd.service |
# wait for a while
# on slave node
$ systemctl stop ntpd.service | |
$ ntpd -gq | |
$ systemctl start ntpd.service |
Reference3
# Sudo
# add a sudoer
username ALL=(root) /usr/sbin/*,/sbin/*,/usr/bin/*,!/usr/bin/passwd,!/usr/sbin/visudo,!/usr/sbin/useradd,!/usr/sbin/userdel,!/usr/sbin/reboot,!/usr/sbin/poweroff,!/usr/sbin/shutdown |
Reference4
Reference5
# History
$ echo 'HISTTIMEFORMAT="%F %T "' >> /etc/profile | |
$ source /etc/profile |
Reference6
# Backup
$ rsync -zvh backup.tar /tmp/backups/ # cp file | |
$ rsync -avzh /root/rpmpkgs /tmp/backups/ # cp dir | |
# rsync --remove-source-files -avzhR /root/rpmpkgs /tmp/backups/ |
Reference7
# md5sum
$ find ./ -type f -print0 | xargs -0 md5sum >> filename.md5 | |
$ md5sum -c filename.md5 > check.log |