Easy file sharing with Python SimpleHTTPServer

An easy way to share files from your computer is to use Python SimpleHTTPServer. You don’t need to know Python programming to use the SimpleHTTPServer, the only requirement is to have Python installed on the machine where the files that needs to be shared are located.

Most Linux distributions are shipped with Python installed by default, but for Windows you might need to check how to use Python on Windows.

To start the SimpleHTTPServer “cd” into the directory which you want to be shared and run the command:

python -m SimpleHTTPServer 8000

You need to specify a port, usually 8000, like in the example should be just fine.
To access the shared files o to http://your_ip_address:8000.

Display banner text in command line

You can display banner-like texts with large characters created from regular characters using the FIGlet utility.

The default output look like this (quotes are optional):

FIGlet banner text

Basic usage requires only the text you want to output on the CLI, but you can also specify the font used in text rendering, dimensions and other layout options.

Disk management in Linux

If you need to manage your disk or just check the disk space usage of a Linux powered computer, here are some suggestions for both graphical and command line interfaces.

Desktop applications for disk management:

File mangers: in a modern Linux desktop environment checking disk usage is a trivial task. The file managers, default ones like Nautilus in Gnome, Dolphin in KDEThunar in XFCE or other popular file managers like Gnome Commander, Tux Commander, Krusader can display disk space with just a few mouse clicks.

Gnome System Monitor – has a “File Systems” tab which gives you a quick overview over your file systems in terms of mount points, file systems types (ext3, ext4, etc.), disk space.

KDiskFree – similar with the Gnome System Monitor – File Systems, but since this is a part of the KDE desktop it might be preferred over the mentioned Gnome application.

Gnome Disk Utility – this disk utility from RedHat, not only that it provides detailed information about the disk and S.M.A.R.T. data, but also has options similar to a partitioning application (format, unmount, edit partition, etc.). It is included by default in Ubuntu.

GParted – a full featured Gnome partition manager with a friendly user interface suited for about any disk management task. Has a live cd version called GParted Live which makes partitioning a breeze.

CLI applications for disk management:

ls – the directory listing command, probably one of the most popular tool for both novice and experts; one of the best results is provided using the –alh parameters.

du – summarize disk usage for each file, recursively for directories. Use -h parameter for a human readable output of the size and -s parameter to summarize the disk usage of a directory instead of displaying the size of each file (helpful for directories with a large number of files/subdirectories). The –max-depth parameter also deserves to be mentioned.

df – can be defined as the CLI version of the Gnome System Monitor’s “File System” tab previously mentioned. Like in the case of du command, use -h parameter for better readability.

fdisk – command line interface partition editor

cfdisk – same as fdisk, but with a more user-friendly interface

CLI search and replace in multiple files

Here is a quick tip about how to find and replace a text in multiple files, from CLI.

In this example you have some text files (.txt) with urls like “http://example.com, http://another-example.com…”. What you are trying to do is to replace all “http” references with “https”.

You can find all text files using the following command in the directory where the files are located:

find -type f -name *.txt

You can execute a command on the search result using the -exec parameter for the find command:

find -type f -name *.txt -exec my_command

The actual search and replace will be performed using sed command:

find -type f -name *.txt -exec sed -i 's/http/https/' {} \;