Navigate the filesystem using the CLI

The Command Line Interface

Now that we have Linux installed as a Virtual Machine (VM) we can look at basic features of the command line interface (CLI). At times you might also hear the CLI referred to as a shell. One of the most important topics that will help you in your Linux experience is man and info pages. We will learn how to use and navigate both of these items. After we have a basic understanding of how to gain information about a command we will move into navigating the Linux filesystem. We will learn how to list the contents of a directory, navigate between different directories, copy, move and rename files. These are all extremely important topics within Linux. Even though Linux does have a GUI (Graphical User Interface) a majority of using and maintaining Linux is done on the CLI. During my experience with using Linux I have found that I can do tasks on the CLI can be a lot quicker then trying to do it within a GUI.

man pages

man (think of this is a shorten word for manual) pages provide details about how to use a command and different options you can give to the command. These are very helpful with learning about commands and how to use them.

man page levels

1 General commands

2 System calls

3 Library functions

4 Special files (think /dev) and drivers

5 File formats and conventions

6 Games and screensavers

7 Miscellaneous

8 System admin commands and daemons

info pages

info pages are like man pages, except they are better. info pages allow you to navigate between pages as they are linked together. This allows you to navigate between commands without having to exit.

The two videos above provide a great introduction to man and info pages. Please read "MAN PAGES - HOW TO READ" as it also provides an overview of man and info pages.



ls

The ls command is a very useful command. This command provides us with the ability to list the contents of a directory.

https://linux.die.net/man/1/ls

touch

The touch command has multiple uses. The one that you should get the most familiar with is that it creates a blank and empty file. Basically, if you need to create a new empty file use the touch command. Another use of the touch command is that it allows the ability to update the timestamps of files.

https://linux.die.net/man/1/touch

cp

The cp command provides the ability to copy (cp) a file to a new file. You can also copy and entire directory, but you have to make sure you provide an option on the command line to say copy the contents recursively (-r).

https://linux.die.net/man/1/cp

https://www.cyberciti.biz/faq/copy-command/

mv

The mv command provides the ability to move (mv) a file to a new file name or to a new directory. You can also move the entire contents of a directory to a new one. If you use the mv command keep in mind that the original file or directory will not exist anymore!

https://linux.die.net/man/1/mv

pwd

The pwd command is a very useful command if you ever forget what directory you are currently in when using the CLI. The pwd command will post the current working directory. Yes, it is a very simple command, but one I use frequently when I forget the location I am in on the cli.

https://linux.die.net/man/1/pwd

mkdir & rmdir & rm

These three commands are important to learn and understand. The mkdir allows you to make a directory. When you issue the mkdir you provide the name of the directory you want to create after the command (i.e. mkdir ics231 would create an empty ics231 directory). The rmdir command allows you to delete a directory if it is empty. Personally, I rarely use the rmdir command as usually I want to delete all the contents of the directory too. To do this you can use the rm command. The rm command can remove (rm) files and directories if you provide the recursive option to the command (-r). Be careful as the Linux CLI does not have a trash can!

https://linux.die.net/man/1/rmdir

https://linux.die.net/man/1/rm

https://linux.die.net/man/1/mkdir

File Globbing

Linux uses file globbing to do wild card matches on filenames. This is an important concept to understand as it allows you to create, search or remove files based on a specific pattern. Think of these like a regular expression, but for filenames in Linux.

https://www.geeksforgeeks.org/file-globbing-linux/

https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm