For RedHat Enterprise Linuxlinux
# clean old kernel packages package-cleanup --oldkernels --count=1 # get boot method systemctl get-default # set boot level to command lines systemctl set-default multi-user.target # set boot level to GUI systemctl set-default graphical.target
# list groups of package yum group list # list packages of a group yum group info "Minimal Install" yum group info "core" # install packages sudo yum install <package name>
# check service status systemctl status docker # configure a service start on boot systemctl enable docker # start a service systemctl start docker systemctl restart docker systemctl stop docker
Linux Storage:
Physical Disks:/dev/sda, /dev/sdb, etc
Physical Volumes: /dev/sda1, /dev/sda2, etc,也能夠是/dev/sdb
Logical Volume Groups: rehl, centos
Logical Volumes: /dev/rehl/root
File System: xfsgit
# enlarge disk size for rehl # check disk size df -lh # list physical disks. If there is no /dev/sdb, try reboot. fdisk -l | grep "Disk /" # find volume group name vgdisplay | grep "VG Name" # find physical volume name pvdisplay | grep "PV Name" # extend a physical volume to a logical volume group vgextend rhel /dev/sdb # add spaces to a logical volume lvextend -l +100%FREE /dev/rhel/root # XFS file system xfs_growfs /dev/rhel/root # check disk size df -lh # ----- enlarge disk size for centos ------- df -lh fdisk -l | grep "Disk /" vgdisplay | grep Name pvdisplay | grep Name vgextend centos /dev/sdb lvextend -l +100%FREE /dev/centos/root xfs_growfs /dev/centos/root df -lh # ----- physical disk partitions -------- # list disk partitions fdisk -l # ----- LVM : logical volume management -------- # active volume group lvm vgchange -ay # ----- LVM : merge /home to / -------- # copy /home mkdir backup mv /home/* ./backup # umount /home umount /home # remove volume /home lvremove /dev/centos/home # extend root size lvextend -l +100%FREE /dev/centos/root # get the configuration work xfs_growfs /dev/centos/root # clear backup folder rm -rf ./backup
wget -r -nH --cut-dirs=3 ftp://username:password@ftp_hostname//dir1/dir2 # Install FTP yum install ftp # FTP commands # connect to a server ftp IP/hostname # Or ftp ftp> open IP/hostname # transfer mode. Use binary mode in most cases. ftp> binary ftp> ascii # get: download a specific file # mget: download multiple files # put|mput # cd|pwd: directory operations on FTP server # lcd: change local direcoty # close: close connection # quit: quit ftp
# install 32bit zip package sudo yum -y install bzip2-libs*686 # zip zip -u package.zip file1 file2
# show system locale locale # show system support locale locale -a # using utf-8 as system locale # export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 # support Asia fonts sudo yum groupinstall Fonts # list installed fonts fc-list
# check network status /sbin/service network status # check ip address ip address
# check the listening ports and applications on Linux sudo lsof -i -P -n | grep LISTEN sudo netstat -tulpn | grep LISTEN sudo nmap -sTU -O IP-address-Here
# create docker group grep "^docker" /etc/group if [ $? -ne 0 ]; then /usr/sbin/groupadd docker fi id root | grep docker if [ $? -ne 0 ];then /usr/sbin/usermod -a -G docker root /usr/sbin/usermod -g docker root fi # install docker curl -fsSL https://get.docker.com/ | sh # support HTTP response via HTTPS tee /etc/docker/daemon.json <<-EOF { "insecure-registries": ["<private host name>:5000"] } EOF # check docker version docker --version # restart docker systemctl stop docker systemctl daemon-reload systemctl start docker # install docker-compose, make sure the path is in the /usr/local/sbin PATH variable curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m`" > /usr/local/sbin/docker-compose chmod +x /usr/local/sbin/docker-compose # check docker-compose version docker-compose --version
# restart docker services sudo systemctl stop docker sudo systemctl daemon-reload sudo systemctl start docker # start docker, need to wait few minutes sudo systemctl restart docker docker-compose start # stop docker docker-compose stop # stop and clear changes docker-compose down docker system prune -f # start with images docker-compose up -d # Re-Install ## cd <compose configure path> docker-compose down docker system prune -f # docker rm -fv $(docker ps -qa) docker rmi $(docker images -q) docker-compose pull docker-compose up -d # Login docker with root docker exec -u 0 -it <container id> bash # Enable docker ssh docker exec <container id> /usr/sbin/sshd
tmux 是一個多通道終端。
最大的好處是:github
當運行tmux時,實際上會運行一個tmux service,保持session的運行。docker
tmux的提出的概念是 tmux / sessions * / windows + / panes +
tmux能夠管理多個sessions。
一個session有多個windows。
一個windows有多個panes。
每一個pane是一個終端。json
sudo yum -y install tmuxwindows
prefix is a key concept in tmux, it is a tmux shortcut key, default is [ctrl + b].
for example, the detach command iscentos
tmux -detach
If you use [ctrl + b, d], also works.bash
~/.tmux.confsession
# install tmux sudo yum -y install tmux # create a session here tmux new-session -s here # detach the session prefix + d # attach the session tmux a tmux a -t here
# list command tmux list-command # list shortcut keys tmux list-keys
command | shortcut key | meaning |
---|---|---|
tmux new-session -s [session name] | create an session | |
tmux attach-session -t [session name] | attach to an (or the only) session | |
tmux detach-session | prefix + d | detach with the current session |
tmux list-sessions | list all sessions | |
tmux kill-session -t [session name] | kill a session |
command | shortcut key | meaning |
---|---|---|
tmux list-windows | list all windows | |
tmux kill-window -t [window name] | prefix + & | kill a window |
command | shortcut key | meaning |
---|---|---|
tmux split-window | prefix + % | new a horizontal pane |
tmux split-window -v | prefix + " | new a horizontal pane |
tmux split-window -h | prefix + % | new a vertical pane |
tmux rotate-window | prefix + C-o | rotate panes |
tmux select-pane -U | prefix + Up | select the up pane |
tmux select-pane -D | prefix + Down | select the down pane |
tmux select-pane -L | prefix + Left | select the left pane |
tmux select-pane -R | prefix + Right | select the right pane |
tmux resize-pane -U | prefix + A-Up | resize the up side |
tmux resize-pane -D | prefix + A-Down | resize the down side |
tmux resize-pane -L | prefix + A-Left | resize the left side |
tmux resize-pane -R | prefix + A-Right | resize the right side |
tmux list-panes | list all panes | |
tmux kill-pane -t [pane name] | prefix + x | kill a pane |
set -g @plugin 'tmux-plugins/tmux-resurrect'
Hit prefix + I to fetch the plugin and source it. You should now be able to use the plugin.app
Key bindings prefix + Ctrl-s - save prefix + Ctrl-r - restore