Computer
Fix Joseph Posted on 2:13 am

Building Linux Terminal Programs and Utilities

Tools for building programs
We will talk about the interpreted software platforms available on most systems – Python, Perl, awk, Bash. In addition, you will need a Make system for building code.

The code a programmer writes is often divided into .h header files and .c source code files.

The gcc compiler does the following:

When you compile -S, the source code is converted from .c to .s assembly code.
When -c is compiled, the assembly code is transformed into .o object code.

The -l link is a reference to the standard libraries for creating the executable.
By default gcc combines the above steps to create an executable.

gcc hello.c – creates a.out, not .o or .s files.

Make build system
This system automates the compilation of multiple source files in a complex project, arranges the dependent actions, and executes them in order. It then reads the configuration from a “build” file, usually called a Makefile. As a result, the Makefile acts as a software component of the project’s build process.

The process of the make command
make will read data from the Makefile and run commands to build the final target. For example, in the Makefile shown above, make will run commands for rules 2-4, followed by rule 1:

gcc -c dep1.c # create dep1.o
gcc -c dep2.c # create dep2.o
gcc -c main.c # create main.o

gcc -o an_exe main.o dep1.o dep2.o -lm

Linux terminal utilities
To run a command at a specific time, use at:

at 17:00
at> log_days_activities.sh # sometimes you can abbreviate: at> prompt [Ctrl+D]

at offers the use of keywords such as now, noon, today, tomorrow as well as different options such as hours and days which can be specified with a + character.

at noon
at now + 1 year
at 3:08pm + 1 day
at 3:01 p.m. December 19, 2018

Use cron if you want to set how often you want to run commands.

The Linux terminal utility cron allows you to set up periodic runs through a crontab file, which controls the process and determines what needs to be run and when. Entries can be created in any file and added to the system using the crontab command as follows:

echo ’15 18 30 6 * find /home -mtime +30 -print’ > f00
crontab f00 # add the previous command to the system crontab

crontab -l # list of crontab entries
crontab -r # delete crontab entries

The output of the cron command will be done via mail (alternatively it can be redirected to a file with >).