GNU/Linux >> Linux の 問題 >  >> Linux

Centos 7:vim を構成する

Vim は強力なオープン ソースのコマンド ライン テキスト エディターです。 Vim の設定ファイルは /etc/vimrc にあります。まず、VIM テスト エディターをインストールする必要があります。次に、構成ファイルを開いて、必要な設定を適用する必要があります。

[root@thehackertips ~]# yum -y install vim-enhanced

[root@thehackertips ~]# vi /etc/vimrc

# You can applly vim configuration which you want, Some of them applied by default.
set number # Show line numbers
set linebreak # Break lines at word (requires Wrap lines)
set showbreak=+++ # Wrap-broken line prefix
set textwidth=100 # Line wrap (number of cols)
set showmatch # Highlight matching brace
set spell # Enable spell-checking
set errorbells # Beep or flash screen on errors
set visualbell # Use visual bell (no beeping)

set hlsearch # Highlight all search results
set smartcase # Enable smart-case search
set gdefault # Always substitute all matches in a line
set ignorecase # Always case-insensitive
set incsearch # Searches for strings incrementally

set autoindent # Auto-indent new lines
set cindent # Use 'C' style program indenting
set expandtab # Use spaces instead of tabs
set shiftwidth=4 # Number of auto-indent spaces
set smartindent # Enable smart-indent
set smarttab # Enable smart-tabs
set softtabstop=4 # Number of spaces per Tab

set confirm # Prompt confirmation dialogs
set ruler # Show row and column ruler information
set showtabline=2 # Show tab bar

set autochdir # Change working directory to open buffer
set autowriteall # Auto-write all file changes

set undolevels=1000 # Number of undo levels
set backspace=indent,eol,start # Backspace behaviour

ファイアウォールと SELinux を構成する

Firewalld は CentOS 7 にデフォルトでインストールされていますが、システムにインストールされていない場合は、次のように入力してパッケージをインストールできます。

[root@thehackertips ~]# sudo yum install firewalld 

FirewallD サービスを開始して有効にするには:

[root@thehackertips ~]# sudo systemctl start firewalld  
[root@thehackertips ~]# sudo systemctl enable firewalld 

Centos7 のファイアウォールのステータスを確認するには:

[root@thehackertips ~]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)
   Active: active (running) since Mon 2019-10-21 07:01:17 EDT; 55min ago
 Main PID: 581 (firewalld)
   CGroup: /system.slice/firewalld.service
           ââ581 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Oct 21 07:01:17 thehackertips.com systemd[1]: Started firewalld - dynamic fi....
Hint: Some lines were ellipsized, use -l to show in full.
[root@thehackertips ~]# getenforce
Enforcing
[root@thehackertips ~]# 

以下のように停止して無効にすることができます。

[root@thehackertips ~]# sudo systemctl stop firewalld  
[root@thehackertips ~]# sudo systemctl disable firewalld

最もよく使用されるファイアウォール コマンドは次のとおりです:

[root@thehackertips ~]# firewall-cmd --get-default-zone  # display default zone
[root@thehackertips ~]# firewall-cmd --list-all # display current setting of default zone
[root@thehackertips ~]# firewall-cmd --set-default-zone=external # change default zone
[root@thehackertips ~]# firewall-cmd --get-services # get a list of the available services
# show allowed services on a specific zone
[root@thehackertips ~]# firewall-cmd --list-service --zone=internal
dhcpv6-client ipp-client mdns samba-client ssh
[root@thehackertips ~]# firewall-cmd --list-service --zone=external
ssh
[root@thehackertips ~]# firewall-cmd --list-service --zone=public
dhcpv6-client ntp ssh

[root@thehackertips ~]# firewall-cmd --add-service=https #Adding a Service to your Zones
[root@thehackertips ~]# firewall-cmd --remove-service=https #Remove a Service to your Zones

#For adding service permanently use command like below and reload the firewall
[root@thehackertips ~]# firewall-cmd --add-service=http --permanent
[root@thehackertips ~]# firewall-cmd --reload
# Opening ro removing a Port for your Zones
[root@thehackertips ~]# firewall-cmd --add-port=25/tcp
[root@thehackertips ~]# firewall-cmd --remove-port=25/tcp
[root@thehackertips ~]# firewall-cmd --add-port=25/tcp --permanent
[root@thehackertips ~]# firewall-cmd --reload

SELinux – Security-Enhanced Linux は、カーネルに実装されている強制アクセス制御 (MAC) セキュリティ メカニズムです。操作には 3 つの基本モードがあり、そのうち Enforcing がインストールのデフォルト モードとして設定されています。

  • 強制:システムで SELinux セキュリティ ポリシーを有効にして強制し、アクセスを拒否してアクションをログに記録するデフォルト モード
  • Permissive:Permissive モードでは、SELinux が有効になりますが、セキュリティ ポリシーは適用されず、警告とログ アクションのみが実行されます。 Permissive モードは、SELinux の問題のトラブルシューティングに役立ちます
  • 無効:SELinux がオフになっています

sestatus を使用できます または getenforce 現在の SELinux ステータスを表示するコマンド:

[root@thehackertips ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28


[root@thehackertips ~]# getenforce
Enforcing

SELinux オープン構成ファイルを無効にし、enforcing を無効に変更してからサーバーを再起動する場合:

[root@thehackertips ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@thehackertips ~]# reboot

Linux
  1. CentOSでMariaDBサーバーを構成する

  2. Centos 7 :インストール、構成、管理

  3. Ubuntu 19.04 :vim を構成する

  1. CentOS8でVSFTPDを設定する方法

  2. Centos 7 :DNS サーバーの構成

  3. Centos 7:vim を構成する

  1. LinuxでVimをデフォルトのエディターとして設定する方法

  2. CentOS7でOpenSSHを構成する方法

  3. CentOS7でFirewallDを設定する