Appendix C Command Line

The command line or CLI is text interface to your computer and an alternative to graphical user interfaces like windows. It typically involves typing text commands into a terminal to perform some operation. Although not necessary to learn, it can be helpful. The terminal which can be launched from Control + Alt + T is a command line running in a window.

An exhaustive tutorial on the command line is a bit beyond the scope of the manual. The man command brings up the user manual and can be used to learn more about a commands use, its options, and inputs. If you wanted to learn more about the df (disk free) command, enter the following into a command line and press enter :

man df

This will show you the user manual for the df command containing and explanation of the command and other useful information. For example is the -h option gives a human readable output. If the manual is way too long you can press the / key and type in what you want to search for. To scroll up and down in a manual page press Up arrow or Down arrow. To quit a man page press q.

df -h

will make a much nicer output than


To list files on the current file system one of the most important commands to know is ls.


will show the files in your current directory and the man page lists more options such as viewing all files or long listing.

To change to another directory an important command is

cd [dir]

where [dir] is the directory you want to switch to. Another thing that is useful is you can append .. after cd to make it go up one level.

Many command line commands have what are called options that use one or sometimes two - to type before options that allow you to do different options on different commands which checking the man page to see what options for each command.

There is also the command line for managing and installing packages which is beyond the scope of this appendix but please see apt package management for how to insert and remove packages from the command line. To see how to manage snap packages on the command line see snap documentation .

If you need to edit a text file from the command line the easiest editor included is nano so to edit a file from the command line if you broke something run

nano [file]

where you replace [file] with the file you want to edit. Lubuntu also ships with the advanced text editor vim however documenting how to use that editor is beyond the scope of this manual. If you want to learn that advanced text editor run the command


which provides you an interactive tutorial.

If you want to stop something running in the terminal press Control +C. To run a task in the background type a & at the end of it.

If you want just to see the contents of a file on standard output run

cat [filename]

If you have a command and you don’t want to type the whole thing out you can press the tab key. If this does not work press tab again and see the list of available commands to run. This process is called tab completion.

If you want a command to run if the first completes run

command 1 && command 2

One of the most powerful uses of the command line is called a pipe which allows you to take the output of one command and pipe it to a second to this for example

lspci |less

. Also | is called the pipe character. The command less is what is known as a pager that is really useful to see commands that produce lots of output interactively.

To get the previous command you have entered press Up Arrow. To go to the next command in your history press Down Arrow.