GNU/Linux >> Belajar Linux >  >> Linux

Ubuntu 19.04 :Konfigurasikan vim

Vim adalah editor teks baris perintah yang kuat dan open source. File konfigurasi untuk Vim ada di /etc/vimrc. Pertama Kita perlu menginstal editor uji VIM, kemudian buka file konfigurasi untuk menerapkan pengaturan yang Anda inginkan (untuk menerapkan konfigurasi ke semua sistem, Anda perlu melakukan hal yang sama pada /etc/vim/vimrc):

root@thehackertips:~# apt install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
vim-common vim-runtime vim-tiny
Suggested packages:
ctags vim-doc vim-scripts indent
The following packages will be upgraded:
vim vim-common vim-runtime vim-tiny
4 upgraded, 0 newly installed, 0 to remove and 122 not upgraded.
Need to get 7,378 kB of archives.
After this operation, 4,096 B disk space will be freed.
Do you want to continue? [Y/n]
Get:1 http://us.archive.ubuntu.com/ubuntu disco-updates/main amd64 vim amd64 2:8.1.0320-1ubuntu3.1 [1,180 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu disco-updates/main amd64 vim-tiny amd64 2:8.1.0320-1ubuntu3.1 [505 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu disco-updates/main amd64 vim-runtime all 2:8.1.0320-1ubuntu3.1 [5,609 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu disco-updates/main amd64 vim-common all 2:8.1.0320-1ubuntu3.1 [84.4 kB]
Fetched 7,378 kB in 13s (559 kB/s)
(Reading database … 66699 files and directories currently installed.)
Preparing to unpack …/vim_2%3a8.1.0320-1ubuntu3.1_amd64.deb …
Unpacking vim (2:8.1.0320-1ubuntu3.1) over (2:8.1.0320-1ubuntu3) …
Preparing to unpack …/vim-tiny_2%3a8.1.0320-1ubuntu3.1_amd64.deb …
Unpacking vim-tiny (2:8.1.0320-1ubuntu3.1) over (2:8.1.0320-1ubuntu3) …
Preparing to unpack …/vim-runtime_2%3a8.1.0320-1ubuntu3.1_all.deb …
Unpacking vim-runtime (2:8.1.0320-1ubuntu3.1) over (2:8.1.0320-1ubuntu3) …
Preparing to unpack …/vim-common_2%3a8.1.0320-1ubuntu3.1_all.deb …
Unpacking vim-common (2:8.1.0320-1ubuntu3.1) over (2:8.1.0320-1ubuntu3) …
Setting up vim-common (2:8.1.0320-1ubuntu3.1) …
Setting up vim-runtime (2:8.1.0320-1ubuntu3.1) …
Setting up vim (2:8.1.0320-1ubuntu3.1) …
Setting up vim-tiny (2:8.1.0320-1ubuntu3.1) …
Processing triggers for mime-support (3.60ubuntu1) …
Processing triggers for man-db (2.8.5-2) …
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

Konfigurasi Firewall dan SELinux

Firewalld diinstal secara default di Ubuntu 19.04, tetapi jika tidak diinstal pada sistem Anda, Anda dapat menginstal paket dengan mengetik:

root@thehackertips:~# apt install firewalld

Untuk memulai layanan Firewalld dan mengaktifkannya:

root@thehackertips:~# systemctl start firewalld
root@thehackertips:~# systemctl enable firewalld
Synchronizing state of firewalld.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable firewalld
root@thehackertips:~#

Untuk memeriksa status Firewall di Ubuntu 19.04:

root@thehackertips:~# systemctl status firewalld
â firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-11-04 06:32:50 EST; 2min 47s ago
Docs: man:firewalld(1)
Main PID: 5034 (firewalld)
Tasks: 2 (limit: 1096)
Memory: 20.6M
CGroup: /system.slice/firewalld.service
ââ5034 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid

Nov 04 06:32:50 thehackertips.com systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 04 06:32:50 thehackertips.com systemd[1]: Started firewalld - dynamic firewall daemon.
root@thehackertips:~#

mungkin untuk menghentikan dan menonaktifkannya seperti di bawah ini.

root@thehackertips:~# systemctl stop firewalld
root@thehackertips:~# systemctl disable firewalld
Synchronizing state of firewalld.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
root@thehackertips:~#

Perintah firewall yang paling sering digunakan sebagai berikut:

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 – Linux yang Ditingkatkan Keamanan adalah mekanisme keamanan kontrol akses wajib (MAC) yang diterapkan di kernel. Ada tiga mode operasi dasar, di mana Penegakan ditetapkan sebagai mode default instalasi.

  • Menegakkan:Mode default yang akan mengaktifkan dan menerapkan kebijakan keamanan SELinux pada sistem, menolak akses dan tindakan pencatatan
  • Permissive:Dalam mode Permissive, SELinux diaktifkan tetapi tidak akan menerapkan kebijakan keamanan, hanya memperingatkan dan mencatat tindakan. Mode permisif berguna untuk memecahkan masalah SELinux
  • Dinonaktifkan:SELinux dimatikan

Untuk menginstal SELinux:

root@thehackertips:~#  apt install selinux-utils policycoreutils

Anda dapat menggunakan perintah sestatus atau getenforce untuk melihat status SELinux saat ini:

root@thehackertips:~# sestatus
SELinux status: disabled
root@thehackertips:~# getenforce
Disabled
root@thehackertips:~#

Jika Anda ingin menonaktifkan SELinux, buka file konfigurasi dan ubah penegakan menjadi nonaktif, lalu restart server.

root@thehackertips:~# vi /etc/selinux/config

Linux
  1. Bagaimana saya mengonfigurasi Vim sebagai editor default saya di Linux

  2. OpenStack Kilo di Ubuntu 14.04.2 – Konfigurasi Nova

  3. OpenStack Kilo di Ubuntu 14.04.2 – Konfigurasi Sekilas

  1. Instal pgAdmin 4 di Ubuntu 16.04

  2. Cara Mengonfigurasi Firewall UFW di Ubuntu 18.04

  3. Centos 7:Konfigurasikan vim

  1. Cara Menginstal Vim 8.2 di Ubuntu 18.04

  2. Cara Mengonfigurasi Alamat IP Statis di Ubuntu 18.04

  3. OpenStack Kilo di Ubuntu 14.04.2 – Konfigurasi Neutron #1