ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

Files and text: a summary of the essential commands, vim

Lesson 1.48 minBeginnerDecember 1, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • Navigation and files: pwd, cd -, ls -lah, cp -a, mv, rm -i, mkdir -p, ln -s, find / -name ... 2>/dev/null.
  • Text: grep -rn, head/tail -f, wc -l, sort | uniq -c, cut -d: -f1, sed -i.
  • Redirection: >, >>, 2>, &>, |, tee; to write to a root-owned file use | sudo tee -a.
  • On RHEL vi is actually vim (vim-minimal); nano may be missing on a minimal installation.
  • vim: i type, Esc, :wq save, :q! discard; /word search, dd delete line, u undo, :set nu line numbers.

The essential commands in one table

JobCommandNote
Where am Ipwd
Go back to the previous directorycd -
Hidden files and sizesls -lah
Create a directory treemkdir -p /srv/app/{logs,conf}{} creates several names
Copy keeping permissions and datescp -a source target-a = archive
Symbolic linkln -s /srv/app/conf /etc/app
Find a filefind /etc -name "*.conf" -mmin -60changed in the last 60 minutes
Find large filesfind / -size +500M 2>/dev/nulldiscard errors
Find a word (in a directory)grep -rn "Listen" /etc/httpd/-n line numbers
Follow a log livetail -f /var/log/messageson RHEL messages, not syslog
Countgrep -c Failed /var/log/secureon RHEL secure, not auth.log
Cut columnscut -d: -f1,7 /etc/passwd
Most repeatedsort, then uniq -c, then sort -rnjoined with pipes
Replace in a filesed -i 's/old/new/' filecheck without -i first

Log names differ on RHEL: Ubuntu's /var/log/syslog is /var/log/messages here, and /var/log/auth.log is /var/log/secure. RHCSA tasks often test this.

Redirection and root-owned files

srv-web01
[ali@srv-web01 ~]$ find /etc -name "*.repo" > ~/repolar.txt 2> ~/sehvler.txt
[ali@srv-web01 ~]$ sudo grep -c "Failed password" /var/log/secure
3
[ali@srv-web01 ~]$ echo "10.20.0.20 srv-db01" | sudo tee -a /etc/hosts
10.20.0.20 srv-db01

sudo echo ... >> /etc/hosts does not work — the redirection is done by your shell, not by root. That is why | sudo tee -a is used.

The editor on RHEL: vim

A minimal RHEL installation may not have nano, but vi is always there (the vim-minimal package). For full vim (with syntax colouring): sudo dnf install -y vim-enhanced.

The minimum to remember:

Mode / commandWhat it does
iInsert mode — start typing
EscBack to Normal mode
:w / :wq / :q!Save / save and quit / quit without saving
/word, nSearch, next
dd, yy, pDelete, copy, paste a line
u, Ctrl+RUndo, redo
gg, G, :25Start of file, end, line 25
:set nuLine numbers
:%s/old/new/gReplace in the whole file
oNew line below and start typing

Changing a configuration file safely

A working habit — every configuration change in these four steps:

srv-web01
[ali@srv-web01 ~]$ sudo cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
[ali@srv-web01 ~]$ sudo vim /etc/ssh/sshd_config
[ali@srv-web01 ~]$ sudo sshd -t
[ali@srv-web01 ~]$ sudo systemctl reload sshd
  1. A backup (cp -a keeps permissions and the SELinux context).
  2. The edit.
  3. The service's own syntax check (sshd -t, httpd -t, nginx -t).
  4. reload — only after the check passes.

diff is useful to see what you changed: sudo diff /etc/ssh/sshd_config.bak /etc/ssh/sshd_config.

Lab: files and vim

In the Red Hat simulator (your own VM for the vim part), on srv-web01:

  1. Create the /srv/app/{logs,conf} tree with one command and check with ls -R /srv/app.
  2. Find the files under /etc ending in .repo, send the list to ~/repolar.txt and errors to /dev/null.
  3. Count failed login attempts in /var/log/secure.
  4. Add srv-db01 to /etc/hosts with tee -a and check with ping -c 1 srv-db01.
  5. (On your own VM) open vim ~/qeyd.txt, type three lines, look at the numbers with :set nu, delete the second line with dd, save with :wq.
srv-web01
[ali@srv-web01 ~]$ sudo mkdir -p /srv/app/{logs,conf}
[ali@srv-web01 ~]$ find /etc -name "*.repo" > ~/repolar.txt 2>/dev/null
[ali@srv-web01 ~]$ sudo grep -c "Failed password" /var/log/secure
[ali@srv-web01 ~]$ ping -c 1 srv-db01

Check: ls /srv/app → conf logs; cat ~/repolar.txt is not empty; ping srv-db01 answers.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1On RHEL, which file stores failed SSH logins?

The RHEL equivalent of Ubuntu's auth.log.

2Which editor is always present on a minimal RHEL installation?

For full vim, install the vim-enhanced package.

3Why does sudo echo "x" >> /etc/hosts not work?

The fix: echo "x" | sudo tee -a /etc/hosts.

4How does cp -a differ from plain cp?

-a is archive mode.

5What is done after changing a configuration file and before reloading?

A broken configuration can stop the service.
Was this lesson useful?

Comments

Sign in to comment.