GNU/Linux >> Tutoriels Linux >  >> Linux

Centos 7 :Configurer vim

Vim est un éditeur de texte en ligne de commande puissant et open source. Le fichier de configuration de Vim se trouve dans /etc/vimrc. Nous devons d'abord installer l'éditeur de test VIM, puis ouvrir le fichier de configuration pour appliquer le paramètre que vous souhaitez :

[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

Configurer le pare-feu et SELinux

Firewalld est installé par défaut sur CentOS 7, mais s'il n'est pas installé sur votre système, vous pouvez installer le package en tapant :

[root@thehackertips ~]# sudo yum install firewalld 

Pour démarrer le service FirewallD et l'activer :

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

Pour vérifier l'état du pare-feu sur 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 ~]# 

il est possible de l'arrêter et de le désactiver comme ci-dessous.

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

Les commandes de pare-feu les plus utilisées sont les suivantes :

[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 est un mécanisme de sécurité de contrôle d'accès obligatoire (MAC) implémenté dans le noyau. Il existe trois modes de fonctionnement de base, parmi lesquels l'application est définie comme mode d'installation par défaut.

  • Application :le mode par défaut qui activera et appliquera la politique de sécurité SELinux sur le système, en refusant l'accès et en enregistrant les actions
  • Permissif :en mode Permissif, SELinux est activé mais n'appliquera pas la politique de sécurité, uniquement les actions d'avertissement et de journalisation. Le mode permissif est utile pour résoudre les problèmes de SELinux
  • Désactivé :SELinux est désactivé

Vous pouvez utiliser sestatus ou getenforce commande pour afficher l'état actuel de 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

Si vous souhaitez désactiver le fichier de configuration ouvert SELinux et modifier l'application sur désactivé, puis redémarrez le serveur :

[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. Comment configurer Vim comme éditeur par défaut sous Linux

  2. Comment configurer OpenSSH sur CentOS 7

  3. Configurer le serveur MariaDB sur CentOS

  4. Centos 7 :Installer, Configurer, Gérer

  5. Ubuntu 19.04 :Configurer vim

Comment utiliser Ansible pour configurer Vim

Comment installer et configurer GlusterFS sur CentOS 7/CentOS 8

Comment configurer un serveur TeamSpeak sur CentOS 7

Comment configurer NGINX sur un serveur CentOS 7

Comment configurer GitLab sur CentOS 8

Centos 7 :Configurer le serveur NTP