Find out your local IP address
The easiest way to find out your local IP address is to type the following command
Which will show you output similar to the below
Screenshot above shows the local IP address of eth0, which means that my Raspberry is connected via an ethernet cable to my router and the local IP address is 192.168.0.129
If you have more than one connection method, like Pi 4B has, both ethernet port and Wi-Fi, then all methods that are active will be listed, even if they are not used at the moment. You will simply see a connection that is not active, but ready.
- eth0 – cable connection
- wlan – Wi-Fi connection
- lo – local connection, ignore for now
Better search engine for package repository
Default apt search functionality is not that great. With xapian indexing you can extend the search functionality.
Install it with the following command
sudo apt install apt-xapian-index
Rebuild your package repository and update xapian index with
sudo apt update sudo update-apt-xapian-index
Now you can use axi-cache command to browse your repository with the following
axi-cache search $search_term
If you want to learn how to refine your search run
Check installed packages
If you want to see what packages you have installed on your system, run the following command
apt list --installed
If you want to search the list for a particular package you have to pipe the result to a different command – grep.
In order to check if you have apache2 package installed run the following command
apt list --installed | grep apache2
You can substitute apache2 with any string to search for a different package
Using a pipe
Pipeing is done by using the character |, this is not an uppercase i nor it is a lowercase l. It is a separate symbol on your keyboard. A vertical line. Look for it around the enter key.
It basically passes the standard output of a command on its left to a command on its right. Look at the following code
command1 | command2
This takes the standard output (a result) of command1 and passes it as an attribute to command2. It might not seem like much, but consider a example of browsing for installed packages above, I included it first for a reason.
You could list all packages that you have installed on your machine and manually look through it for a specific one or pass the output to grep command so that it shows only what you are looking for, or nothing as this is also information. Remember that lack of information IS the information as well – you have to judge for yourself.
Now consider a file with a list. Let’s say 200-something lines and this time you only know that it starts with some letter combination. Do you really want to look through the whole file or do you want to
cat file_name | grep xyz | sort
to search the file file_name for the string xyz and have the output neatly sorted alphabetically? Exactly. Pipes are great, learn to use them.
See who logged in recently
Logs provide a lot of useful information. They should be your go-to place for troubleshooting, as they will tell you what errors are present and what to look for online. One more use of logs is to see who managed to log in, and when. The following log file contains both failed and successful login attempts
Unfortunately output is usually quite long, as it records bots that try to access your server using logins and passwords from the most commonly used lists. To filter out successful logins run the following
sudo cat /var/log/auth.log | grep "Accepted password"