GNU/Linux


How to monitor all outgoing requests/connections from your GNU/Linux machine

netstat -nputw;

The “netstat” command is a network utility tool used to display information about active network connections, including the protocol used (TCP or UDP), the local and remote addresses and port numbers, and the current state of the connection.

The options used in this command are as follows:

  • “n” displays addresses and port numbers in numerical form rather than converting them to hostnames and service names.
  • “p” shows the process ID (PID) and program name using the connection.
  • “u” displays UDP connections.
  • “t” displays TCP connections.
  • “w” displays raw sockets.
  • “;” separates the command from other commands that may follow.

Therefore, the command netstat -nputw; will display all current network connections on the machine, including the corresponding processes and raw socket connections, in a numerical format without resolving hostnames and service names.


Mount a Windows share on a GNU/Linux server

sudo mount -t cifs //$WINDOWS_FILE_SERVER/$SHARED_FOLDER /var/www/bytefreaks.net/shared/ -o username=remoteUser,password='123abc',domain=bytefreaks.net,file_mode=0777,dir_mode=0777;

The command sudo mount -t cifs //$WINDOWS_FILE_SERVER/$SHARED_FOLDER /var/www/bytefreaks.net/shared/ -o username=remoteUser,password='123abc',domain=bytefreaks.net,file_mode=0777,dir_mode=0777 is used to mount a shared folder from a Windows file server onto a Linux system.

To break down the command further, here is a detailed explanation of each component:

sudo – this command is used to run the following command as a superuser or root. It is required in this instance as mounting requires administrative privileges.

mount – the mount command is used to mount a file system onto a directory in the Linux file system hierarchy.

-t cifs – this option specifies the type of file system that is being mounted. In this case, it is the Common Internet File System (CIFS), which is used for file sharing between Windows and Linux systems.

//$WINDOWS_FILE_SERVER/$SHARED_FOLDER – this is the network path to the shared folder on the Windows file server. The $WINDOWS_FILE_SERVER and $SHARED_FOLDER are placeholders for the actual Windows file server name and shared folder name, respectively.

/var/www/bytefreaks.net/shared/ – this is the mount point, or the location in the Linux file system hierarchy where the shared folder will be mounted.

-o username=remoteUser,password='123abc',domain=bytefreaks.net,file_mode=0777,dir_mode=0777 – these are the mount options that are specified when mounting the shared folder.

The username option specifies the username of the remote user that has access to the shared folder. In this case, the remote user is named remoteUser.

The password option specifies the password for the remote user.

The domain option specifies the domain or workgroup that the Windows file server belongs to. In this case, the domain is bytefreaks.net.

The file_mode and dir_mode options specify the permissions that should be set on the files and directories within the mounted shared folder. In this case, both are set to 0777, which means that all users have full read, write, and execute permissions on all files and directories within the mounted shared folder.

In summary, the sudo mount -t cifs //$WINDOWS_FILE_SERVER/$SHARED_FOLDER /var/www/bytefreaks.net/shared/ -o username=remoteUser,password='123abc',domain=bytefreaks.net,file_mode=0777,dir_mode=0777 command is used to mount a shared folder from a Windows file server onto a Linux system with the specified mount options.


How to empty the gnome tracker3 cache?

To empty the cache of gnome tracker3, you can follow the steps below:

Open a terminal window by pressing Ctrl + Alt + T.

Type the following command to stop the tracker daemon:

tracker3 daemon -t;

Type the following command to clear the tracker database:

tracker reset --filesystem;

This command will remove all indexed data from the tracker and clear its cache. (Remove filesystem indexer database)

Restart the tracker daemon by typing the following command:

tracker daemon -s ;

This will start the tracker daemon again, and it will begin to rebuild its database and cache.

After following these steps, the cache of gnome tracker3 will be emptied.

Execution example:

$ tracker3 daemon -t
Found 1 PID…
  Killed process 13705 — “tracker-miner-fs-3”
$ tracker3 reset --filesystem
Found 1 PID…
  Killed process 13705 — “tracker-miner-fs-3”
$ tracker3 daemon -s
Starting miners…
  ✓ File System

Compressing mysqldump with pipe: MySQL

When working with MySQL databases, it’s common to create backups of the database using the mysqldump utility. However, these backups can often take up a significant amount of disk space, especially for large databases. One way to reduce the size of these backups is to compress them using a compression algorithm. In this post, we will explore how to compress a mysqldump using a pipe.

First, let’s review the basic syntax for creating a mysqldump:

mysqldump -u [username] -p [database_name] > [backup_file].sql

This command will create a plain-text backup file of the specified database, which can then be restored using the mysql command. However, this backup file can be quite large, especially for large databases.

To compress the backup file, we can use a pipe to redirect the output of the mysqldump command to a compression utility. One common compression utility is gzip, which uses the gzip algorithm to compress files. Here’s how we can use gzip to compress the mysqldump:

mysqldump -u [username] -p [database_name] | gzip > [backup_file].sql.gz

In this command, we use the | symbol to pipe the output of the mysqldump command to the gzip command. The > symbol is then used to redirect the compressed output to a file with a .sql.gz extension.

The resulting backup file will be compressed using the gzip algorithm, which typically results in significant reduction in file size. To restore the backup, we can use the following command:

gunzip < [backup_file].sql.gz | mysql -u [username] -p [database_name]

In this command, we use the gunzip command to decompress the compressed backup file, which is then piped to the mysql command to restore the database.

In conclusion, compressing a mysqldump using a pipe is a simple and effective way to reduce the size of backup files. By using a compression utility such as gzip, we can significantly reduce the amount of disk space required to store backups, while still being able to restore the database using standard MySQL commands.