Uninstalling & Reinstalling Apache2 On Ubuntu 22.04

To uninstall Apache2 on Ubuntu 22.04

$ sudo apt-get purge apache2

Reinstall Apache2 on Ubuntu 22.04

$ sudo apt-get install apache2

Make sure that Apache2 has been correctly installed and is working

$ systemctl status apache2.service

Clear The Node Repl or Console

Node JS is a JavaScript server-side runtime. It can read and write to disk, process text streams and more. Node also includes its own package manager, npm (Node Package Manager), which makes it easy for developers to install third party modules that extend the functionality of their application or provide additional features without managing dependencies manually.

“how to clear screen in node js command prompt” is a question that has been asked many times before. The answer is as follows: “To clear the console, use Ctrl+L.”

Source

Find Command On Linux

The find command in UNIX is a command line utility for walking a file hierarchy. It can be used to find files and directories and perform subsequent operations on them. It supports searching by file, folder, name, creation date, modification date, owner and permissions. By using the ‘-exec’ other UNIX commands can be executed on files or folders found. 

$ find [where to start searching from]
 [expression determines what to find] [-options] [what to find]

Options :

  • -exec CMD: The file being searched which meets the above criteria and returns 0 for as its exit status for successful command execution.
  • -ok CMD : It works same as -exec except the user is prompted first.
  • -inum N : Search for files with inode number ‘N’.
  • -links N : Search for files with ‘N’ links.
  • -name demo : Search for files that are specified by ‘demo’.
  • -newer file : Search for files that were modified/created after ‘file’.
  • -perm octal : Search for the file if permission is ‘octal’.
  • -print : Display the path name of the files found by using the rest of the criteria.
  • -empty : Search for empty files and directories.
  • -size +N/-N : Search for files of ‘N’ blocks; ‘N’ followed by ‘c’can be used to measure size in characters; ‘+N’ means size > ‘N’ blocks and ‘-N’ means size < ‘N’ blocks.
  • -user name : Search for files owned by user name or ID ‘name’.
  • \(expr \) : True if ‘expr’ is true; used for grouping criteria combined with OR or AND.
  • ! expr : True if ‘expr’ is false.

Source

When Unsure Of Name Use Wildcard Patterns To Look For A File

To look for a file with a wildcard pattern it may be useful to wrap pattern in single quotes. If you are looking for a file with a .pdf extension, try:

$ find / -name '*.pdf'

Source

When You Need To Search An Entire Hard Drive

A simple find / -type f -name "" would do the trick if you know exact filename.

find / -type f -iname "filename*" if you want to match more files (ignore case).

Avoid -type option if you want to search for directories etc.

This will also search all mounted devices as well, might want to just search /mount/hddyouwanttosearch

note that one might wish to add sudo ahead of the mentioned command

Source

LS Command ::: How to list files and directories with directories first

Got GNU?

The gnu version of ls has --group-directories-first. And cp has -t.

No GNU?

On systems that don’t have gnu’s ls, your best bet is two successive calls to find with -maxdepth n/-mindepth n and -type t with the appropriate options.

find . -maxdepth 1 -mindepth 1 -type d
find . -maxdepth 1 -mindepth 1 \! -type d

For copying files, with the target first, you would have to write a script that saves the first argument, then uses shift, and appends the argument to the end.

#!/bin/sh
target="$1"
shift
cp -r -- "$@" "$target"

Source

How Do I Update Linux Software On Ubuntu From Command Line?

Use this:

sudo apt update        # Fetches the list of available updates
sudo apt upgrade       # Installs some updates; does not remove packages
sudo apt full-upgrade  # Installs updates; may also remove some packages, if needed
sudo apt autoremove    # Removes any old packages that are no longer needed

Documentation about each apt option can be found in the the manpages for apt. These are also available by running man apt in your terminal.

Use of both upgrade and full-upgrade together is usually not needed, but it may help in some cases: see Debian documentation about Upgrades from Debian 9.

Source