Using Scrcpy On Linux With Wireless

$ adb kill-server
$ adb tcpip 5555
$ adb connect {phone IP address}:5555
$ adb devices

After adb devices, make sure the phone shows up twice, once for the USB connection and once for the WiFi connection, which will list your IP address. If the connections are not showing, then adb is not connecting – your phone may be blocking it. If you have the WiFi connection showing, unplug the phone from the USB and enter the following:

$ scrcpy


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

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.


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'


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


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.


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.

cp -r -- "$@" "$target"


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.


nmap on Ubuntu

Installing nmap on Ubuntu

In order to install nmap on Ubuntu, we will be using these commands at terminal:

$ sudo apt-get install nmap

Simple Scanning With nmap on Ubuntu

In terminal of your choosing, type(you should use your own ip address or ip address of network you wish to scan):

$ sudo nmap -sn

Whatever ip address you have must be followed by ‘/24’. It also helps to change last number to ‘0’. That will give us first possible ip address on that network. Using ‘/24’ informs our computer to scan from ip address ‘’ until it reaches and scans ‘’.

Diving Deeper Scanning With nmap on Ubuntu

If we remove our ‘-sn’ option, we can use nmap to scan ports on all of those devices we found above.


$ sudo nmap

Aggressively Scanning With nmap On Ubuntu

$ sudo nmap -A -T4

In this line of code, ‘-A’ option acts as an aggressive scan. This runs nmap’s operating system detection, version detection, script scanning, and traceroute detection.

There is a timing template set by ‘-T’ flag. From 0 to 5, we can chose to run nmap in one of these timing modes. Each timing mode is interestingly named:

  • (0) Paranoid
  • (1) Sneaky
  • (2) Polite
  • (3) Normal
  • (4) Agressive
  • (5) Insane


How to Compress PDF on Linux With Ghostscript [Terminal]

You can use Ghostscript command line tool for compressing a PDF file. Most Linux distributions include the open source version of Ghostscript already. However, you can still try to install it just to make sure.

On Debian/Ubuntu based distributions, use the following command to install Ghostscript:

sudo apt install ghostscript

Now that you have made sure that Ghostscript is installed, you can use the following command to reduce the size of your PDF file:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_PDF_file.pdf input_PDF_file.pdf

In the above command, you should add the correct path of the input and out PDF file.

The command looks scary and confusing. I advise copying and pasting most of it. What you need to know is the dPDFSETTINGS parameter. This is what determines the compression level and thus the quality of your compressed PDF file.

/prepress (default)Higher quality output (300 dpi) but bigger size
/ebookMedium quality output (150 dpi) with moderate output file size
/screenLower quality output (72 dpi) but smallest possible output file size

Do keep in mind that some PDF files may not be compressed a lot or at all. Applying compression on some PDF files may even produce a file bigger than the original. There is not much you can do in such cases.