Anatomy of command line arguments in Linux

While designing a simple C program or a full fledged command line application, it is pretty usual to have a requirement for arguments to be passed while running the executable/application. These arguments are known as command line arguments. These parameters govern the behaviour of the program to some extent, as these are the inputs based on which output is computed/displayed.

Another usage of these command line arguments comes in the form of various options of a command, be it on Linux, Windows or any platform. In Linux, any command is actually an executable being triggered through Linux shell. In code, the entry point to this executable (in ELF format) will be the main() method . The Linux shell communicates the command line arguments to the program by passing these parameters to the main() method. In this article, we shall go through the advanced concepts related to command line arguments in Linux using C programming examples.
(more…)

Linux time and date functions – A must read for developers

In this pacing world, time plays an important role in every aspect of Life. Even in industries like embedded, automotive etc time plays a very important role. Seems like everyone is working just to minimize this parameter called time. If we talk about software industry, here too, minimising the time complexity is the most prominent objective driving thick and thin. Moreover, Benchmarking software and programs are taken much seriously these days in research as well as in industry. However, talking in terms of software running on an OS, what is time and how do we measure it? Here in this article we shall be learning about various Linux time and date functions.
(more…)

5 GCC compiler options worth sharing

If you have worked on Linux software development using C language, you would have definitely come across the gcc compiler. It is one of the most popular C compiler as of today. GCC contains a huge list of compiler options. For those who are new to gcc, they must have knowledge of some basic gcc compiler options. This article would discuss five gcc compiler options that I personally use the most.
(more…)

Delete both files and directories using Linux remove function

Till now we have read that there are separate functions (unlink and rmdir) to delete files and directories in Linux. In this article, we will understand Linux remove function that is capable of deleting both files and directories in Linux.
(more…)

Delete a directory using Linux rmdir function

In our last article on unlink() function here, we discussed how this function can be used to delete files. Also, this function has a limitation that it cannot be used to delete directories. Here in this article, we will discuss the Linux rmdir function. As the name suggests this function is used to delete directories in Linux.
(more…)

Delete a file using Linux unlink function

Sometimes it is required to delete a file present on disk from within the C code. In Linux this can be done through the Linux unlink function. This function holds the capability to delete the file but under certain conditions.
(more…)

Error handling in C programming on Linux

While writing C code for Linux programs, it’s very important to put in place proper error handling mechanism as it saves precious time while debugging any problem with the same code. Mostly developers write code that contains broken error handling and this causes them to invest hours while debugging a complex code. In this example we will discuss in detail how to perform error handling in C.
(more…)

How to determine GNU C library glibc version on Linux system?

There are times when it is required to determine GNU C Library glibc version on your Linux box. There are two different ways in which this can be done. One way is through command line while the other way is through using some C functions in the code. In this article we will understand both the ways to determine the glibc version.
(more…)

Linux process that changes its own name

In one of our earlier articles, we learned how command line arguments are accessed from within the code. Here in this article, we will see how these command line arguments can be used by a Linux process to change its own name.
(more…)

How to access Linux command line arguments in C code

Have you ever used Linux command line? if yes then you would have definitely come across command line utilities which require arguments. For example basic commands like ‘cat’, ‘rm’ etc require a file name as an argument. Ever wondered how the code is able to access these Linux command line arguments?  In this article, we will understand how the Linux command line arguments are accessed from within the code of an executable in Linux.
(more…)

© 2013 MyLinuxBook. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie
Close
Please support MyLinuxBook
Let your friends and followers know about MyLinuxBook

Twitter

Facebook

Google+