前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux 技巧

Linux 技巧

作者头像
绿巨人
发布2018-10-10 09:59:08
6020
发布2018-10-10 09:59:08
举报
文章被收录于专栏:绿巨人专栏绿巨人专栏

Linux 技巧

For RedHat Enterprise Linux

系统

Locale

代码语言:javascript
复制
# 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

Network

代码语言:javascript
复制
# 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

工具

Docker

代码语言:javascript
复制
# 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

有用的链接
什么是tmux

tmux 是一个多通道终端。 最大的好处是:

  • 可以避免终端中断带来的session中断

当运行tmux时,实际上会运行一个tmux service,保持session的运行。

tmux的提出的概念是 tmux / sessions * / windows + / panes + tmux可以管理多个sessions。 一个session有多个windows。 一个windows有多个panes。 每个pane是一个终端。

安装

yum -y install tmux

tmux prefix

prefix 是一个重要的概念。它是一个tmux的快捷键,默认是[ctrl + b]。 比如,退出tmux的命令是

代码语言:javascript
复制
tmux -detach

等价于 [ctrl + b, d]

配置文件

~/.tmux.conf

tmux 命令
  • Help
代码语言:javascript
复制
# list command
tmux list-command

# list shortcut keys
tmux list-keys
  • Sessions

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

  • Windows

command

shortcut key

meaning

tmux list-windows

list all windows

tmux kill-window -t [window name]

prefix + &

kill a window

  • Panes

command

shortcut key

meaning

tmux split-window

prefix + %

new a horizontal pane

tmux split-window -v

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 + C-Up

resize the up side

tmux resize-pane -D

prefix + C-Down

resize the down side

tmux resize-pane -L

prefix + C-Left

resize the left side

tmux resize-pane -R

prefix + C-Right

resize the right side

tmux list-panes

list all panes

tmux kill-pane -t [pane name]

prefix + x

kill a pane

  • Save sessions Installation with Tmux Plugin Manager (recommended) Add plugin to the list of TPM plugins in ~/.tmux.conf:
代码语言:javascript
复制
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.

Key bindings prefix + Ctrl-s - save prefix + Ctrl-r - restore

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-09-15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Linux 技巧
    • 系统
      • Locale
      • Network
    • 工具
      • Docker
      • tmux
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档