Michael O.
3min Read

Linux Basics – man and mkdir

In our previous articles we went over the basics of navigating Linux and the kill command. In this tutorial, we go over the basics of the man and mkdir commands. Download our Linux commands cheat sheet.


The Linux ‘man’ command

The Linux man command is one of the lesser known helpers for those new to Linux. Typing in ‘man find‘ give you a whole manual page on the ‘find‘ command and this is what ‘man‘ is short for – Manual.

Let us see part of the ‘man find‘ command and its output:

FIND(1)               General Commands Manual                 FIND(1)

NAME
find - search for files in a directory hierarchy

SYNOPSIS
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]

DESCRIPTION
This manual page documents the GNU version of find. GNU find searches the directory tree rooted at each given starting-point
by evaluating the given expression from left to right, according to the rules of precedence (see section OPERATORS), until the
outcome is known (the left hand side is false for and operations, true for or), at which point find moves on to the next file
name. If no starting-point is specified, `.' is assumed.

If you are using find in an environment where security is important (for example if you are using it to search directories
that are writable by other users), you should read the `Security Considerations' chapter of the findutils documentation, which
is called Finding Files and comes with findutils. That document also includes a lot more detail and discussion than this
manual page, so you may find it a more useful source of information.

OPTIONS
The -H, -L and -P options control the treatment of symbolic links. Command-line arguments following these are taken to be
names of files or directories to be examined, up to the first argument that begins with `-', or the argument `(' or `!'. That
argument and any following arguments are taken to be the expression describing what is to be searched for. If no paths are
given, the current directory is used. If no expression is given, the expression -print is used (but you should probably con‐
sider using -print0 instead, anyway).

This manual page talks about `options' within the expression list...........etc,etc

The actual entry continues for quite a bit so go ahead and type it into your Linux terminal to see the entire entry.

Searching the Linux man entry

Searching for a keyword in a manual entry is the same syntax as ‘vi‘ – type a forward slash (/) followed by the search string and then press enter. You can jump to the next entry found by pressing ‘n‘.

Searching for a term across all man pages is accomplished by using man -k [search string]. You could even go so far as to type ‘man man‘ to get instructions on the Linux man command! This is actually a good place to start as the structure of the ‘man‘ system is explained here and makes the system a bit easier to understand.

Linux man can be invoked for all the standard Linux commands, but some extra software or custom written commands may not have Linux man entries.

Remember: Linux man is your helper – no need to always use Google.


The mkdir command

Creating a directory is pretty easy. The command we are after is mkdir which is short for Make Directory. In the most basic form, we can type ‘mkdir [mynewdirectory]‘ and the new directory will be created in our current directory (pwd). Once again the directory creation can either be a relative path or an absolute path.

A handy switch to use is ‘-p‘ if we need to create the path. Thus, if we are in the directory ‘/opt‘ and we need ‘/opt/books‘, it is simple enough. Issue ‘mkdir books‘ and it is done.

If we need ‘/opt/books/ebooks/linux‘ then we can use the ‘-p‘ switch (for path). Issue ‘mkdir -p /opt/books/ebooks/linux‘ and it will be done. Adding the ‘-v‘ switch will make mkdir tell us what is doing as well.

The opposite command is ‘rmdir directoryname‘. The ‘rmdir‘ command will only delete empty directories. So it is a safer option than rm -rf directoryname.

Don’t miss our next Linux Basics article where we dive into log files.

Happy hosting!


The Author

Michael O.

Michael is the founder, managing director, and CEO of HOSTAFRICA. He studied at Friedrich Schiller University Jena and was inspired by Cape Town's beauty to bring his German expertise to Africa. Before HOSTAFRICA, Michael was the Managing Director of Deutsche Börse Cloud Exchange AG, one of Germany's largest virtual server providers.

More posts from Michael