Let's learn: logrotate!

Logrotate is a system utility that manages the automatic rotation and compression of log files. 1 2 logrotate --version man logrotate Configuration can be found generally in two places: /etc/logrotate.conf: contain some default settings, sets up rotation for a few logs that are not owned by any system packages. Also uses an include statement to pull in configuration from any file from the logrotate directory. /etc/logrotate.d: files for packages. By default, logrotate.confwill configure weekly log rotations, with log files owned by the root user and the syslog group., with four log files being retained at a time (rotate 4) and new empty log files being created after the current one is rotated (create). ...

May 10, 2023 · Loknath Dhar

Let's learn: journalctl!

jounralctl is the command line tool that let us interact with the journal logs. Default location of journald logs is /var/log/journal directory. Type journalctl in the terminal, it will show the journal logs in chronological order. journalctl --no-pager will display entire logs directly on the screen. journalctl -n 25: will display most recent 25 lines of the logs. journalctl -f: view logs in real time. jouralctl --utc: display logs in UTC time. journalctl -k: display only kernel logs. All Journal logs Use sudo to see all journal logs. ...

April 30, 2023 · Loknath Dhar

Let's learn: systemctl!

Service management 1 2 3 4 5 6 7 8 9 10 11 12 13 sudo systemctl start app.service sudo systemctl stop app.service sudo systemctl restart app.service sudo systemctl reload app.service sudo systemctl reload-or-restart app.service sudo systemctl enable app.service sudo systemctl disable app.service Checking status 1 2 3 4 5 6 7 systemctl status app.service systemctl is-active app.service systemctl is-enabled app.service systemctl is-failed app.service System state overview 1 2 3 4 5 6 7 8 9 10 # see a list of active units systemctl list-units systemctl # returns same as above systemctl list-units --all systemctl list-units --all --state=inactive systemctl list-units --type=service To see every available units in the system paths (including those that systemd has not attempted to load): ...

March 20, 2023 · Loknath Dhar

Let's learn: Vim/NeoVim!

Syntax: vim filename. Movement Navigating h /j/k/l : C-U/C-D : half-page up/down. C-B/C-F : page up/down. H : move to top of the screen. M : move to middle of the screen. L : move to bottom of the screen. Words b/w : previous/next word. ge/e : previous/next end of word. gj : move cursor down (multi-line text). gk : move cursor up (multi-line text). Line $ : to the end of the line (including last character). ...

February 8, 2023 · Loknath Dhar

Let's learn: Wildcards!

Wildcards (also known as globbing) allows us to select filenames based on patterns of characters. Wildcard Meaning * matches any character ? matches any single character [characters] matches any character that is a member of the set characters [!characters] matches any character that is not a member of the set characters [[:class:]] matches any character that is a member of the specified class Commonly used character classes: ...

January 18, 2023 · Loknath Dhar

Let's learn: grep!

grep: Global Regular Expression print. grep is a powerful program used to find text patterns within files. It uses regular expressions (shortly regex) to match the pattern. When grep encounters a pattern in the file, it prints out the lines containing it. If no file is given, it will search recursively search the given pattern in the files in current directory. 1 2 3 grep pattern [file...] grep <search-pattern> file.txt To show the line number in the output, use -n option: 1 grep -n <search-pattern> file.txt grep is case-sensitive. ...

December 13, 2022 · Loknath Dhar

Let's learn: less!

The less command is a program to view text files. Example: 1 2 3 less filename less /etc/passwd Some action commands for less: Command Action Page Up or b Scroll back one page Page Down or space Scroll forward one page Up Arrow Scroll up one line Down Arrow Scroll down one line G Move to the end of the text file g or 1G Move to the beginning of the text file /characters search forward to the next occurrence of characters n search for the next occurrence of the previous search h display help screen q quit less less is more ...

November 13, 2022 · Loknath Dhar

Let's learn: man pages!

man - display a program’s manual page. 1 man program # program is the name of the command On most Linux systems, man uses less to display manual page. The manual that man displays is broken into sections and covers not only user commands but also system administration commands, programming interfaces, file formats and more. Man page organization: Section Contents 1 user commands 2 programming interfaces for kernel system calls 3 programming interfaces to the C library 4 special files such as device nodes and drivers 5 file formats 6 games and amusements such as screen savers 7 Miscellaneous 8 System administration commands 9 Obscure kernel specs and interfaces 1 2 3 man section search_item man 5 passwd Refer to a specific section of the manual to find what we are looking for. ...

October 13, 2022 · Loknath Dhar

Let's learn: Terminal Shortcuts!

To enter virtual consoles: Ctrl+Alt+F1 to Ctrl+Alt+F6 Switch from one to another console: Alt+F1 to Alt+F6 To return to the graphical desktop: Alt+F7 command meaning Ctrl+a beginning of the line Ctrl+c kill process/stop running Ctrl+d ending terminal session Ctrl+e end of line Ctrl+k cut from cursor to the end of line Ctrl+l clear screen Ctrl+u cut from cursor to the beginning of line Ctrl+w erase word from cursor to begin Ctrl+y get back from last cut text Ctrl+z froze the program/pause Alt+b backward one word Alt+d cut from cursor to end of word Alt+f forward one word Alt+backspace cut from cursor to beginning of the word Ctrl+shift+c copy from terminal Ctrl+shift+v paste on terminal

July 23, 2022 · Loknath Dhar